Announcement Announcement Module
Collapse
No announcement yet.
problem in petclinic: NoClassDefFoundError: javax/xml/bind/JAXBException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem in petclinic: NoClassDefFoundError: javax/xml/bind/JAXBException

    Note: Just now discovered Ben had already answered a similar post. Ben's answer is shown immediately below, followed by my original post. Of course after learning of this I will switch to java 6 for the time being. It might be helpful until ROO goes GA for the readme.txt to have a section in it where this category of unusual situation is communicated explicitly to developers.

    Code:
    This is a bug in Hibernate Validator when used on Java 5 machines. This is not due to a bug in Roo. Information on the bug can be found in the following issue:
    
    http://jira.springframework.org/browse/ROO-224

    I get a "Sorry, we encountered an internal error." message when I try to create a new Pet Category, when I follow the instructions for running petclinic contained in the "readme.txt" of roo-1.0.0.RC2 as shown below:

    Code:
     # mkdir petclinic
    # cd petclinic
    # roo
    
    roo> script clinic.roo
    roo> exit
    
    # mvn eclipse:eclipse
    # mvn test
    # mvn package
    
    # mvn tomcat:run
    http://localhost:8080/petclinic
    PetClinic looks fine when I view it in FireFox and the "List" options work okay (but of course there is no data to list yet). I get the error when I try to create anything, for example a new Pet type:
    Code:
     SEVERE: Servlet.service() for servlet petclinic threw exception
    java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
    	at org.hibernate.validation.engine.ConfigurationImpl.parseValidationXml(ConfigurationImpl.java:187)
    	at org.hibernate.validation.engine.ConfigurationImpl.buildValidatorFactory(ConfigurationImpl.java:116)
    	at javax.validation.Validation.buildDefaultValidatorFactory(Validation.java:109)
    	at com.springsource.petclinic.web.PetTypeController_Roo_Controller.ajc$interMethod$com_springsource_petclinic_web_PetTypeController_Roo_Controller$com_springsource_petclinic_web_PetTypeController$create(PetTypeController_Roo_Controller.aj:21)
    	at com.springsource.petclinic.web.PetTypeController.create(PetTypeController.java:1)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    Below shows info on my maven and java versions:
    Code:
    rdg1@ubuntu:~/rooPlayPen/test5$ mvn -version
    Apache Maven 2.2.0 (r788681; 2009-06-26 06:04:01-0700)
    Java version: 1.5.0_19
    Java home: /usr/lib/jvm/java-1.5.0-sun-1.5.0.19/jre
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux" version: "2.6.28-13-generic" arch: "i386" Family: "unix"
    One unusual thing I noticed was an error message during the maven test:

    Code:
    [INFO] Building petclinic
    [INFO]    task-segment: [test]
    [INFO] ------------------------------------------------------------------------
    [INFO] [aspectj:compile {execution: default}]
    [INFO] [resources:resources {execution: default-resources}]
    [INFO] Using default encoding to copy filtered resources.
    [INFO] [compiler:compile {execution: default-compile}]
    [INFO] Nothing to compile - all classes are up to date
    [INFO] [aspectj:test-compile {execution: default}]
    [WARNING] advice defined in com.springsource.petclinic.domain.Jpa_Exception_Translator has not been applied [Xlint:adviceDidNotMatch]
    [INFO] [resources:testResources {execution: default-testResources}]
    [INFO] Using default encoding to copy filtered resources.
    I attached a zip file containing the logs of everything I did.

    Thanks for any help.
    Last edited by RobertGloverJr; Oct 24th, 2009, 05:16 PM.

  • #2
    temp fix for java 5 JAXB problem

    I signed up for a Hibernate JIRA account and in that way obtained the change being made to the 3.5 Hibernate pom.xml to fix the JAXB problem that occurs in java 5 but not in java 6.
    I inserted that code into the pom.xml that ROO created when I ran the clinic.roo script and then issued "mvn clean package" followed by "mvn tomcat:run".
    With that change to the pom, the ROO PetClinic runs perfectly on java 5.
    Maybe this profile could be added to the upcoming pom's generated by the upcoming ROO RC3?

    The first code snipped below shows the code lifted from the Hibernate 3.5 POM. ("HIBERNATE:/core/trunk/annotations/pom.xml")

    Code:
    <profiles>
           <profile>
     <id>jaxb</id>
           <activation>
                <jdk>1.5</jdk>
            </activation>
            <dependencies>
                   <dependency>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>2.1</version>
                    </dependency>
                   <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-impl</artifactId>
                        <version>2.1.3</version>
                    </dependency>
             </dependencies>
      </profile>
    </profiles>

    Below I show the exact place within the pom.xml generated by ROO where I inserted the "profiles" section that I lifted from the pom.xml of Hibernate 3.5.

    Code:
    </configuration>
    </plugin>
    </plugins>
    	</build>
    
    <profiles>
           <profile>
     <id>jaxb</id>
           <activation>
                <jdk>1.5</jdk>
            </activation>
            <dependencies>
                   <dependency>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>2.1</version>
                    </dependency>
                   <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-impl</artifactId>
                        <version>2.1.3</version>
                    </dependency>
             </dependencies>
      </profile>
    </profiles>
    
    	<properties>
    		<spring.version>3.0.0.RC1</spring.version>
    		<aspectj.version>1.6.5.RELEASE</aspectj.version>
    	</properties>

    Comment


    • #3
      I had the same problem with the wedding.roo sample and RobertGloverJr's solution worked. I use:
      $ java -version
      java version "1.5.0_12"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
      BEA JRockit(R) (build R27.4.0-90-89592-1.5.0_12-20070928-1715-windows-ia32, compiled mode)

      You probably don't want to add it to the generated code as it can cause problems elsewhere. Perhaps Roo shouldn't use a buggy version of hibernate.

      Comment


      • #4
        This is due to Hibernate Validator bug https://jira.springsource.org/browse/ROO-224. This issue report contains a description of workarounds and the reason we are supporting this particular version of Hibernate.

        Comment

        Working...
        X