Mantis Bugtracker
  

Viewing Issue Advanced Details Jump to Notes ] View Simple ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0004491 [Resin] minor always 04-09-11 11:16 04-27-11 17:56
Reporter rickHigh View Status public  
Assigned To ferg
Priority normal Resolution fixed Platform
Status closed   OS
Projection none   OS Version
ETA none Fixed in Version 4.0.18 Product Version
  Product Build
Summary 0004491: Roo app not running in Resin (JPA w/o jta-data-source)
Description Roo is the way to generate "best practice" spring 2.5/3.0 applications.
Roo apps are tested in JBoss and Tomcat and they run out of the bat in those environments.

Roo apps do not seem to run in a Resin environment without changes.

It appears that Resin finds a loads the persistence.xml file (which it does at at com.caucho.env.jpa.PersistenceUnitManager.createDelegate(PersistenceUnitManager.java:396)).

Then Hibernate complains that there is no JDBC connection.

     [java] java.lang.UnsupportedOperationException: The user must supply a JDBC connection
     [java] at org.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:54)
     [java] at org.hibernate.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)
     [java] at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:263)
     [java] at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:219)
     [java] at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:372)
     [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1842)
     [java] at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:902)
     [java] at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:74)
     [java] at com.caucho.env.jpa.PersistenceUnitManager.createDelegate(PersistenceUnitManager.java:396)
     [java] at com.caucho.env.jpa.PersistenceUnitManager.start(PersistenceUnitManager.java:363)
     [java] at com.caucho.env.jpa.PersistenceManager.startPersistenceUnits(PersistenceManager.java:354)
     [java] at com.caucho.env.jpa.PersistenceManager.environmentConfigureEnhancer(PersistenceManager.java:609)
     [java] at com.caucho.loader.EnvironmentClassLoader.config(EnvironmentClassLoader.java:838)
     [java] at com.caucho.loader.EnvironmentClassLoader.bind(EnvironmentClassLoader.java:856)
     [java] at com.caucho.loader.EnvironmentClassLoader.start(EnvironmentClassLoader.java:883)


Roo apps come preconfigured with this for JDBC (in applicationContext.xml):

    <bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
        <property name="driverClassName" value="${database.driverClassName}"/>
        <property name="url" value="${database.url}"/>
        <property name="username" value="${database.username}"/>
        <property name="password" value="${database.password}"/>
    </bean>

I know there are workarounds. We should document the workaround on the Resin wiki and on the Roo forum. This way folks that want to use Roo with Spring 3 can.

Also in the future Resin may want to check to see if jta-data-source is set in the persistence.xml.

        <jta-data-source>jdbc/basic</jta-data-source>


If jta-data-source is not set, then it might be a good idea if Resin does not process the persistence.xml and assume Spring or something else is going to deal with it directly.

I think many (if not most) Spring applications use BasicDataSource and not JNDI.

Resin might not work with a lot of JPA applications for this reason.
Steps To Reproduce
Additional Information
Attached Files

- Relationships

- Notes
(0005185)
rickHigh
04-09-11 11:46

Work around:

Run this command from the roo console:

roo> persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY --jndiDataSource jdbc/basic

Then add jta-data-source to your persistence.xml file.

Adding <jta-data-source>jdbc/basic</jta-data-source> to persistence.xml:


<?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>
        <jta-data-source>jdbc/basic</jta-data-source>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
            <!-- 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="create"/>
            <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/>
            <property name="hibernate.connection.charSet" value="UTF-8"/>
            <!-- Uncomment the following two properties for JBoss only -->
            <!-- property name="hibernate.validator.apply_to_ddl" value="false" /-->
            <!-- property name="hibernate.validator.autoregister_listeners" value="false" /-->
        </properties>
    </persistence-unit>
</persistence>


Lastly add this resin-web.xml file to your WEB-INF directory:

<web-app xmlns="http://caucho.com/ns/resin"> [^]


<database jndi-name='jdbc/basic'>
  <driver type="org.hsqldb.jdbcDriver">
    <url>jdbc:hsqldb:~/hypersonic/localDB</url>
    <user>sa</user>
    <password></password>
  </driver>
</database>
</web-app>

This will get you past this issue. If you are using the maven plugin (under development). Just run:

 mvn org.cdisource.maven.resin:cdisource-resin-maven-plugin:run-war -Dresin.runMode=gui -Dresin.spawn=false -DskipTests=true
 
(0005221)
ferg
04-27-11 17:56

env/0e22
 

- Issue History
Date Modified Username Field Change
04-09-11 11:16 rickHigh New Issue
04-09-11 11:46 rickHigh Note Added: 0005185
04-27-11 09:45 ferg Summary Roo app not running in Resin => Roo app not running in Resin (JPA w/o jta-data-source)
04-27-11 17:56 ferg Note Added: 0005221
04-27-11 17:56 ferg Assigned To  => ferg
04-27-11 17:56 ferg Status new => closed
04-27-11 17:56 ferg Resolution open => fixed
04-27-11 17:56 ferg Fixed in Version  => 4.0.18


Mantis 1.0.0rc3[^]
Copyright © 2000 - 2005 Mantis Group
31 total queries executed.
27 unique queries executed.
Powered by Mantis Bugtracker