Announcement Announcement Module
Collapse
No announcement yet.
Error deploying Spring Roo project to JBoss 5.1.0.GA Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error deploying Spring Roo project to JBoss 5.1.0.GA

    I am able to deploy my project war to Tomcat without problems. However, when deploying to JBoss 5.1.0.GA, I get the following exception:

    Code:
    11:27:48,444 ERROR [AbstractKernelController] Error installing to Start: name=persistence.unit:unitName=#persistenceUnit state=Create
    java.lang.RuntimeException: Specification violation [EJB3 JPA 6.2.1.2] - You have not defined a non-jta-data-source for a RESOURCE_LOCAL enabled persistence context named: persistenceUnit
    	at org.jboss.jpa.deployment.PersistenceUnitInfoImpl.<init>(PersistenceUnitInfoImpl.java:124)
    	at org.jboss.jpa.deployment.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:275)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    .....
    The contents of my persistence.xml file are as follows:

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    	<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
                <!--value='create' to build a new database on each run; value='update' to modify an existing database; value='create-drop' means the same as 'create' but also drops tables when Hibernate closes; value='validate' makes no changes to the database-->
                <property name="hibernate.hbm2ddl.auto" value="update"/>
                <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
            </properties>
        </persistence-unit>
    </persistence>
    Any ideas?

  • #2
    Lots of problems with JBoss, here is how I got it working

    First, since Roo uses Hibernate 3.5.5 and JPA2, it WILL NOT work with JBoss 5.1.0.

    Here is how I got my Roo project deployed to JBoss 6.0.0.

    1. Create the MySQL data source within JBoss. You can do this following the JBoss documentation for creating data sources.

    2. Place mysql jar in JBOSS_HOME/server/default/lib

    3. Modify the Spring applicationContext.xml and change the dataSource to be a JNDI bean:

    Code:
         <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    		<property name="jndiName" value="java:/MySqlDS" />
    	</bean>
    4. Modify the persistence.xml file and define a non-jta-data-source AND list all of the classnames of the Roo managed Domain objects. If you do not do this then JBoss for some reason will not recognize that these objects are mapped to database tables:

    Code:
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    	<persistence-unit name="persistenceUnit" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <non-jta-data-source>java:/MySqlDS</non-jta-data-source>
            <class>com.my.domain.obj.A</class>
            <class>com.my.domain.obj.B</class>
            ......
            <class>com.my.domain.obj.Z</class>
            <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
                <!--value='create' to build a new database on each run; value='update' to modify an existing database; value='create-drop' means the same as 'create' but also drops tables when Hibernate closes; value='validate' makes no changes to the database-->
                <property name="hibernate.hbm2ddl.auto" value="update"/>
                <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
            </properties>
        </persistence-unit>
    </persistence>
    6. You must modify your pom.xml file and mark every hibernate, jta, and any other jar that is provided by JBoss as "<scope>provided</scope>". Pretty much any jar that containes javax.* classes had to be kept out of the war file. I also had to exclude certain troublemaking jars like geronimo-xxx-spec.

    This was by far the most frustrating part of the process, since you will likely have to go jar by jar until JBoss stops throwing exceptions when you deploy the war.
    Last edited by jporche; Sep 28th, 2010, 02:45 PM.

    Comment

    Working...
    X