Getting exception invoking JSONArray.fromObje

Help
2008-05-29
2013-04-29
  • Hi, I am trying to use the method JSONArray.fromObject, but when I run the web application in the server, get the this exception StandardWrapperValve[Listas]: PWC1406: Servlet.service() for servlet Listas threw exception
    java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
    get the exception this line
    net.sf.json.JSONArray jsonArray = JSONArray.fromObject( "['json','is','easy']"  );

    I’m using the following libraries

    \commons-beanutils.jar
    \commons-collections-3.2.1.jar
    \commons-lang-2.3.jar
    \commons-logging-1.1.jar
    \ezmorph-1.0.4.jar
    \jakarta-oro-2.0.8.jar
    \json-lib-2.2.1-jdk15.jar
    \jstl.jar
    \standard.jar
    And GlassFish V2 in the server
    The complete error is this:
    StandardWrapperValve[Listas]: PWC1406: Servlet.service() for servlet Listas threw exception
    java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
            at java.lang.ClassLoader.defineClass1(Native Method)
            at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
            at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
            at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
            at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
            at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at com.sun.appserv.server.util.ASURLClassLoader.loadClass(ASURLClassLoader.java:144)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            at Requisiciones.Listas.ListaDependencias(Listas.java:107)
            at Requisiciones.Listas.processRequest(Listas.java:36)
            at Requisiciones.Listas.doGet(Listas.java:130)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
            at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
            at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
            at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
            at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
            at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
            at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
            at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
            at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
            at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
            at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
            at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
            at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
            at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
            at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)
    Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
            at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
            at com.sun.appserv.server.util.ASURLClassLoader.loadClass(ASURLClassLoader.java:144)
            at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
            at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
            ... 49 more

     
    • aalmiray
      aalmiray
      2008-05-29

      Hi Jorge,

      At first glance it seems to be a classpath config problem. Do me a favor, try to instantiate a NestableRuntimeException instead of calling JSONArray.fromObject(), if that works your classpath is ok and Json-lib may be broken, if not then you may have a misconfiguration in your server.

      Thanks.

       
    • I made the test with NestableRuntimeException and it run without problem, review the log server at the time of publishing the application and if it appears the library in the classpath:

      [AbstractLoader] Unload Web Service Endpoint(s) Status: true
      LoaderEventNotifier: AppEvent: AFTER_UNLOAD -> Requisiciones
      Unloading persistence units for application: C:/Documents and Settings/UNAMMX/Mis documentos/NetBeansProjects/Requisiciones/build/web
      entityManagerFactories.size() = 0
      Finished unloading persistence units for application: C:/Documents and Settings/UNAMMX/Mis documentos/NetBeansProjects/Requisiciones/build/web
      Adding directory to class path:C:\Archivos de programa\glassfish-v2ur2\domains\domain1\lib\classes
      Adding jar to class path:C:\Archivos de programa\glassfish-v2ur2\domains\domain1\lib\derbyclient.jar
      Adding jar to class path:C:\Archivos de programa\glassfish-v2ur2\domains\domain1\lib\jconn3.jar
      Adding jar to class path:C:\Archivos de programa\glassfish-v2ur2\domains\domain1\lib\org-netbeans-modules-web-httpmonitor.jar
      Adding directory to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\classes
      Adding jar to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\lib\commons-beanutils.jar
      Adding jar to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\lib\commons-collections-3.2.1.jar
      Adding jar to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\lib\commons-lang-2.3.jar
      Adding jar to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\lib\commons-logging-1.1.jar
      Adding jar to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\lib\ezmorph-1.0.4.jar
      Adding jar to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\lib\jakarta-oro-2.0.8.jar
      Adding jar to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\lib\json-lib-2.2.1-jdk15.jar
      Adding jar to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\lib\jstl.jar
      Adding jar to class path:C:\Documents and Settings\UNAMMX\Mis documentos\NetBeansProjects\Requisiciones\build\web\WEB-INF\lib\standard.jar
      deployed with moduleid = Requisiciones
      LoaderEventNotifier: AppEvent: BEFORE_LOAD -> Requisiciones
      [AbstractLoader] Unload Web Service Endpoint(s) Status: true
      LoaderEventNotifier: AppEvent: AFTER_LOAD -> Requisiciones
      Loading persistence units for application: C:/Documents and Settings/UNAMMX/Mis documentos/NetBeansProjects/Requisiciones/build/web
      Finished loading persistence units for application: C:/Documents and Settings/UNAMMX/Mis documentos/NetBeansProjects/Requisiciones/build/web
      I’m using netbeans 6.1 with Gassfish v2u2 bundle, if  it is the server configuration , Would you can suggest me what configurations should revise?

      Thanks

      Jorge