JSONArray cannot be resolved to a type

C

carmelo

Hi everybody,
I'm trying a MapGuide JSP example, on Tomcat, with which I get this
compiler error:

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 50 in the jsp file: /javaviewersample/query/
classes/query.jsp
JSONArray cannot be resolved to a type
47:
48: public String getNumOp()
49: {
50: JSONArray jsonArray = new JSONArray();
51: for(int i=0;i<6;i++)
52: {
53: jsonArray.put(numOperators);


How come? How can I do to fix it?

I copied the json.jar file from
C:\Program Files\Autodesk\MapGuideEnterprise\WebServerExtensions\www
\javaviewersample
to
C:\Program Files\Autodesk\MapGuideEnterprise\WebServerExtensions\www
\WEB-INF\lib



Hoping in your help
Cheers
Carmelo
 
L

Lew

this is a very unusual place for your JSP to reside on the face of it. Not
knowing the layout of your web app, it's hard to be sure, but the usual layout is:

webapps/APPNAME/ <= html, JSP and such
webapps/APPNAME/WEB-INF/ <= hidden resources start here
webapps/APPNAME/WEB-INF/classes/ <= root of all compiled Java
webapps/APPNAME/WEB-INF/lib/ <= JARs go here
JSONArray cannot be resolved to a type
47:
48: public String getNumOp()
49: {
50: JSONArray jsonArray = new JSONArray();
51: for(int i=0;i<6;i++)
52: {
53: jsonArray.put(numOperators);


How come? How can I do to fix it?


Roedy said:
try putting the jar in the ext directory. See
http://mindprod.com/jgloss/ext.html

This is not the normal approach for web applications, nor recommended by most
in most circumstances. Roedy's link is excellent for those times when the
extensions directory is an appropriate approach, but this is might not be one
of those times.

I don't understand the Autodesk WebServerExtensions aspect of this. Usually
you put JARs needed by all webapps for a given app server (Tomcat in your
case) in a server-specific directory, like TOMCAT_HOME/lib/ or such. Check
your Tomcat docs for the exact location. App-specific JARs go in the
WEB-INF/lib/ directory for that application.
 
C

carmelo

Thank you guys for your help!

The MapGuide web application it's running on Apache 2.2.4 HTTP server,
which integrates Tomcat, creating a number of "worker" processes
responsible for executing JSPs/servlets (Integrating Tomcat with
Apache article: http://www.serverwatch.com/tutorials/article.php/2203891).

That's the reason for which it said to copy the jar file to
C:\Program Files\Autodesk\MapGuideEnterprise\WebServerExtensions\www
\WEB-INF\lib


I don't understand the Autodesk WebServerExtensions aspect of this.  Usually
you put JARs needed by all webapps for a given app server (Tomcat in your
case) in a server-specific directory, like TOMCAT_HOME/lib/ or such.  Check
your Tomcat docs for the exact location.  App-specific JARs go in the
WEB-INF/lib/ directory for that application.

I created the WEB-INF/lib directory on the App-specific directory,
then I copied the json.jar file to the MyApp/WEB-INF/lib directory.
Now it works without compiling errors :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top