1 2 Previous Next 21 Replies Latest reply on Oct 27, 2015 1:30 PM by leysson

    NoClassDefFoundError when call EJB 2.1 in AS7

    huasonator

      Hi all,

      When I call EJB 2.1 ,i dont have problem with de lookup, is work, but when i need create de bean, i get the next error:

       

      java.lang.NoClassDefFoundError: Could not initialize class org.jboss.security.SecurityAssociation

       

      This class is found in jbossall-client.jar, this jar is put in WEN-INF/lib, within example.war. I read de classloader documentation and the war is isolate, what is the problem? I can not get remote interface in AS7?

       

      Regards...

        • 1. Re: NoClassDefFoundError when call EJB 2.1 in AS7
          sfcoy

          Is the EJB actually remote?

           

          Or is it deployed in the same server instance?

           

          Or is it deployed in the same application (EAR)?

          • 2. Re: NoClassDefFoundError when call EJB 2.1 in AS7
            huasonator

            The EJB 2.1 is deployed in jboss-4.0.5.GA in other machine, i can get the remote interface if i do the lookup from other server with the same jboss-4.0.5.GA, but when i try get the same remote interface within jboss-as-7.1.1.Final i got the java.lang.NoClassDefFoundError: Could not initialize class org.jboss.security.SecurityAssociation, this happens when i tried to create the remote interface ( i dont have problems get in the home interface).

             

            Any ideas?

            • 3. Re: NoClassDefFoundError when call EJB 2.1 in AS7
              wdfink

              Maybe you need to exclude security classes from AS7 via deployment-structure.xml

              • 4. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                huasonator

                I dont understand because the documentation say: "The war is considered to be a single module, so classes defined in WEB-INF/lib are treated the same as classes in WEB-INF/classes. All classes packaged in the war will be loaded with the same class loader." And i put jbossall-client.jar in WEB-INF/lib, this jar contains org.jboss.security.SecurityAssociation, for other hand i read that as org.jboss.security.SecurityAssociation was removed form AS7.

                 

                 

                Anayway i put the next deployment-structure.xml in my WEB-INF/lib:

                <jboss-deployment-structure>

                  <deployment>

                    <exclusions>

                      <module name="org.jboss.security" />

                    </exclusions>

                          </deployment>

                </jboss-deployment-structure>

                 

                But i get the same result...

                • 5. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                  huasonator

                  Next code works fine,i create a simple test with a main class and the code run (dependece jbossall-client.jar), but if i put the same code running on AS7 i get the problem.

                   

                  Code:

                  final Properties properties = new Properties();

                   

                  properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");

                  properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");

                  properties.put(Context.PROVIDER_URL, "jnp://192.168.0.138:1099");

                   

                  Context context = new InitialContext(properties);

                  Object objectLookup = context.lookup("ExampleJNDI"); // it works fine

                  Object ejbService = objectLookup.getClass().getMethod("create", new Class[]{}).invoke(objectLookup, new Object[]{}); // throws Exception

                   

                  Object result = ejbService.getClass().getMethod("exampleMethod", new Class[]{}).invoke(ejbService, new Object[]{});

                        

                  System.out.println(result);  

                   

                       

                   

                   

                  Stacktrace:

                   

                  18:39:43,392 ERROR [stderr] (http--127.0.0.1-8080-1) java.lang.reflect.InvocationTargetException

                  18:39:43,394 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                  18:39:43,397 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                  18:39:43,400 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                  18:39:43,402 ERROR [stderr] (http--127.0.0.1-8080-1)    at java.lang.reflect.Method.invoke(Method.java:597)

                  18:39:43,404 ERROR [stderr] (http--127.0.0.1-8080-1)    at com.labs.example.struts.action.ExampleAction.invokeService(ExampleAction.java:69)

                  18:39:43,413 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                  18:39:43,414 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                  18:39:43,417 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                  18:39:43,420 ERROR [stderr] (http--127.0.0.1-8080-1)    at java.lang.reflect.Method.invoke(Method.java:597)

                  18:39:43,421 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)

                  18:39:43,425 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)

                  18:39:43,429 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)

                  18:39:43,431 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)

                  18:39:43,432 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)

                  18:39:43,433 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)

                  18:39:43,436 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)

                  18:39:43,437 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                  18:39:43,439 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

                  18:39:43,440 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                  18:39:43,441 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

                  18:39:43,443 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

                  18:39:43,444 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153

                  )

                  18:39:43,446 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

                  18:39:43,447 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                  18:39:43,449 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                  18:39:43,450 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

                  18:39:43,452 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

                  18:39:43,453 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

                  18:39:43,454 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

                  18:39:43,456 ERROR [stderr] (http--127.0.0.1-8080-1)    at java.lang.Thread.run(Thread.java:662)

                  18:39:43,457 ERROR [stderr] (http--127.0.0.1-8080-1) Caused by: java.lang.IllegalAccessError: tried to access class org.jboss.security.SecurityActions from class or

                  g.jboss.security.SecurityAssociation

                  18:39:43,459 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.security.SecurityAssociation.<clinit>(SecurityAssociation.java:141)

                  18:39:43,460 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.proxy.SecurityInterceptor$1.getPrincipal(SecurityInterceptor.java:87)

                  18:39:43,461 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:58)

                  18:39:43,463 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184)

                  18:39:43,464 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)

                  18:39:43,465 ERROR [stderr] (http--127.0.0.1-8080-1)    at $Proxy12.create(Unknown Source)

                  18:39:43,466 ERROR [stderr] (http--127.0.0.1-8080-1)    ... 30 more

                   

                  Any Ideas?

                  • 6. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                    sfcoy

                    I suspect that there is bound to be some class collisions in the JBoss 4.0.5 jbossall-client.jar and JBoss 7.x.

                     

                    It's worth trying a bit of elimination to see if we can get it to work.

                     

                    Try replacing jbossall-client.jar with jnp-client.jar to start with. The jbossall-client.jar is an amalgamation of the client jars in your 4.0.5 $JBOSS_HOME/client directory.

                     

                    If we can get it failing with class not found exceptions, then we can gradually try to add in only the relevent client jars.

                    • 7. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                      huasonator

                      I remove jbossall-client.jar from WEB-INF/lib and put the necessary jar (jnp-client.jar,jboss-common-client.jar,jboss-j2ee.jar,concurrent.jar,jboss-client.jar,jboss-serialization.jar,jboss-remoting.jar,jbosssx.jar,jboss-transaction-client.jar) but i get the same error.

                       

                      Really I do not understand why this happens, I prove the same WAR in jboss-6.1.0.Final and works fine. The problem is only wint AS7.

                      • 8. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                        sfcoy

                        We need to do this one jar at a time, not all at once...

                        • 9. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                          sfcoy

                          How do you know what is necessary? The jbossall-client.jar would have been completely redundant in your JBoss 4.0.5 client app deployment.

                          • 10. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                            huasonator

                            I did what you told me, the jar with the problem is jbosssx.jar, this jar has the class SecurityAssociation , when i remove i get the next stack trace.

                            21:09:55,747 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "example-struts-1.0.war"

                            21:10:02,644 ERROR [stderr] (http--127.0.0.1-8080-1) java.lang.reflect.InvocationTargetException

                            21:10:02,646 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                            21:10:02,647 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                            21:10:02,649 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                            21:10:02,651 ERROR [stderr] (http--127.0.0.1-8080-1)    at java.lang.reflect.Method.invoke(Method.java:597)

                            21:10:02,661 ERROR [stderr] (http--127.0.0.1-8080-1)    at cl.bennu.labs.example.struts.action.ExampleAction.invokeService(ExampleAction.java:69)

                            21:10:02,662 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                            21:10:02,664 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                            21:10:02,665 ERROR [stderr] (http--127.0.0.1-8080-1)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                            21:10:02,666 ERROR [stderr] (http--127.0.0.1-8080-1)    at java.lang.reflect.Method.invoke(Method.java:597)

                            21:10:02,667 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:270)

                            21:10:02,669 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:187)

                            21:10:02,670 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)

                            21:10:02,672 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)

                            21:10:02,674 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)

                            21:10:02,675 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)

                            21:10:02,676 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)

                            21:10:02,677 ERROR [stderr] (http--127.0.0.1-8080-1)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                            21:10:02,678 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

                            21:10:02,684 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                            21:10:02,685 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

                            21:10:02,687 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

                            21:10:02,688 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153

                            )

                            21:10:02,689 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

                            21:10:02,691 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                            21:10:02,692 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                            21:10:02,693 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

                            21:10:02,695 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

                            21:10:02,696 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

                            21:10:02,698 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

                            21:10:02,699 ERROR [stderr] (http--127.0.0.1-8080-1)    at java.lang.Thread.run(Thread.java:662)

                            21:10:02,701 ERROR [stderr] (http--127.0.0.1-8080-1) Caused by: java.lang.NoClassDefFoundError: org/jboss/security/SecurityAssociation

                            21:10:02,702 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.proxy.SecurityInterceptor$1.getPrincipal(SecurityInterceptor.java:87)

                            21:10:02,703 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:58)

                            21:10:02,704 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184)

                            21:10:02,705 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)

                            21:10:02,706 ERROR [stderr] (http--127.0.0.1-8080-1)    at $Proxy10.create(Unknown Source)

                            21:10:02,707 ERROR [stderr] (http--127.0.0.1-8080-1)    ... 30 more

                            21:10:02,708 ERROR [stderr] (http--127.0.0.1-8080-1) Caused by: java.lang.ClassNotFoundException: org.jboss.security.SecurityAssociation from [Module "deployment.ex

                            ample-struts-1.0.war:main" from Service Module Loader]

                            21:10:02,710 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:190)

                            21:10:02,712 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:468)

                            21:10:02,714 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:456)

                            21:10:02,716 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:423)

                            21:10:02,718 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:398)

                            21:10:02,720 ERROR [stderr] (http--127.0.0.1-8080-1)    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:120)

                            21:10:02,721 ERROR [stderr] (http--127.0.0.1-8080-1)    ... 35 more

                             

                             

                            When i put the jar, i get the same error Caused by: java.lang.IllegalAccessError: tried to access class org.jboss.security.SecurityActions from class org.jboss.security.SecurityAssociation

                             

                            I gave up

                            • 11. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                              sfcoy

                              I suspected that you would get this kind of problem.

                               

                              I think that if you really want to get this to work you could try and build your own version of jbosssx.jar against the security APIs in JBoss AS 7.

                              • 12. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                                sfcoy

                                For what it's worth, I've tried your scenario out myself and tried to configure the classloader to avoid issues.

                                 

                                Unfortunately, it is initially failing with a

                                 

                                {code}

                                java.lang.IllegalAccessError: tried to access class org.jboss.security.SecurityActions from class org.jboss.security.SecurityAssociation

                                          org.jboss.security.SecurityAssociation.<clinit>(SecurityAssociation.java:141)

                                          org.jboss.proxy.SecurityInterceptor$1.getPrincipal(SecurityInterceptor.java:87)

                                          org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:58)

                                          org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184)

                                          org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)

                                          $Proxy22.create(Unknown Source)

                                          org.jboss.demo.jee6.web.EjbClientServlet.doGet(EjbClientServlet.java:78)

                                          javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

                                          javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                                          org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62){code}

                                 

                                 

                                which suggests that JBoss AS 7 security configuration is actually preventing access to theses classes.

                                 

                                Therefore, I don't think even my previous idea is likely to work for you.

                                • 13. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                                  huasonator

                                  Yep... tonight i will give other perspective to this problem... try to access with new jboss-remote-naming with org.jboss.naming.remote.client.InitialContextFactory i think it should work... or maby the class valid the new format for the JNDI...

                                   

                                  https://docs.jboss.org/author/display/AS71/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project

                                   

                                   

                                  What do you  think?

                                  • 14. Re: NoClassDefFoundError when call EJB 2.1 in AS7
                                    sfcoy

                                    Hmm. I just noticed that it's a java.lang.IllegalAccessError, which means we have some class incompatibilities.

                                     

                                    It may be possible to update org.jboss.proxy.SecurityInterceptor so that it works with the JBoss 7 security APIs.

                                     

                                    (I really have to stop answering forum questions at 1:30 in the morning...)

                                    1 2 Previous Next