I think I've found it ;-)

this was funny

INFO: Configuring PersistenceUnit(name=poc)
Jul 16, 2013 4:59:34 PM org.apache.openejb.config.AutoConfig setJtaDataSource
INFO: Adjusting PersistenceUnit poc <jta-data-source> to Resource ID
'poc1' from 'xyz1'
Jul 16, 2013 4:59:34 PM org.apache.openejb.config.AutoConfig setNonJtaDataSource
INFO: Adjusting PersistenceUnit poc <non-jta-data-source> to Resource
ID 'jdbc/quartzDS2' from 'xyz2'

probably because persistence.xml has

  <persistence-unit name="poc">
    <jta-data-source>xyz1</jta-data-source>
    <non-jta-data-source>xyz2</non-jta-data-source>

and tomee.xml has

        <Resource id="poc1" type="DataSource">
                JdbcDriver com.mysql.jdbc.Driver
                JdbcUrl jdbc:mysql://localhost:3306/tomee
                UserName xxx
                Password xxx
                JtaManaged true
        </Resource>

        <Resource id="jdbc/quartzDS" type="DataSource">
                JdbcDriver com.mysql.jdbc.Driver
                JdbcUrl jdbc:mysql://localhost:3306/quartz
                UserName xxx
                Password xxx
                JtaManaged true
        </Resource>

        <Resource id="jdbc/quartzDS2" type="DataSource">
                JdbcDriver com.mysql.jdbc.Driver
                JdbcUrl jdbc:mysql://localhost:3306/quartz
                UserName xxx
                Password xxx
                JtaManaged false
        </Resource>

it seems openJPA just decided to pick up the first JtaManaged=false
and bind it to xyz2 because... well, it needed one I guess

:-)

seems to be solved adding, of course, the right JtaManaged=false in tomee.xml

        <Resource id="poc1" type="DataSource">
                JdbcDriver com.mysql.jdbc.Driver
                JdbcUrl jdbc:mysql://localhost:3306/tomee
                UserName xxx
                Password xxx
                JtaManaged true
        </Resource>

        <Resource id="poc2" type="DataSource">
                JdbcDriver com.mysql.jdbc.Driver
                JdbcUrl jdbc:mysql://localhost:3306/tomee
                UserName xxx
                Password xxx
                JtaManaged false
        </Resource>

        <Resource id="jdbc/quartzDS" type="DataSource">
                JdbcDriver com.mysql.jdbc.Driver
                JdbcUrl jdbc:mysql://localhost:3306/quartz
                UserName xxx
                Password xxx
                JtaManaged true
        </Resource>

        <Resource id="jdbc/quartzDS2" type="DataSource">
                JdbcDriver com.mysql.jdbc.Driver
                JdbcUrl jdbc:mysql://localhost:3306/quartz
                UserName xxx
                Password xxx
                JtaManaged false
        </Resource>

oh boy

[]

Leo


