5 Replies Latest reply on Aug 20, 2012 11:18 PM by Nguyen Thanh

    Jboss throw ClassNotFoundException: XMLGregorianCalendarImpl

    Nguyen Thanh Newbie

      Hi all,

       

      I developed a ear file with some webService inside.

      This is a part of my DTO:

       

           public XMLGregorianCalendar getStartDate() {
                          if(startDate != null){
                                    startDate.setTimezone(DatatypeConstants.FIELD_UNDEFINED);
                          }
                          return startDate;
                }
      
      
                /**
                 * @param startDate the startDate to set
                 */
                @XmlSchemaType(name = "date")
                public void setStartDate(XMLGregorianCalendar startDate) {
                          this.startDate = startDate;
                }
      
      

       

      I use maven to build my ear file:

       

       

                                    <plugin>
                                              <groupId>org.apache.maven.plugins</groupId>
                                              <artifactId>maven-compiler-plugin</artifactId>
                                              <version>2.3.2</version>
                                              <configuration>
                                                        <source>${jdkVersion}</source>
                                                        <target>${jdkVersion}</target>
                                              </configuration>
                                    </plugin>
      
      
                                    <plugin>
                                              <artifactId>maven-ejb-plugin</artifactId>
                                              <version>2.3</version>
                                              <configuration>
                                                        <ejbVersion>3.1</ejbVersion>
                                              </configuration>
                                    </plugin>
      
      

       

      Then, I deploy ear file to Jboss 7.1.1 and try to invoke to web service. However, jboss alway throw a exception, this is a part of log:

       

      Caused by: java.lang.RuntimeException: ClassNotFoundException marshaling EJB parameters
                at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:229) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.remote.LocalEjbReceiver.clone(LocalEjbReceiver.java:216) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
                at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:188) [jboss-as-ejb3-7.1.1.Final.jar:7.1.1.Final]
      .......
      Caused by: java.lang.ClassNotFoundException: org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl from [Module "my.ear.file.xxx" 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.performLoadClassChecked(ConcurrentClassLoader.java:423)
      
      
      

       

      Does someone know why jboss throw that exception? And how to fix it?

       

      I deployed to Glassfish 3.1 and my web service work correctly.

        • 1. Re: Jboss throw ClassNotFoundException: XMLGregorianCalendarImpl
          Cheng Fang Master

          Do you package any xerces jar in your app?   My guessing is GlassFish doesn't bundle in a xerces.jar whereas jboss does have a ./modules/org/apache/xerces/main/xercesImpl-2.9.1-jbossas-1.jar.  So no conflict when deploying to GlassFish and everything just works.  In JBoss, there could be some library conflict or shadowing between the server and the app.

          • 2. Re: Jboss throw ClassNotFoundException: XMLGregorianCalendarImpl
            jaikiran pai Master

            In AS7 we do allow users to package their own versions of xerces. So that shouldn't be a problem in AS7.

             

            Caused by: java.lang.ClassNotFoundException: org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl from [Module "my.ear.file.xxx" from Service Module Loader]

            So your application has a dependency on the XMLGregorianCalendarImpl. Have you packaged it as a jar within the application? If so, where is it located. Also post a bit more about your packaging details.

            • 3. Re: Jboss throw ClassNotFoundException: XMLGregorianCalendarImpl
              Nguyen Thanh Newbie

              @Cheng Fang: I don't package nay xerces in my ear file. I checked xercesImpl-2.9.1-jbossas-1.jar, Jboss already had XMLGregorianCalendarImpl


                   "In JBoss, there could be some library conflict or shadowing between the server and the app"
              => I think so as well.

               

              @jaikiran pai: Because of some reason, I need XMLGregorianCalendar in DTO part. This is content of my ear file.

               

              my_ear-1.01.18-SNAPSHOT.ear
                   lib
                   -----> commons-collections-3.2.1.jar
                   -----> commons-logging-1.1.1.jar
                   -----> commons-lang-2.4.jar
                   META-INF
                   -----> application.xml
              
                   activation-1.1.jar
                   ejb-api-3.0.jar
                   hibernate-validator-4.0.0.GA.jar
                   jaxb-api-2.1.jar
                   jaxb-impl-2.1.3.jar
                   jsr250-api-1.0.jar
                   slf4j-api-1.5.6.jar
                   stax-api-1.0-2.jar
                   validation-api-1.0.0.GA.jar
                   xml-apis-ext-1.3.04.jar
                   my_service-1.01.18-SNAPSHOT.jar
              

               

              I use hibernate as persistence provider.

              • 4. Re: Jboss throw ClassNotFoundException: XMLGregorianCalendarImpl
                Stephen Coy Master

                Every one of those jars in the root of your ear file, except the ones in the lib directory, slf4j-api.jar and my_service-1.01.18-SNAPSHOT.jar don't need to be there, because they contain classes provided by JBoss or the JDK. The slf4j-api.jar will be more useful in the lib directory too.

                1 of 1 people found this helpful
                • 5. Re: Jboss throw ClassNotFoundException: XMLGregorianCalendarImpl
                  Nguyen Thanh Newbie

                  I fixed by add dependencies in manifest, and it works:

                   

                  <configuration>
                       <displayName>xcrm_ear</displayName>
                       <includeInApplicationXml>true</includeInApplicationXml>
                       <archive>
                            <manifestEntries>
                                 <Dependencies>org.apache.xerces, org.dom4j</Dependencies>
                            </manifestEntries>
                       </archive>
                  </configuration>
                  
                  
                  

                   

                  @Stephen Coy: Thanks for your idea, I will refactor my project.

                   

                  Thank jaikiran pai and Cheng Fang as well