4 Replies Latest reply on Dec 12, 2011 9:58 AM by Scott Marlow

    ClassNotFoundException: PersistentBag on AS 7.1.0 BetaB

    Jim Barrows Newbie

      I'm deploying a fairly simple ear with an ejb jar, war and JPA jar.  If I understand the AS7 documentation right, I don't deploy hibernate with my ear.  It's already there, and AS7 should just use hibernate to implement the JPA.

      The problem is that I get this error message (stack trace at bottom): java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters

      which is caused by: java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters

      and finally: java.lang.ClassNotFoundException: org.hibernate.collection.internal.PersistentBag from [Module "deployment.MBMS-EAR.ear.party-services-1.0-SNAPSHOT.jar:main" from Service Module Loader]

      And this is the code:

      Person party = new Person();

                                    party.setFirstName(firstName);

                                    party.setMiddleName(middleName);

                                    party.setLastName(lastName);

                                    partyCrud.create(party );

      The data is getting saved into the database.  This appears to be happening after that. 

       

      I've also tried putting the hibernate jar's in with the ear, and that did not help either.

       

      I'm not sure what I'm doing wrong and would appreciate any help!

       

      Thanks

       

      Here's the stack trace:

      12:27:06,009 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-4) #{personController.save}: java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters: javax.faces.FacesException: #{personController.save}: java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters

                at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118) [jsf-impl-2.1.3-b02-jbossorg-2.jar:]

                at javax.faces.component.UICommand.broadcast(UICommand.java:315) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]

                at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]

                at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]

                at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81) [jsf-impl-2.1.3-b02-jbossorg-2.jar:]

                at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3-b02-jbossorg-2.jar:]

                at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.3-b02-jbossorg-2.jar:]

                at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]

                at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.3.Final.jar:]

                at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.3.Final.jar:]

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

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

                at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.1.0.Beta1b.jar:]

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

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

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

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

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

                at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.3.Final.jar:]

                at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.3.Final.jar:]

                at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.3.Final.jar:]

                at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]

      Caused by: javax.faces.el.EvaluationException: java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters

                at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]

                at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102) [jsf-impl-2.1.3-b02-jbossorg-2.jar:]

                ... 21 more

      Caused by: java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters

                at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:201)

                at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:188)

                at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:175)

                at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:185) [jboss-ejb-client-1.0.0.Beta7.jar:]

                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:113) [jboss-ejb-client-1.0.0.Beta7.jar:]

                at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:96) [jboss-ejb-client-1.0.0.Beta7.jar:]

                at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:86) [jboss-ejb-client-1.0.0.Beta7.jar:]

                at $Proxy63.create(Unknown Source)          at mbms.party.PersonController.save(PersonController.java:38) [classes:]

                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_26]

                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_26]

                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_26]

                at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_26]

                at org.apache.el.parser.AstValue.invoke(AstValue.java:196) [jbossweb-7.0.3.Final.jar:]

                at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276) [jbossweb-7.0.3.Final.jar:]

                at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105) [jsf-impl-2.1.3-b02-jbossorg-2.jar:]

                at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:]

                ... 22 more

      Caused by: java.lang.ClassNotFoundException: org.hibernate.collection.internal.PersistentBag from [Module "deployment.MBMS-EAR.ear.party-services-1.0-SNAPSHOT.jar:main" from Service Module Loader]

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

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

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

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

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

                at java.lang.Class.forName0(Native Method) [:1.6.0_26]

                at java.lang.Class.forName(Class.java:247) [:1.6.0_26]

                at org.jboss.marshalling.cloner.ClassLoaderClassCloner.clone(ClassLoaderClassCloner.java:46)

                at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:158)

                at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135)

                at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:187)

                at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135)

                at org.jboss.marshalling.cloner.SerializingCloner.cloneFields(SerializingCloner.java:346)

                at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:307)

                at org.jboss.marshalling.cloner.SerializingCloner.initSerializableClone(SerializingCloner.java:284)

                at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:252)

                at org.jboss.marshalling.cloner.SerializingCloner.clone(SerializingCloner.java:135)

                at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:197)

                ... 38 more

        • 1. Re: ClassNotFoundException: PersistentBag on AS 7.1.0 BetaB
          Scott Marlow Master

          Can you describe more details about your deployment?  Where is the persistence.xml and name/location/purpose of each contained archive.  Just a quick description would be great.

           

          I am thinking of some enhancements to better deal with cases like this but not sure when I will get to it.  This sounds a little different but not that much from http://community.jboss.org/message/640695 (a simliar workaround will probably help you).  The enhancement might be as simple as adding the persistence provider module classloader, to each sub-deployment in the application. 

          • 2. Re: ClassNotFoundException: PersistentBag on AS 7.1.0 BetaB
            Jim Barrows Newbie

            I'm trying the suggestions in the discussion you referenced.  Thanks for the link!

            Here's how I have thigns packaged out;

             

            Top level of EAR:

            • lib 
            • META-INF 
            • party-services-1.0-SNAPSHOT.jar  -- 2 EJB's.  One of which contains the code below
            • party-ui-web-1.0-SNAPSHOT.war -- JSF 2 application that calls the EJB

             

            Lib directory:

            • commons-collections-3.2.1.jar 
            • party-model-1.0-SNAPSHOT.jar   -JPA Jar.  persistence.xml lives here
            • commons-lang-2.3.jar          
            • slf4j-api-1.5.10.jar
            • javasasist-3.12.0.GA.jar       
            • slf4j-log4j12-1.5.10.jar
            • joda-time-1.6.jar             
            • usertype.jodatime-1.9.jar
            • log4j-1.2.16.jar              
            • usertype.spi-1.9.jar
            • model-utils-1.0-SNAPSHOT.jar - I extracted the ID and Version fields to a common class for everything that is persistable.

             

            Code in EJB:

            public Party create(Party party) throws ValidationException{

             

             

                                validator = factory.getValidator();

                                Set<ConstraintViolation<Party>> violations = validator.validate(party);

                                if (violations.isEmpty()) {

                                          em.persist(party);

                                } else {

                                          throw new ValidationException();

                                }

             

             

                                return party;

                      }

            • 3. Re: ClassNotFoundException: PersistentBag on AS 7.1.0 BetaB
              Jim Barrows Newbie

              I've tried placing the org.hibernate in the manifest classpath in the EAR, WAR and jpa JAR file.  All three failed.

              I'm really confused.  Obviously I'm not the first person to try JPA in an EAR. 

              • 4. Re: ClassNotFoundException: PersistentBag on AS 7.1.0 BetaB
                Scott Marlow Master

                If you haven't already, could you try adding the Dependencies: org.hibernate in the ejb jar party-services-1.0-SNAPSHOT.jar MANIFEST.MF.