JSONArray cannot be resolved to a type

Discussion in 'Java' started by carmelo, Nov 17, 2008.

  1. carmelo

    carmelo Guest

    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
    carmelo, Nov 17, 2008
    #1
    1. Advertising

  2. carmelo

    Roedy Green Guest

    On Mon, 17 Nov 2008 07:53:58 -0800 (PST), carmelo <>
    wrote, quoted or indirectly quoted someone who said :

    >How come? How can I do to fix it?

    try putting the jar in the ext directory. See
    http://mindprod.com/jgloss/ext.html
    --
    Roedy Green Canadian Mind Products
    http://mindprod.com
    Your old road is
    Rapidly agin'.
    Please get out of the new one
    If you can't lend your hand
    For the times they are a-changin'.
    Roedy Green, Nov 17, 2008
    #2
    1. Advertising

  3. carmelo

    Lew Guest

    carmelo wrote:
    >> 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


    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 Green wrote:
    > 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 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


    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.

    --
    Lew
    Lew, Nov 18, 2008
    #3
  4. carmelo

    carmelo Guest

    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


    On 18 Nov, 04:01, Lew <> wrote:
    > 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 :)
    carmelo, Nov 18, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bossanovaplayer
    Replies:
    4
    Views:
    12,580
    bossanovaplayer
    Jun 17, 2005
  2. alessio
    Replies:
    1
    Views:
    816
  3. dushkin
    Replies:
    5
    Views:
    7,208
  4. Lionel
    Replies:
    3
    Views:
    751
    Lionel
    Aug 25, 2008
  5. Vincent Ly
    Replies:
    14
    Views:
    14,662
    Arne Vajhøj
    Dec 3, 2009
Loading...

Share This Page