Re: Unable to use two XA Datasource in a same transaction

2017-04-24 Thread David Jencks
I’m not very familiar with this configuration, but I don’t see any indication 
that the two datasources are connecting to different databases.  If they 
connect to the same database I think that is likely the source of the problem.  
There might possibly be an Oracle setting to allow this.  It might possibly be 
called something like loose coupling or tight coupling.  It would be better to 
change to one datasource per target database, however, as you would be making 
the database work much less with one xid rather than two.

david jencks

> On Apr 24, 2017, at 1:56 AM, Dignesh  wrote:
> 
> I created two XA datasource and getting connection from both datasource in
> same transaction. I'm getting below exeception when i try to get connection
> from second data source
> 
> Caused by: java.sql.SQLException: Unable to enlist connection in
> transaction: enlistResource returns 'false'.
> at
> org.apache.openejb.resource.jdbc.managed.local.ManagedConnection.invoke(ManagedConnection.java:136)
> at com.sun.proxy.$Proxy82.prepareStatement(Unknown Source)
> 
> TomEE Version: 7.0.2
> Database: Oracle
> 
> Here are the datasource configurations
> 
>   
>   XaDataSource XA/Datasource
>   UserName $UserName$
>   Password $Password$
>   PasswordCipher TestCipher   
>   maxActive = 40
>   minIdle = 2
>   validationQuery = select 1 from dual
>   testOnBorrow = true
>   validationInterval = 3
>   
>   
>   
>   XaDataSource XA/Datasource
>   UserName $UserName$
>   Password $Password$
>   PasswordCipher TestCipher
>   maxActive = 20
>   minIdle = 2
>   validationQuery = select 1 from dual
>   testOnBorrow = true
>   validationInterval = 3
>   
>   
>class-name="oracle.jdbc.xa.client.OracleXADataSource">
>   Url $JdbcUrl$   
>   
> 
> Note: I'm not seeing this issue when i use PostgreSQL database
> 
> Thank You.
> 
> 
> 
> --
> View this message in context: 
> http://tomee-openejb.979440.n4.nabble.com/Unable-to-use-two-XA-Datasource-in-a-same-transaction-tp4681579.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.



Re: Error when using EH Cache with Hibernate

2017-04-24 Thread cri_sys
Finally it looks i found the solution.
I removed my Resource Jdbc from tomee.xml and it is loading and getting the
configurations done in persistance.xml.

Even though still i see that my query it is not really improved and it is
not hitting the cache.
I activated the stats and as result i get:
2017-04-24 15:12:19 INFO  StatisticalLoggingSessionEventListener:275 -
Session Metrics {
892456 nanoseconds spent acquiring 27 JDBC connections;
172511 nanoseconds spent releasing 27 JDBC connections;
217866203 nanoseconds spent preparing 27 JDBC statements;
2646336502 nanoseconds spent executing 27 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
1239845 nanoseconds spent performing 19 L2C hits;
490312 nanoseconds spent performing 1 L2C misses;
17828739 nanoseconds spent executing 1 flushes (flushing a total of 39
entities and 57 collections);
6846 nanoseconds spent executing 1 partial-flushes (flushing a total of
0 entities and 0 collections)
}

and i am using the following code to activate the cache:
Query query =
createNamedQuery("Feed.findAll").setMaxResults(limit).setFirstResult(offset);
query.setHint("org.hibernate.cacheable", true);
return query.getResultList();

am i missing something?



--
View this message in context: 
http://tomee-openejb.979440.n4.nabble.com/Error-when-using-EH-Cache-with-Hibernate-tp4681560p4681585.html
Sent from the TomEE Dev mailing list archive at Nabble.com.


Re: Error when using EH Cache with Hibernate

2017-04-24 Thread cri_sys
I deleted the @Cache from my entity, and checked on JMX the persistance-unit
properties, and indeed the configuration from properties it is not there.
any of the folloing properties are there:
  
  
  
  
  
  
  
  
  

  
  

  
  
  

Maybe because it is being overritten by the Resource from tomee.xml?



--
View this message in context: 
http://tomee-openejb.979440.n4.nabble.com/Error-when-using-EH-Cache-with-Hibernate-tp4681560p4681584.html
Sent from the TomEE Dev mailing list archive at Nabble.com.


Re: Error when using EH Cache with Hibernate

2017-04-24 Thread cri_sys
I want to try the option 1 you just gave me, but i am not sure if i got the
idea, you want me to remove the depencies from the pom o my project? and
just keep the libraries in the tomee/lib? should i put it as provided?

BTW, the error just prompt whenever i use on my entity, @Cache(usage =
CacheConcurrencyStrategy.READ_WRITE, region = "feed"), if i remove that
line, the error dissapears. But still i want to activate the cache.



--
View this message in context: 
http://tomee-openejb.979440.n4.nabble.com/Error-when-using-EH-Cache-with-Hibernate-tp4681560p4681582.html
Sent from the TomEE Dev mailing list archive at Nabble.com.


