Hi David,

we have a little success :-) The database error is gone now. You are right it 
has to be
<property name="hibernate.connection.datasource">java:comp/env/TestDS</property>
in the hibernate.cfg.xml file and
<res-ref-name>TestDS</res-ref-name>
in the ejb-jar.xml.

But now I end up in the next error that the UserTransaction cannot be found:

Caused by: javax.naming.NameNotFoundException: Name "java:/TransactionManager" 
not found.
        at 
org.apache.openejb.core.ivm.naming.IvmContext.federate(IvmContext.java:172)
        at 
org.apache.openejb.core.ivm.naming.IvmContext.lookup(IvmContext.java:129)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at 
org.hibernate.transaction.JNDITransactionManagerLookup.getTransactionManager(JNDITransactionManagerLookup.java:23)

        ... 72 more

I don't know if this error is related to a similar error I had once and 
Jean-Louis helped me out, that you sometime have to call new InitialContext() 
twice [1]. But here, within the hibernate code, I cannot call new 
InitialContext() twice.

Any further hints?

Regards
Marco

[1] 
http://www.nabble.com/InitialContext-does-not-contains-UserTransaction-td22310648.html


-----Ursprüngliche Nachricht-----
Von: David Blevins [mailto:[email protected]]
Gesendet: Donnerstag, 19. März 2009 00:54
An: [email protected]
Betreff: Re: AW: AW: AW: How to use JBPM with openEJB?


On Mar 17, 2009, at 5:11 AM, <[email protected]> 
<[email protected]  > wrote:

> Hi David,
>
> I send you my ejb-jar.xml and hibernate.cfg.xml.
>
> The ejb-jar.xml is based on the ejb-jar.xml from the jbpm-
> enterprise.jar. I only add the messaging-type and changed some JNDI
> names. The hibernate.cfg.xml is also based on default configuration
> from jbpm. I only add the hibernate.connection.datasource property.
> I also add the jbpm.cfg.xml defining the
> JtaDbPersistenceServiceFactory, as mentioned in the documentation.
>
> I hope the files helps to get more light in this problem.

I think I see something.  Looking at this section of the ejb-jar.xml

       <resource-ref>
         <description>
           Logical name of the data source that provides connections to the 
persistence service. Must
           match the hibernate.connection.datasource property in the Hibernate 
configuration file.
         </description>
         <!-- CHANGES <res-ref-name>jdbc/JbpmDataSource</res-ref-name>
-->
         <res-ref-name>TestDS</res-ref-name>
         <res-type>javax.sql.DataSource</res-type>
         <res-auth>Container</res-auth>
       </resource-ref>

Based on that comment, the hibernate.connection.datasource should be configured 
like so:

     <!-- DataSource properties (begin) -->
     <property name="hibernate.connection.datasource">java:comp/env/
TestDS</property>
     <!-- DataSource properties (end) -->

Also, I'm not too sure about this last comment but it seems strange to have the 
"hibernate.connection.driver_class" and other JDBC related properties set in 
addition to using a container supplied datasource.
I'm used to seeing this as a one or the other kind of thing: either you're in a 
managed environment and use a datasource or in a non- managed environment and 
create connections yourself.  I know that when doing the same with OpenJPA it 
will cause problems, not sure if the same applies with Hibernate.

-David


Reply via email to