Hi David,

I use the same settings for managed and unmanaged datasource because I got
an error or a warning (can't remember) if I don't put both inside the
persistence.xml.

I have 2 Persistence Unit and 2 DataSource (4 DS because I declare XxDS and
XxDSUn), one datasource refers to a schema with read/write and TX. The other
points to another schema which is used for read only queries, sometimes they
are in 2 different DB.



<persistence-unit name="MyOrclEM" transaction-type="JTA">

            <provider>org.hibernate.ejb.HibernatePersistence</provider>

            <jta-data-source>MyOrclDS</jta-data-source>

            <non-jta-data-source>MyOrclDSUn</non-jta-data-source>

            <class>

      [pojo here]

            </class>

            <properties>

                  <property name="hibernate.dialect"



value="org.hibernate.dialect.Oracle10gDialect" />

                  <property name="hibernate.show_sql" value="false" />

                  <property name="hibernate.cache.provider_class"



value="org.hibernate.cache.HashtableCacheProvider" />

                  <property

name="hibernate.transaction.manager_lookup_class"



value="org.hibernate.transaction.JBossTransactionManagerLookup" />

            </properties>

      </persistence-unit>



I user latest version of OpenEJB (3.1).

I use oracle XE.

I have to say that I am migrating from JBoss 4.x, in JBoss it works
perfectly.



Thank you.



Regards,

Paolo


2009/1/21 David Blevins <david.blev...@visi.com>

> Hi Paolo,
>
> Something interesting is going on.
>
> The openejb.xml looks great and the persistence-unit declaration for "MyEM"
> looks perfect.  Can you post the declaration for the "MyOrclEM"
> persistence-unit?  Even if the MyOrclEM declaration was somehow flawed I
> wouldn't expect the outcome you got.  We've got a large amount of tests[1]
> for this feature.  We should be able to plug your config into those tests
> and figure out what's going on.
>
> On a side note, it looks like the datasources "MyDS" and "MyOrclDS" are
> identical as are "MyDSUn" and "MyOrclDS".  If you're willing to give some
> details on what motivates that, that'd be great.  I suspect there is a
> feature waiting to be added there that might help you reduce redundant
> configuration.
>
> Also, what OpenEJB version are you using?
>
> -David
>
> [1]
> http://svn.apache.org/repos/asf/openejb/tags/openejb-3.1/container/openejb-core/src/test/java/org/apache/openejb/config/AutoConfigPersistenceUnitsTest.java
>
>
> On Jan 19, 2009, at 4:19 AM, Paolo Spadafora wrote:
>
>  Hello,
>>
>> I have a problem with datasource, looks like openejb is using an hsqldb
>> database instead of Oracle.
>>
>>
>>
>> The error is: "table not found"
>>
>>
>>
>> INFO: building session factory
>>
>> 19-gen-2009 12.43.36 org.hibernate.impl.SessionFactoryObjectFactory
>> addInstance
>>
>> INFO: Not binding factory to JNDI, no JNDI name configured
>>
>> 19-gen-2009 12.43.36 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>>
>> INFO: Running hbm2ddl schema update
>>
>> 19-gen-2009 12.43.36 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>>
>> INFO: fetching database metadata
>>
>> 19-gen-2009 12.43.36 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
>>
>> GRAVE: could not get database metadata
>>
>> java.sql.SQLException: Tabella non trovata in statement [select
>> sequence_name fr
>>
>> om user_sequences]
>>
>>       at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
>>
>>       at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
>>
>>       at org.hsqldb.jdbc.jdbcStatement.executeQuery(Unknown Source)
>>
>>       at
>> org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingSt
>>
>> atement.java:208)
>>
>>       at
>> org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingSt
>>
>> atement.java:208)
>>
>>       at
>> org.hibernate.tool.hbm2ddl.DatabaseMetadata.initSequences(DatabaseMet
>>
>> adata.java:128)
>>
>>       at
>> org.hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.j
>>
>> ava:46)
>>
>>       at
>> org.hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.j
>>
>> ava:39)
>>
>>       at
>> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:129
>>
>> )
>>
>>       at
>> org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
>>
>> 314)
>>
>>       at
>> org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
>>
>> a:1300)
>>
>>       at
>> org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(Annotat
>>
>> ionConfiguration.java:859)
>>
>>       at
>> org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Con
>>
>> figuration.java:669)
>>
>>       at
>> org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFa
>>
>> ctory(HibernatePersistence.java:132)
>>
>>       at
>> org.apache.openejb.assembler.classic.PersistenceBuilder.createEntityM
>>
>> anagerFactory(PersistenceBuilder.java:183)
>>
>>       at
>> org.apache.openejb.assembler.classic.Assembler.createApplication(Asse
>>
>> mbler.java:487)
>>
>>       at
>> org.apache.openejb.assembler.classic.Assembler.createApplication(Asse
>>
>> mbler.java:447)
>>
>>       at
>> org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(A
>>
>> ssembler.java:365)
>>
>>       at
>> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:2
>>
>> 77)
>>
>>       at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:150)
>>
>>       at org.apache.openejb.OpenEJB.init(OpenEJB.java:299)
>>
>>       at
>> org.apache.openejb.tomcat.catalina.TomcatLoader.init(TomcatLoader.jav
>>
>> a:121)
>>
>>
>>
>>
>>
>> Openejb.xml:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <openejb>
>>
>>
>>
>> <Container id="My CMP Container" type="CMP_ENTITY">
>>
>>
>>
>> </Container>
>>
>> <Container id="My BMP Container" type="BMP_ENTITY">
>>
>>
>>
>>  PoolSize 10
>>
>>
>>
>> </Container>
>>
>> <Container id="My Stateful Container" type="STATEFUL">
>>
>>  Passivator   org.apache.openejb.core.stateful.SimplePassivater
>>
>>
>>
>>  TimeOut  20
>>
>>
>>
>>  Capacity  1000
>>
>>
>>
>>  BulkPassivate  100
>>
>>
>>
>> </Container>
>>
>>
>>
>> <Container id="My Stateless Container" type="STATELESS">
>>
>>  TimeOut  0
>>
>>
>>
>>  PoolSize  10
>>
>>
>>
>>  StrictPooling  true
>>
>> </Container>
>>
>>
>>
>> <Resource id="MyDS" type="DataSource">
>>
>> JdbcDriver oracle.jdbc.OracleDriver
>>
>> JdbcUrl jdbc:oracle:thin:@localhost:1521:XE
>>
>> UserName username
>>
>> Password password
>>
>> JtaManaged true
>>
>> </Resource>
>>
>>
>>
>>
>>
>> <Resource id="MyDSUn" type="DataSource">
>>
>> JdbcDriver oracle.jdbc.OracleDriver
>>
>> JdbcUrl jdbc:oracle:thin:@localhost:1521:XE
>>
>> UserName username
>>
>> Password password
>>
>> JtaManaged false
>>
>> </Resource>
>>
>>
>>
>>
>>
>> <Resource id="MyOrclDS" type="DataSource">
>>
>> JdbcDriver oracle.jdbc.OracleDriver
>>
>> JdbcUrl jdbc:oracle:thin:@localhost:1521:XE
>>
>> UserName username
>>
>> Password password
>>
>> JtaManaged true
>>
>> </Resource>
>>
>>
>>
>>
>>
>> <Resource id="MyOrclDSUn"  type="DataSource">
>>
>> JdbcDriver oracle.jdbc.OracleDriver
>>
>> JdbcUrl jdbc:oracle:thin:@localhost:1521:XE
>>
>> UserName username
>>
>> Password password
>>
>> JtaManaged false
>>
>> </Resource>
>>
>>
>>
>> <Deployments dir="apps/" />
>>
>>
>>
>> </openejb>
>>
>>
>>
>>
>>
>>
>>
>> Persistence.xml:
>>
>> <persistence 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";
>>
>>     version="1.0">
>>
>>     <persistence-unit name="MyEM" transaction-type="JTA" >
>>
>>           <provider>org.hibernate.ejb.HibernatePersistence</provider>
>>
>>           <jta-data-source>MyDS</jta-data-source>
>>
>>           <non-jta-data-source>MyDSUn</non-jta-data-source>
>>
>>           <class>.</class>
>>
>>           [pojo classes]
>>
>>
>>
>>           <exclude-unlisted-classes>false</exclude-unlisted-classes>
>>
>>           <properties>
>>
>>               <property name="hibernate.dialect"
>>
>>                       value="org.hibernate.dialect.Oracle10gDialect" />
>>
>>                 <property name="hibernate.show_sql" value="true" />
>>
>>                 <property name="hibernate.cache.provider_class"
>>
>>                       value="org.hibernate.cache.HashtableCacheProvider"
>> />
>>
>>                 <property
>> name="hibernate.transaction.manager_lookup_class"
>>
>>
>> value="org.hibernate.transaction.JBossTransactionManagerLookup" />
>>
>>                 <property name="hibernate.hbm2ddl.auto" value="update" />
>>
>>                 <property name="hibernate.jdbc.batch_size" value="0"/>
>>
>>           </properties>
>>
>>     </persistence-unit>
>>
>>
>>
>>
>>
>>
>>
>> Openejb.log (why is openejb "Adjusting" the datasource for my EM?)
>>
>> 2009-01-19 12:43:30,217 - INFO  - Configuring Service(id=Tomcat Security
>> Service, type=SecurityService, provider-id=Tomcat Security Service)
>>
>> 2009-01-19 12:43:30,220 - INFO  - Configuring Service(id=Default
>> Transaction
>> Manager, type=TransactionManager, provider-id=Default Transaction Manager)
>>
>> 2009-01-19 12:43:30,222 - INFO  - Configuring Service(id=MyDS,
>> type=Resource, provider-id=Default JDBC Database)
>>
>> 2009-01-19 12:43:30,224 - INFO  - Configuring Service(id=MyDSUn,
>> type=Resource, provider-id=Default JDBC Database)
>>
>> 2009-01-19 12:43:30,225 - INFO  - Configuring Service(id=MyOrclDS,
>> type=Resource, provider-id=Default JDBC Database)
>>
>> 2009-01-19 12:43:30,227 - INFO  - Configuring Service(id=MyOrclDSUn,
>> type=Resource, provider-id=Default JDBC Database)
>>
>> 2009-01-19 12:43:30,230 - INFO  - Configuring Service(id=My CMP Container,
>> type=Container, provider-id=Default CMP Container)
>>
>> 2009-01-19 12:43:30,232 - INFO  - Configuring Service(id=My BMP Container,
>> type=Container, provider-id=Default BMP Container)
>>
>> 2009-01-19 12:43:30,234 - INFO  - Configuring Service(id=My Stateful
>> Container, type=Container, provider-id=Default Stateful Container)
>>
>> 2009-01-19 12:43:30,235 - INFO  - Configuring Service(id=My Stateless
>> Container, type=Container, provider-id=Default Stateless Container)
>>
>> 2009-01-19 12:43:30,934 - INFO  - Configuring enterprise application:
>> C:\dev\apache-tomcat-6.0.18\apps\my-ejb.jar
>>
>> 2009-01-19 12:43:31,408 - INFO  - Configuring PersistenceUnit(name=MyEM,
>> provider=org.hibernate.ejb.HibernatePersistence)
>>
>> 2009-01-19 12:43:31,413 - INFO  - Configuring Service(id=Default JDBC
>> Database, type=Resource, provider-id=Default JDBC Database)
>>
>> 2009-01-19 12:43:31,415 - INFO  - Configuring Service(id=Default Unmanaged
>> JDBC Database, type=Resource, provider-id=Default Unmanaged JDBC Database)
>>
>> 2009-01-19 12:43:31,416 - INFO  - Auto-creating a Resource with id
>> 'Default
>> JDBC Database' of type 'DataSource for 'MyEM'.
>>
>> 2009-01-19 12:43:31,416 - INFO  - Auto-creating a Resource with id
>> 'Default
>> Unmanaged JDBC Database' of type 'DataSource for 'MyEM'.
>>
>> 2009-01-19 12:43:31,416 - INFO  - Configuring
>> PersistenceUnit(name=MyOrclEM,
>> provider=org.hibernate.ejb.HibernatePersistence)
>>
>> 2009-01-19 12:43:31,417 - INFO  - Adjusting MyOrclEM <jta-data-source> to
>> 'Default JDBC Database'
>>
>> 2009-01-19 12:43:31,418 - INFO  - Adjusting MyOrclEM <non-jta-data-source>
>> to 'Default Unmanaged JDBC Database'
>>
>> 2009-01-19 12:43:31,447 - INFO  - Enterprise application
>> "C:\dev\magsuite\ms-v2\apache-tomcat-6.0.18\apps\msuite-ejb.jar" loaded.
>>
>>
>>
>>
>>
>> All necessary jars are there: hibernates jars and oracle drivers.
>>
>>
>>
>> Thank you.
>>
>>
>>
>> Regards,
>>
>> Paolo
>>
>>
>

Reply via email to