Announcement Announcement Module
Collapse
No announcement yet.
Roo 1.2.RELEASE multimodule doesn't include JAXB-API in the "core" (HIBERNATE/DB2) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Roo 1.2.RELEASE multimodule doesn't include JAXB-API in the "core" (HIBERNATE/DB2)

    Hello,

    I've created a maven multi-module project with 3 modules: extra (some extra stuff), core (main logic), web (web application):

    Code:
    // Spring Roo 1.2.0.RELEASE [rev 39eb957] log opened at 2012-01-09 12:28:35
    project --topLevelPackage com.malsolo.multi --projectName multi-parent --java 5 --packaging POM
    module create --moduleName multi-core --topLevelPackage ~.core --java 5 --packaging JAR
    module focus --moduleName ~
    module create --moduleName multi-web --topLevelPackage ~.web --java 5 --packaging WAR
    module focus --moduleName ~
    module create --moduleName multi-extra --topLevelPackage ~.extra --java 5 --packaging JAR
    Then I've tried with a JPA Entity in DB2 using Hibernate (some context here):

    Code:
    module focus --moduleName multi-core
    jpa setup --provider HIBERNATE --database Etc...
    entity jpa --class ~.domain.MyEntity --table ...
    field string --fieldName name --column ...
    module focus --moduleName ~
    perform eclipse
    //Adjust the project as DB2/OS390 requires
    // Spring Roo 1.2.0.RELEASE [rev 39eb957] log opened at 2012-01-09 a few minutes later
    perform tests
    But it didn't work because...

    Code:
    Tests run: 9, Failures: 0, Errors: 9, Skipped: 0, Time elapsed: 2.55 sec <<< FAILURE!
    testMarkerMethod(es.redsys.cerbero.core.domain.EntidadIntegrationTest)  Time elapsed: 1.47 sec  <<< ERROR!
    java.lang.IllegalStateException: Failed to load ApplicationContext
    	at org.springframework.test.context.TestContext.getApplicationContext(TestContext.java:157)
    ...
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager' defined in file [C:\...\target\classes\META-INF\spring\applicationContext.xml]: Cannot resolve reference to bean 'entityManagerFactory' while setting bean property 'entityManagerFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [C:\...\target\classes\META-INF\spring\applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    ...
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in file [C:\...\target\classes\META-INF\spring\applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
    ...
    Caused by: org.hibernate.HibernateException: Unable to get the default Bean Validation factory
    	at org.hibernate.cfg.beanvalidation.BeanValidationActivator.applyDDL(BeanValidationActivator.java:127)
    ...
    Caused by: java.lang.reflect.InvocationTargetException
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    ...
    Caused by: java.lang.NoClassDefFoundError: javax.xml.bind.JAXBContext
    	at java.lang.J9VMInternals.verifyImpl(Native Method)
    ...
    Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBContext
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:496)
    	... 80 more
    The reason is that the core project doesn't have the JAXB-API dependency in the pom:

    Code:
            <!-- Manually added -->
            <dependency>
            	<groupId>javax.xml.bind</groupId>
            	<artifactId>jaxb-api</artifactId>
            	<version>2.1</version>
            </dependency>
    Nevertheless, it's excluded in the HIBERNATE validator dependecy:

    Code:
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-validator</artifactId>
                <version>4.2.0.Final</version>
                <exclusions>
                    <exclusion>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-impl</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
    Previous versions of Roo did include this dependency, so I copy the appropriate lines from an old pom and the problem is solved:

    Code:
    ...
        <dependency>
                <groupId>javax.annotation</groupId>
                <artifactId>jsr250-api</artifactId>
                <version>1.0</version>
            </dependency>
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.1</version>
            </dependency>
    ...
    Is it a bug or is there a reason for not including this dependency?

    I could rise a JIRA ticket if you need so.

    Thank you very much.

  • #2
    SOLVED:

    The problem is that I'm using Java 5 (IBM for WAS 6.1). With Java 6 is not a problem.

    The solution still applies: manually add the missing dependency.

    Greetings.

    Comment

    Working...
    X