On Tue, Jul 16, 2013 at 3:13 PM, Romain Manni-Bucau
<[email protected]> wrote:
> did you look openjpa.jdbc.Schema too?
>
> but once again maybe fwd it to openjpa@
>
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2013/7/16 Leonardo K. Shikida <[email protected]>
>>
>> Hi Romain
>>
>> probably is, because I've tried
>>
>>   <!--http://openjpa.apache.org/faq.html-->
>>   <!-- does not create foreign keys, creates schema and deletes
>> content of a database
>>        (deleteTableContents - foreign keys are created twice???), use
>> dropDB instead -->
>>   <property name="openjpa.jdbc.SynchronizeMappings"
>> value="buildSchema(foreignKeys=true,schemaAction='dropDB,add')"/>
>>   <!--Resolves the problem with foreign key integrity - joined
>> entities are persisted sometimes in wrong order??? (verify it)-->
>>   <property name="openjpa.jdbc.SchemaFactory"
>> value="native(foreignKeys=true)" />
>>   <!--Create foreign keys-->
>>   <property name="openjpa.jdbc.MappingDefaults"
>> value="ForeignKeyDeleteAction=restrict,
>> JoinForeignKeyDeleteAction=restrict"/>
>>   <property name="openjpa.Log" value="DefaultLevel=TRACE,SQL=TRACE" />
>>
>> and then it create almost all the entities... in the wrong user :-)
>>
>> I have an schema for quartz, another for jms and another for entities
> (JPA)
>>
>> it created the JPA entities in quartz...
>>
>> I haven't digged all the logs yet, but it seems it tries to get some
>> jdbc connection to create the tables, finds null and then fallback to
>> the first one it finds (in this case, it seems it was quartz), but I
>> am not sure of that yet.
>>
>> I don't know if it's related, but I remember when I've worked with
>> dbUnit that Oracle sometimes needs to know the "schema" to be the same
>> as the "user".
>>
>> []
>>
>> Leo
>>
>>
>> On Tue, Jul 16, 2013 at 1:57 PM, Romain Manni-Bucau
>> <[email protected]> wrote:
>> > Hi,
>> >
>> > I got issues with schema for the init of the base when having mutiple
>> > schemas. Is it your case?
>> >
>> > Ps: maybe openjpa list is more adapted
>> > Le 16 juil. 2013 18:46, "Leonardo K. Shikida" <[email protected]> a
> écrit :
>> >
>> >> Hi
>> >>
>> >> I have an app that was creating entities fine in mysql and it does not
>> >> when I try on oracle.
>> >>
>> >> The error message does not help much
>> >>
>> >> INFO: Starting OpenJPA 2.2.0
>> >> Jul 16, 2013 3:58:27 PM null
>> >> INFO: Using dictionary class
>> >> "org.apache.openjpa.jdbc.sql.OracleDictionary".
>> >> javax.ejb.EJBException: The bean encountered a non-application
>> >> exception; nested exception is:
>> >>         <openjpa-2.2.0-r422266:1244990 fatal store error>
>> >> org.apache.openjpa.persistence.OptimisticLockException: Unable to
>> >> obtain an object lock on "null".
>> >>         at
>> >>
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.convertException(BaseEjbProxyHandler.java:363)
>> >>         at
>> >>
> org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:283)
>> >> (...)
>> >> Caused by: <openjpa-2.2.0-r422266:1244990 fatal store error>
>> >> org.apache.openjpa.persistence.OptimisticLockException: Unable to
>> >> obtain an object lock on "null".
>> >>         at
>> >> org.apache.openjpa.jdbc.sql.DBDictionary.narrow(DBDictionary.java:4900)
>> >>         at
>> >>
> org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(DBDictionary.java:4878)
>> >>         at
>> >>
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:136)
>> >>         at
>> >>
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:118)
>> >>         at
>> >>
> org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(SQLExceptions.java:70)
>> >> (...)
>> >> Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException:
>> >> ORA-00942: table or view does not exist
>> >>  {prepstmnt 219199633 SELECT t0.id, t0.name FROM SiteType t0}
>> >> [code=942, state=42000]
>> >>         at
>> >>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:247)
>> >>         at
>> >>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:231)
>> >>         at
>> >>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:72)
>> >>         at
>> >>
> org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:1146)
>> >>         at
>> >>
> org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:265)
>> >>         at
>> >>
> org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1750)
>> >> (..)
>> >>         ... 111 more
>> >>
>> >> my persistence.xml has
>> >>
>> >>     <properties>
>> >>       <property name="openjpa.jdbc.DBDictionary"
>> >> value="org.apache.openjpa.jdbc.sql.OracleDictionary"/>
>> >>       <property name="openjpa.jdbc.SynchronizeMappings"
>> >> value="buildSchema(ForeignKeys=true)"/>
>> >>     </properties>
>> >>
>> >> any ideas?
>> >>
>> >> TIA
>> >>
>> >> Leo
>> >>

Reply via email to