Re: Error when using EH Cache with Hibernate

2017-04-24 Thread Romain Manni-Bucau
hmm maybe try these:

1. put hibernate/ehcache in tomee/lib (avoid duplicates) and give it a try
removing it from your app
2. if 1 didnt work it means your config is wrong for that version, if 1
worked it means there is a conflict
2.a you can confirm a conflict using tomee webprofile probably - since
there is no ehcache there it should work
2.b  best is likely to debug hibernate when loading, happy to help you on
that if you setup tomee-maven-plugin in a github project easy to run


Romain Manni-Bucau
@rmannibucau  |  Blog
 | Old Blog
 | Github  |
LinkedIn  | JavaEE Factory


2017-04-24 12:04 GMT+02:00 cri_sys :

> Yeah i am using the plus distribution: version 1.7.4
>
> I tried again with the dependencies in case there is a conflict as you said
> but still not success, currently ive got in my pom.xml
> 
> org.hibernate
> hibernate-core
> 4.2.21.Final
> 
> 
> org.hibernate
> hibernate-entitymanager
> 4.2.21.Final
> 
> 
> hibernate-core
> org.hibernate
> 
> 
> 
> 
> net.sf.ehcache
> ehcache-core
> 2.4.3
> 
> 
> org.hibernate.common
> hibernate-commons-annotations
> 4.0.5.Final
> 
> 
> org.hibernate
> hibernate-ehcache
> 4.2.21.Final
> 
> 
> hibernate-core
> org.hibernate
> 
> 
> 
>
>
> and in my lib folder/
> hibernate-annotations-3.5.6-Final.jar
> hibernate-commons-annotations-4.0.5.Final.jar
> hibernate-core-4.2.21.Final.jar
> hibernate-ehcache-4.2.21.Final.jar
> hibernate-entitymanager-4.2.21.Final.jar
> hibernate-validator-4.3.0.Final.jar
>
>
> i am using even same versioning, still no idea why my cache it is not
> working. Any other suggestion?
> Thanks
>
>
>
> --
> View this message in context: http://tomee-openejb.979440.
> n4.nabble.com/Error-when-using-EH-Cache-with-Hibernate-
> tp4681560p4681580.html
> Sent from the TomEE Dev mailing list archive at Nabble.com.
>


Re: Error when using EH Cache with Hibernate

2017-04-24 Thread cri_sys
Yeah i am using the plus distribution: version 1.7.4

I tried again with the dependencies in case there is a conflict as you said
but still not success, currently ive got in my pom.xml

org.hibernate
hibernate-core
4.2.21.Final


org.hibernate
hibernate-entitymanager
4.2.21.Final


hibernate-core
org.hibernate




net.sf.ehcache
ehcache-core
2.4.3


org.hibernate.common
hibernate-commons-annotations
4.0.5.Final


org.hibernate
hibernate-ehcache
4.2.21.Final


hibernate-core
org.hibernate





and in my lib folder/
hibernate-annotations-3.5.6-Final.jar
hibernate-commons-annotations-4.0.5.Final.jar
hibernate-core-4.2.21.Final.jar
hibernate-ehcache-4.2.21.Final.jar
hibernate-entitymanager-4.2.21.Final.jar
hibernate-validator-4.3.0.Final.jar


i am using even same versioning, still no idea why my cache it is not
working. Any other suggestion?
Thanks



--
View this message in context: 
http://tomee-openejb.979440.n4.nabble.com/Error-when-using-EH-Cache-with-Hibernate-tp4681560p4681580.html
Sent from the TomEE Dev mailing list archive at Nabble.com.


Unable to use two XA Datasource in a same transaction

2017-04-24 Thread Dignesh
I created two XA datasource and getting connection from both datasource in
same transaction. I'm getting below exeception when i try to get connection
from second data source

Caused by: java.sql.SQLException: Unable to enlist connection in
transaction: enlistResource returns 'false'.
 at
org.apache.openejb.resource.jdbc.managed.local.ManagedConnection.invoke(ManagedConnection.java:136)
 at com.sun.proxy.$Proxy82.prepareStatement(Unknown Source)
 
TomEE Version: 7.0.2
Database: Oracle

Here are the datasource configurations


XaDataSource XA/Datasource
UserName $UserName$
Password $Password$
PasswordCipher TestCipher   
maxActive = 40
minIdle = 2
validationQuery = select 1 from dual
testOnBorrow = true
validationInterval = 3



XaDataSource XA/Datasource
UserName $UserName$
Password $Password$
PasswordCipher TestCipher
maxActive = 20
minIdle = 2
validationQuery = select 1 from dual
testOnBorrow = true
validationInterval = 3



Url $JdbcUrl$   


Note: I'm not seeing this issue when i use PostgreSQL database

Thank You.



--
View this message in context: 
http://tomee-openejb.979440.n4.nabble.com/Unable-to-use-two-XA-Datasource-in-a-same-transaction-tp4681579.html
Sent from the TomEE Dev mailing list archive at Nabble.com.