You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by petko <ww...@gmail.com> on 2009/02/20 13:19:58 UTC
OpenEJB+Tomcat+Oracle+Toplink
Hello ,
In my project i am using OpenEJB with Tomcat and Oracle 10g with Toplink as
provider
I have problems configuring the persistence units and/or datasources. I am
not quite sure what the problem is.
The structure of ejb jar folder is:
-projectjar.jar
--com
--META-INF,
where in META-INF folder i have only two xml files
-- ejb-jar.xml
-- persistence.xml
Because i have two database, i have two persistence-unit with different
names PUM and PUL
Content of persistence.xml is:
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="PUM" transaction-type="JTA">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<jta-data-source>DBFirst</jta-data-source>
<non-jta-data-source>DBFirstUnmanaged</non-jta-data-source>
<class>com.Client</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="toplink.logging.level" value="WARNING" />
<property name="toplink.logging.level.sql" value="FINEST" />
<property name="toplink.logging.level.ejb" value="FINEST" />
<property name="Context.INITIAL_CONTEXT_FACTORY"
value="org.apache.openejb.client.LocalInitialContextFactory" />
</properties>
</persistence-unit>
<persistence-unit name="PUL" transaction-type="JTA">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<jta-data-source>DBSec</jta-data-source>
<non-jta-data-source>DBSecUnmanaged</non-jta-data-source>
<class>com.Tasks</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="toplink.logging.level" value="WARNING" />
<property name="toplink.logging.level.sql" value="FINEST" />
<property name="toplink.logging.level.ejb" value="FINEST" />
<property name="Context.INITIAL_CONTEXT_FACTORY"
value="org.apache.openejb.client.LocalInitialContextFactory" />
</properties>
</persistence-unit>
Content of ejb-jar is:
<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
metadata-complete="true" version="3.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<enterprise-beans>
<session>
<display-name>ClientFacade</display-name>
<ejb-name>ClientFacade</ejb-name>
<business-remote>com.ClientFacadeRemote</business-remote>
<ejb-class>com.ClientFacade</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<persistence-context-ref>
<persistence-context-ref-name>com.ClientFacade/em</persistence-context-ref-name>
<persistence-unit-name>PUM</persistence-unit-name>
<persistence-context-type>Transaction</persistence-context-type>
<injection-target>
<injection-target-class>com.ClientFacade</injection-target-class>
<injection-target-name>em</injection-target-name>
</injection-target>
</persistence-context-ref>
<security-identity>
<use-caller-identity />
</security-identity>
</session>
<session>
<display-name>TasksFacade</display-name>
<ejb-name>TasksFacade</ejb-name>
<business-remote>com.tasks.TasksFacadeRemote</business-remote>
<ejb-class>com.tasks.TasksFacade</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<persistence-context-ref>
<persistence-context-ref-name>com.tasks.TasksFacade/em</persistence-context-ref-name>
<persistence-unit-name>PUL</persistence-unit-name>
<persistence-context-type>Transaction</persistence-context-type>
<injection-target>
<injection-target-class>com.tasks.TasksFacade</injection-target-class>
<injection-target-name>em</injection-target-name>
</injection-target>
</persistence-context-ref>
<security-identity>
<use-caller-identity />
</security-identity>
</session>
</enterprise-beans>
</ejb-jar>
In openejb.xml i put
<Resource id="DBM" type="DataSource">
JdbcDriver oracle.jdbc.OracleDriver
JdbcUrl jdbc:oracle:thin:@server:1521:db
UserName user
Password user
</Resource>
<Resource id="DBL" type="DataSource">
JdbcDriver oracle.jdbc.OracleDriver
JdbcUrl jdbc:oracle:thin:@server:1521:db
UserName user2
Password user2
</Resource>
Oracle driver i put in lib folder on tomcat.
Аctually, we migrate from Glassfish to Tomcat. On Glassfish everything works
fine.
I hope that someone can help me out with this.
Thanks in advance.
--
View this message in context: http://www.nabble.com/OpenEJB%2BTomcat%2BOracle%2BToplink-tp22119600p22119600.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB+Tomcat+Oracle+Toplink
Posted by petko <ww...@gmail.com>.
Ok. I make a mistake when i write this post. The datebase name is ok.
I try witout this line
<property name="Context.INITIAL_CONTEXT_FACTORY"
value="org.apache.openejb.client.LocalInitialContextFactory" />
and everything is the same.
openejb.log output:
2009-02-22 17:39:59,171 - INFO - Found ejb module EjbModule in war /Project
2009-02-22 17:40:00,875 - INFO - Configuring enterprise application:
C:\Program Files\apache-tomcat-6.0.18\temp\0-Project
2009-02-22 17:40:01,156 - INFO - Configuring PersistenceUnit(name=PUM,
provider=oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider)
2009-02-22 17:40:01,156 - INFO - Configuring PersistenceUnit(name=PUL,
provider=oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider)
2009-02-22 17:40:01,156 - INFO - Enterprise application "C:\Program
Files\apache-tomcat-6.0.18\temp\0-Project" loaded.
2009-02-22 17:40:01,156 - INFO - Assembling app: C:\Program
Files\apache-tomcat-6.0.18\temp\0-Project
2009-02-22 17:40:01,218 - INFO - PersistenceUnit(name=PUM,
provider=oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider)
2009-02-22 17:40:01,875 - INFO - PersistenceUnit(name=PUL,
provider=oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider)
2009-02-22 17:40:01,984 - INFO - Jndi(name=ClientFacadeRemote) -->
Ejb(deployment-id=ClientFacade)
2009-02-22 17:40:01,984 - INFO - Jndi(name=TasksFacadeRemote) -->
Ejb(deployment-id=TasksFacade)
2009-02-22 17:40:01,984 - INFO - Created Ejb(deployment-id=TasksFacade,
ejb-name=TasksFacade, container=My Stateless Container)
2009-02-22 17:40:01,984 - INFO - Created Ejb(deployment-id=ClientFacade,
ejb-name=ClientFacade, container=My Stateless Container)
2009-02-22 17:40:01,984 - INFO - Deployed Application(path=C:\Program
Files\apache-tomcat-6.0.18\temp\0-Project)
Should I make a correcetion on My Stateless Container?
Thanks,
David Blevins wrote:
>
> The datasource names in your persistence.xml (DBFirst, DBSec) do not
> match the names of the datasources you configured in your openejb.xml
> (DBM, DBL).
>
> I'm suspicious of this line in the persistence.xml:
>
> <property name="Context.INITIAL_CONTEXT_FACTORY"
> value="org.apache.openejb.client.LocalInitialContextFactory" />
>
> I don't think any good can come to that as the only thing you can
> lookup from the LocalInitialContextFactory is EJB references. I
> suspect that might be there for the transaction manager lookup. We do
> ship with an implementation the Toplink JTATransactionController
> interface and will set it if we see you are using Toplink as your
> persistence provider, so all should work without any OpenEJB-specific
> flags in your persistence properties.
>
> If you still see the issue, post the openejb.log output. That should
> help us see how everything is being built.
>
> -David
>
> On Feb 20, 2009, at 4:19 AM, petko wrote:
>
>>
>> Hello ,
>>
>> In my project i am using OpenEJB with Tomcat and Oracle 10g with
>> Toplink as
>> provider
>> I have problems configuring the persistence units and/or
>> datasources. I am
>> not quite sure what the problem is.
>> The structure of ejb jar folder is:
>> -projectjar.jar
>> --com
>> --META-INF,
>> where in META-INF folder i have only two xml files
>> -- ejb-jar.xml
>> -- persistence.xml
>> Because i have two database, i have two persistence-unit with
>> different
>> names PUM and PUL
>> Content of persistence.xml is:
>> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence
>> "
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
>> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
>> <persistence-unit name="PUM" transaction-type="JTA">
>>
>> <
>> provider
>> >oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</
>> provider>
>> <jta-data-source>DBFirst</jta-data-source>
>> <non-jta-data-source>DBFirstUnmanaged</non-jta-data-source>
>> <class>com.Client</class>
>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>> <properties>
>> <property name="toplink.logging.level" value="WARNING" />
>> <property name="toplink.logging.level.sql" value="FINEST" />
>> <property name="toplink.logging.level.ejb" value="FINEST" />
>> <property name="Context.INITIAL_CONTEXT_FACTORY"
>> value="org.apache.openejb.client.LocalInitialContextFactory" />
>> </properties>
>> </persistence-unit>
>> <persistence-unit name="PUL" transaction-type="JTA">
>>
>> <
>> provider
>> >oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</
>> provider>
>> <jta-data-source>DBSec</jta-data-source>
>> <non-jta-data-source>DBSecUnmanaged</non-jta-data-source>
>> <class>com.Tasks</class>
>> <exclude-unlisted-classes>true</exclude-unlisted-classes>
>> <properties>
>> <property name="toplink.logging.level" value="WARNING" />
>> <property name="toplink.logging.level.sql" value="FINEST" />
>> <property name="toplink.logging.level.ejb" value="FINEST" />
>> <property name="Context.INITIAL_CONTEXT_FACTORY"
>> value="org.apache.openejb.client.LocalInitialContextFactory" />
>> </properties>
>> </persistence-unit>
>> Content of ejb-jar is:
>> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> metadata-complete="true" version="3.0"
>> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
>> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
>> <enterprise-beans>
>> <session>
>> <display-name>ClientFacade</display-name>
>> <ejb-name>ClientFacade</ejb-name>
>> <business-remote>com.ClientFacadeRemote</business-remote>
>> <ejb-class>com.ClientFacade</ejb-class>
>> <session-type>Stateless</session-type>
>> <transaction-type>Container</transaction-type>
>> <persistence-context-ref>
>>
>> <persistence-context-ref-name>com.ClientFacade/em</persistence-
>> context-ref-name>
>> <persistence-unit-name>PUM</persistence-unit-name>
>> <persistence-context-type>Transaction</persistence-context-type>
>> <injection-target>
>> <injection-target-class>com.ClientFacade</injection-target-class>
>> <injection-target-name>em</injection-target-name>
>> </injection-target>
>> </persistence-context-ref>
>> <security-identity>
>> <use-caller-identity />
>> </security-identity>
>> </session>
>> <session>
>> <display-name>TasksFacade</display-name>
>> <ejb-name>TasksFacade</ejb-name>
>> <business-remote>com.tasks.TasksFacadeRemote</business-remote>
>> <ejb-class>com.tasks.TasksFacade</ejb-class>
>> <session-type>Stateless</session-type>
>> <transaction-type>Container</transaction-type>
>> <persistence-context-ref>
>>
>> <persistence-context-ref-name>com.tasks.TasksFacade/em</persistence-
>> context-ref-name>
>> <persistence-unit-name>PUL</persistence-unit-name>
>> <persistence-context-type>Transaction</persistence-context-type>
>> <injection-target>
>> <injection-target-class>com.tasks.TasksFacade</injection-target-
>> class>
>> <injection-target-name>em</injection-target-name>
>> </injection-target>
>> </persistence-context-ref>
>> <security-identity>
>> <use-caller-identity />
>> </security-identity>
>> </session>
>> </enterprise-beans>
>> </ejb-jar>
>>
>> In openejb.xml i put
>> <Resource id="DBM" type="DataSource">
>> JdbcDriver oracle.jdbc.OracleDriver
>> JdbcUrl jdbc:oracle:thin:@server:1521:db
>> UserName user
>> Password user
>> </Resource>
>> <Resource id="DBL" type="DataSource">
>> JdbcDriver oracle.jdbc.OracleDriver
>> JdbcUrl jdbc:oracle:thin:@server:1521:db
>> UserName user2
>> Password user2
>> </Resource>
>>
>> Oracle driver i put in lib folder on tomcat.
>> Аctually, we migrate from Glassfish to Tomcat. On Glassfish
>> everything works
>> fine.
>>
>> I hope that someone can help me out with this.
>> Thanks in advance.
>> --
>> View this message in context:
>> http://www.nabble.com/OpenEJB%2BTomcat%2BOracle%2BToplink-tp22119600p22119600.html
>> Sent from the OpenEJB User mailing list archive at Nabble.com.
>>
>>
>
>
>
--
View this message in context: http://www.nabble.com/OpenEJB%2BTomcat%2BOracle%2BToplink-tp22119600p22149563.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: OpenEJB+Tomcat+Oracle+Toplink
Posted by David Blevins <da...@visi.com>.
The datasource names in your persistence.xml (DBFirst, DBSec) do not
match the names of the datasources you configured in your openejb.xml
(DBM, DBL).
I'm suspicious of this line in the persistence.xml:
<property name="Context.INITIAL_CONTEXT_FACTORY"
value="org.apache.openejb.client.LocalInitialContextFactory" />
I don't think any good can come to that as the only thing you can
lookup from the LocalInitialContextFactory is EJB references. I
suspect that might be there for the transaction manager lookup. We do
ship with an implementation the Toplink JTATransactionController
interface and will set it if we see you are using Toplink as your
persistence provider, so all should work without any OpenEJB-specific
flags in your persistence properties.
If you still see the issue, post the openejb.log output. That should
help us see how everything is being built.
-David
On Feb 20, 2009, at 4:19 AM, petko wrote:
>
> Hello ,
>
> In my project i am using OpenEJB with Tomcat and Oracle 10g with
> Toplink as
> provider
> I have problems configuring the persistence units and/or
> datasources. I am
> not quite sure what the problem is.
> The structure of ejb jar folder is:
> -projectjar.jar
> --com
> --META-INF,
> where in META-INF folder i have only two xml files
> -- ejb-jar.xml
> -- persistence.xml
> Because i have two database, i have two persistence-unit with
> different
> names PUM and PUL
> Content of persistence.xml is:
> <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence
> "
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
> http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
> <persistence-unit name="PUM" transaction-type="JTA">
>
> <
> provider
> >oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</
> provider>
> <jta-data-source>DBFirst</jta-data-source>
> <non-jta-data-source>DBFirstUnmanaged</non-jta-data-source>
> <class>com.Client</class>
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
> <properties>
> <property name="toplink.logging.level" value="WARNING" />
> <property name="toplink.logging.level.sql" value="FINEST" />
> <property name="toplink.logging.level.ejb" value="FINEST" />
> <property name="Context.INITIAL_CONTEXT_FACTORY"
> value="org.apache.openejb.client.LocalInitialContextFactory" />
> </properties>
> </persistence-unit>
> <persistence-unit name="PUL" transaction-type="JTA">
>
> <
> provider
> >oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</
> provider>
> <jta-data-source>DBSec</jta-data-source>
> <non-jta-data-source>DBSecUnmanaged</non-jta-data-source>
> <class>com.Tasks</class>
> <exclude-unlisted-classes>true</exclude-unlisted-classes>
> <properties>
> <property name="toplink.logging.level" value="WARNING" />
> <property name="toplink.logging.level.sql" value="FINEST" />
> <property name="toplink.logging.level.ejb" value="FINEST" />
> <property name="Context.INITIAL_CONTEXT_FACTORY"
> value="org.apache.openejb.client.LocalInitialContextFactory" />
> </properties>
> </persistence-unit>
> Content of ejb-jar is:
> <ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> metadata-complete="true" version="3.0"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
> http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
> <enterprise-beans>
> <session>
> <display-name>ClientFacade</display-name>
> <ejb-name>ClientFacade</ejb-name>
> <business-remote>com.ClientFacadeRemote</business-remote>
> <ejb-class>com.ClientFacade</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Container</transaction-type>
> <persistence-context-ref>
>
> <persistence-context-ref-name>com.ClientFacade/em</persistence-
> context-ref-name>
> <persistence-unit-name>PUM</persistence-unit-name>
> <persistence-context-type>Transaction</persistence-context-type>
> <injection-target>
> <injection-target-class>com.ClientFacade</injection-target-class>
> <injection-target-name>em</injection-target-name>
> </injection-target>
> </persistence-context-ref>
> <security-identity>
> <use-caller-identity />
> </security-identity>
> </session>
> <session>
> <display-name>TasksFacade</display-name>
> <ejb-name>TasksFacade</ejb-name>
> <business-remote>com.tasks.TasksFacadeRemote</business-remote>
> <ejb-class>com.tasks.TasksFacade</ejb-class>
> <session-type>Stateless</session-type>
> <transaction-type>Container</transaction-type>
> <persistence-context-ref>
>
> <persistence-context-ref-name>com.tasks.TasksFacade/em</persistence-
> context-ref-name>
> <persistence-unit-name>PUL</persistence-unit-name>
> <persistence-context-type>Transaction</persistence-context-type>
> <injection-target>
> <injection-target-class>com.tasks.TasksFacade</injection-target-
> class>
> <injection-target-name>em</injection-target-name>
> </injection-target>
> </persistence-context-ref>
> <security-identity>
> <use-caller-identity />
> </security-identity>
> </session>
> </enterprise-beans>
> </ejb-jar>
>
> In openejb.xml i put
> <Resource id="DBM" type="DataSource">
> JdbcDriver oracle.jdbc.OracleDriver
> JdbcUrl jdbc:oracle:thin:@server:1521:db
> UserName user
> Password user
> </Resource>
> <Resource id="DBL" type="DataSource">
> JdbcDriver oracle.jdbc.OracleDriver
> JdbcUrl jdbc:oracle:thin:@server:1521:db
> UserName user2
> Password user2
> </Resource>
>
> Oracle driver i put in lib folder on tomcat.
> Аctually, we migrate from Glassfish to Tomcat. On Glassfish
> everything works
> fine.
>
> I hope that someone can help me out with this.
> Thanks in advance.
> --
> View this message in context: http://www.nabble.com/OpenEJB%2BTomcat%2BOracle%2BToplink-tp22119600p22119600.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>