1 2 Previous Next 24 Replies Latest reply on Jan 17, 2012 8:14 AM by h3llghost Branched to a new discussion.

    ClassNotFoundException using EJB in RESTfull Application

    h3llghost Newbie

      Hello,

       

      I have a EJB project, which contains my entities and connecting to the database via hibernate.

      My second project is the dynamic web project containing the classes. I created the dependency, that the project needs the EJB project.

      Migrating to AS 7.1 results into ClassNotFoundException, when I am trying to use the RESTfull application.

       

      Here the full log output:

      19:47:44,536 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/BF3AccessRestrictionJSON]] (http-localhost-127.0.0.1-8080-1) StandardWrapper.Throwable: java.lang.NoClassDefFoundError: Lcom/DataAccessObjectRemote;

                at java.lang.Class.getDeclaredFields0(Native Method) [:1.7.0]

                at java.lang.Class.privateGetDeclaredFields(Unknown Source) [:1.7.0]

                at java.lang.Class.getDeclaredFields(Unknown Source) [:1.7.0]

                at org.jboss.resteasy.core.PropertyInjectorImpl.populateMap(PropertyInjectorImpl.java:139) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.core.PropertyInjectorImpl.<init>(PropertyInjectorImpl.java:57) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.core.InjectorFactoryImpl.createPropertyInjector(InjectorFactoryImpl.java:50) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.spi.ResteasyDeployment.createFromInjectorFactory(ResteasyDeployment.java:280) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:259) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:220) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.7.Final.jar:]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151) [jboss-as-web-7.1.0.CR1b.jar:7.1.0.CR1b]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.7.Final.jar:]

                at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.7.Final.jar:]

                at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.7.Final.jar:]

                at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.7.Final.jar:]

                at java.lang.Thread.run(Unknown Source) [:1.7.0]

      Caused by: java.lang.ClassNotFoundException: com.DataAccessObjectRemote from [Module "deployment.BF3AccessRestrictionJSON.war:main" from Service Module Loader]

                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

                ... 24 more

       

       

      19:47:44,540 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/BF3AccessRestrictionJSON].[de.h3llghost.service.RESTService]] (http-localhost-127.0.0.1-8080-1) Allocate exception for servlet de.h3llghost.service.RESTService: java.lang.ClassNotFoundException: com.DataAccessObjectRemote from [Module "deployment.BF3AccessRestrictionJSON.war:main" from Service Module Loader]

                at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

                at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

                at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

                at java.lang.Class.getDeclaredFields0(Native Method) [:1.7.0]

                at java.lang.Class.privateGetDeclaredFields(Unknown Source) [:1.7.0]

                at java.lang.Class.getDeclaredFields(Unknown Source) [:1.7.0]

                at org.jboss.resteasy.core.PropertyInjectorImpl.populateMap(PropertyInjectorImpl.java:139) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.core.PropertyInjectorImpl.<init>(PropertyInjectorImpl.java:57) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.core.InjectorFactoryImpl.createPropertyInjector(InjectorFactoryImpl.java:50) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.spi.ResteasyDeployment.createFromInjectorFactory(ResteasyDeployment.java:280) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.spi.ResteasyDeployment.createApplication(ResteasyDeployment.java:259) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.spi.ResteasyDeployment.start(ResteasyDeployment.java:220) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.init(ServletContainerDispatcher.java:67) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.init(HttpServletDispatcher.java:36) [resteasy-jaxrs-2.3.0.GA.jar:]

                at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1202) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:952) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:188) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.7.Final.jar:]

                at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:151) [jboss-as-web-7.1.0.CR1b.jar:7.1.0.CR1b]

                at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.7.Final.jar:]

                at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.7.Final.jar:]

                at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.7.Final.jar:]

                at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.7.Final.jar:]

                at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2033) [jbossweb-7.0.7.Final.jar:]

                at java.lang.Thread.run(Unknown Source) [:1.7.0]

       

        • 1. Re: ClassNotFoundException using EJB in RESTfull Application
          Peter Johnson Master

          The class com.DataAccessObjectRemote is not part of JBoss AS 7.0.2 (well, at leats not aprt of the web profile version). Is it one of yours classes? Where is it referenced?

          • 2. Re: ClassNotFoundException using EJB in RESTfull Application
            h3llghost Newbie

            Yes it is my own class and it is part of my EJB project.

            I have added the project to the build path.

            • 3. Re: ClassNotFoundException using EJB in RESTfull Application
              Peter Johnson Master

              Did you verify that the class appears in the deployed application?

               

              Based on your other question, I assume you are using Eclipse for this project. If the deployed app doesn't have this class, someone else will have to help you, I never use Eclipse to compile or package my applications (because I don't trust it, its attempts to be "helpful" usually makes things worse).

              • 4. Re: ClassNotFoundException using EJB in RESTfull Application
                h3llghost Newbie

                I can find the classes under standalone -> deployments -> deployment name.

                So there are available. But I don't know if there is missing some annotation or something like that, which allows the link from other classes.

                • 5. Re: ClassNotFoundException using EJB in RESTfull Application
                  h3llghost Newbie

                  The two files works under JBoss AS 6, but not with JBoss AS 7.

                  But for JBoss AS 6 I have to move my classes from the backend to the package com, because the system only searches there. So I get a ClassNotFoundException for com.DataAccessObjectRemote, but it is in the package de.h3llghost.data.

                  It is annoying. But that doesn't work for JBoss AS 7.

                  • 6. Re: ClassNotFoundException using EJB in RESTfull Application
                    Peter Johnson Master

                    Ahah! So you finally admit that there is no such class named com.DataAccessObjectRemote, that what you really have is de.h3llghost.data.DataAccessObjectRemote. Now things make more sense, and this question is not about a class not found exception, but rather a misconfiguration of the web service. Could you post some source where DataAccessObjectRemote is referenced in annotations or config files? That might help point out the issue (it appears that you referenced DataAccessObjectRemote by is simple name rather than its full name of de.h3llghost.data.DataAccessObjectRemote somewhere.)

                    • 7. Re: ClassNotFoundException using EJB in RESTfull Application
                      h3llghost Newbie

                      No not really, it makes no difference, how I call the package. With JBoss AS 6 only the package com works.

                       

                      import de.h3llghost.data.DataAccessObjectRemote;
                      
                      
                      @ApplicationPath("services")
                      public class RESTService extends Application {
                                @EJB(lookup="java:module/DataAccessObject")
                                protected DataAccessObjectRemote dao;
                      
                      
                      
                      }
                      
                      • 8. Re: ClassNotFoundException using EJB in RESTfull Application
                        Peter Johnson Master

                        So this is a JNDI lookup. Have you checked the JNDI list to see what the EJB is really named? (I know how to get the list of JNDI entries on earlier versions of JBoss AS - use the JNDIView mbean - but not on AS 7)  Have you tried:

                         

                        @EJB(lookup="java:module/de.h3llghost.data.DataAccessObject"

                        • 9. Re: ClassNotFoundException using EJB in RESTfull Application
                          h3llghost Newbie

                          No not yet, but it didn't work for me.

                           

                          Here is the output of the deployment:

                          JNDI bindings for session bean named DataAccessObject in deployment unit deployment "Backend.jar" are as follows:

                           

                              java:global/Backend/DataAccessObject!de.h3llghost.data.DataAccessObjectRemote

                              java:app/Backend/DataAccessObject!de.h3llghost.data.DataAccessObjectRemote

                              java:module/DataAccessObject!de.h3llghost.data.DataAccessObjectRemote

                              java:global/Backend/DataAccessObject

                              java:app/Backend/DataAccessObject

                              java:module/DataAccessObject

                          • 10. Re: ClassNotFoundException using EJB in RESTfull Application
                            Peter Johnson Master

                            Try these (often the 'java:app/' is implied)

                             

                            @EJB(lookup="Backend/DataAccessObject")

                             

                            @EJB(lookup="Backend/DataAccessObject!de.h3llghost.data.DataAccessObjectRemote")

                             

                            If that doesn't help, perhaps someone with more AS 7 experience can jump in and help.

                            • 11. Re: ClassNotFoundException using EJB in RESTfull Application
                              h3llghost Newbie

                              Sorry, but no difference. But I think the problem isn't the lookup. When I remove the ejb annotation I have the same problem.

                              • 12. Re: ClassNotFoundException using EJB in RESTfull Application
                                jaikiran pai Master

                                19:47:44,540 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/BF3AccessRestrictionJSON].[de.h3llghost.service.RESTService]] (http-localhost-127.0.0.1-8080-1) Allocate exception for servlet de.h3llghost.service.RESTService: java.lang.ClassNotFoundException: com.DataAccessObjectRemote from [Module "deployment.BF3AccessRestrictionJSON.war:main" from Service Module Loader]

                                          at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

                                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

                                          at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

                                          at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

                                          at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

                                          at java.lang.Class.getDeclaredFields0(Native Method) [:1.7.0]

                                          at java.lang.Class.privateGetDeclaredFields(Unknown Source) [:1.7.0]

                                          at java.lang.Class.getDeclaredFields(Unknown Source) [:1.7.0]

                                          at org.jboss.resteasy.core.PropertyInjectorImpl.populateMap(PropertyInjectorImpl.java:139) [resteasy-jaxrs-2.3.0.GA.jar:]

                                 

                                Can you post the output of:

                                 

                                jar -tf BF3AccessRestrictionJSON.war

                                 

                                and are you sure none of the classes have references to com.DataAccessObjectRemote (maybe some stale class is lying around)?

                                • 13. Re: ClassNotFoundException using EJB in RESTfull Application
                                  h3llghost Newbie

                                  Here is the output:

                                  META-INF/MANIFEST.MF

                                  META-INF/

                                  WEB-INF/

                                  WEB-INF/classes/

                                  WEB-INF/classes/de/

                                  WEB-INF/classes/de/h3llghost/

                                  WEB-INF/classes/de/h3llghost/service/

                                  WEB-INF/classes/de/h3llghost/service/ressources/

                                  WEB-INF/classes/de/h3llghost/service/ressources/Options.properties

                                  WEB-INF/classes/de/h3llghost/service/RESTService.class

                                  WEB-INF/classes/de/h3llghost/service/RESTServiceException.class

                                  WEB-INF/classes/de/h3llghost/service/Result$errorTypes.class

                                  WEB-INF/classes/de/h3llghost/service/Result.class

                                  WEB-INF/classes/de/h3llghost/service/ServerManagement.class

                                  WEB-INF/lib/

                                  WEB-INF/lib/commons-codec-1.6.jar

                                  WEB-INF/lib/httpcore-4.1.4.jar

                                  WEB-INF/web.xml

                                   

                                  Yes there is nothing. All checked.

                                  • 14. Re: ClassNotFoundException using EJB in RESTfull Application
                                    jaikiran pai Master

                                    Extract that .war to some folder, then post the output of:

                                     

                                    javap -classpath ./WEB-INF/classes de.h3llghost.service.RESTService

                                    1 2 Previous Next