Fabio Schmitz Tani [
http://community.jboss.org/people/fstani] created the discussion
"From Tomcat 6 Spring/JPA/JTA to JBoss EAP 5.1.0"
To view the discussion, visit:
http://community.jboss.org/message/563821#563821
--------------------------------------------------------------
First of all I'd like to introduce myself, I'm new to posting in this community
although I have worked with JBoss AS in the past, in versions 3 and 4, and more recently
with Mobicents Sip Servlet with JBoss 4.
For the past month I've had my first contacts with JBoss AS 5, I was given the task of
researching and documenting migration paths from applications deployed in Tomcat 6 to the
JBoss AS 5, since the company I'm working for is planning on moving applications from
some other application servers including Tomcat 6 (which I know it is not a valid JEE 5
container) and Oracle WebLogic.
Most of their applications so far didn't have the need of a JEE 5 application server,
but recently some applications have been leveraging third party libraries to emulate a JEE
5 environment inside tomcat, so the decision was made to instead try to put everything in
a more homogeneous environment.
So far I've been able to overcome most of my problems with some research and testing
of environments, but I'm still not there. I am trying to migrate the most recent
application that was developed, trying to change mostly the xml configurations and the
environment, in order not to generate re-work to the source code of this applications, at
least not in an initial phase anyways.
So getting to the questions, I have had some success configuring some various steps, such
as ClassLoading, VFS, Weaving with Snowdrop, TransactionManagement (sort of) with JBoss
and JTA.
I think I've covered a lot of ground getting information that was already answered and
reading historic links here and there, but I think I'm getting to a point where I
would really need to interact with the people who know JBoss the most, since I've been
getting to a point where the information I'm getting is either old or outdated. And
I'm stumbling on documentation and examples that are probably still linked by google
but are probably not the current information on the subject.
So, right now what I'm trying to solve is working with multiple datasources in a
transactional environment with two phase commit.
The basic application background is:
JBoss As 5.1.0
Hibernate 3.3.1 - using ClassLoad isolation
Spring 2.5.6 + Snowdrop 1.0.1 GA - to fix VFS and Weaving
JTA (In Tomcat was done using JoTM, in JBoss 5 switched to JBossTS)
MyFaces 1.2.6 + RichFaces 3.0.0 - using the JSF implementation from the WAR, configured in
web.xml
From what I've been able to dig up so far, JBoss 5, which uses
JBossTS, does not support using multiple local-tx-datasources in a war, this being because
the old method is broken and does not guarantee ACID, so basically, in the past it was
possible to use it like this but it would result in errors, so now it is blocked from
being possible to even do this type of configuration.
Ok, so the solution that is pointed is to use XA, luckily for me the underlying database
is Oracle 10g, so we are able to switch to Oracle XA drivers, so with this I've looked
up how to properly set up XA Datasources with Oracle, unfortunately the documentation and
the examples include some hints, which appear to be old or not longer needed (You can see
it here in this thread:
http://community.jboss.org/thread/156044
http://community.jboss.org/thread/156044).
And I think that's where I'm hitting a wall, I'll post the code for the old
local-tx-datasources that would start the application ok, but would throw the two phase
commit problem:
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/Datasource1DS</jndi-name>
<rar-name>jboss-local-jdbc.rar</rar-name>
<use-java-context>true</use-java-context>
<connection-definition>javax.sql.DataSource</connection-definition>
<jmx-invoker-name>jboss:service=invoker,type=jrmp</jmx-invoker-name>
<min-pool-size>5</min-pool-size>
<max-pool-size>20</max-pool-size>
<blocking-timeout-millis>30000</blocking-timeout-millis>
<idle-timeout-minutes>30</idle-timeout-minutes>
<prefill>false</prefill>
<background-validation>false</background-validation>
<background-validation-millis>0</background-validation-millis>
<validate-on-match>true</validate-on-match>
<statistics-formatter>org.jboss.resource.statistic.pool.JBossDefaultSubPoolStatisticFormatter</statistics-formatter>
<isSameRM-override-value>false</isSameRM-override-value>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>5000</allocation-retry-wait-millis>
<security-domain-and-application xsi:type="securityMetaData"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
<local-transaction/>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<user-name>userName</user-name>
<password>passWd</password>
<check-valid-connection-sql>SELECT * FROM
DUAL</check-valid-connection-sql>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter</exception-sorter-class-name>
<prepared-statement-cache-size>0</prepared-statement-cache-size>
<share-prepared-statements>false</share-prepared-statements>
<set-tx-query-timeout>false</set-tx-query-timeout>
<query-timeout>0</query-timeout>
<use-try-lock>60000</use-try-lock>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<connection-url>jdbc:oracle:thin:@oracle-db:1521:schema</connection-url>
</local-tx-datasource>
</datasources>
I have two other datasources which have a similar configuration with different schema /
username and passwords, and JNDI name.
So from that I converted it, according to documentation and other threads to:
<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
<datasources>
<xa-datasource>
<jndi-name>jdbc/Datasource1DS</jndi-name>
<track-connection-by-tx>true</track-connection-by-tx>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">
jdbc:oracle:thin:@oracle-db:1521:schema
</xa-datasource-property>
<xa-datasource-property
name="User">userName</xa-datasource-property>
<xa-datasource-property
name="Password">pwd</xa-datasource-property>
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
</exception-sorter-class-name>
<no-tx-separate-pools/>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</xa-datasource>
<xa-datasource>
<jndi-name>jdbc/Datasource2DS</jndi-name>
<track-connection-by-tx>true</track-connection-by-tx>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">
jdbc:oracle:thin:@oracle-db:1521:schema
</xa-datasource-property>
<xa-datasource-property
name="User">userName2</xa-datasource-property>
<xa-datasource-property
name="Password">pwd2</xa-datasource-property>
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
</exception-sorter-class-name>
<no-tx-separate-pools/>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</xa-datasource>
<xa-datasource>
<jndi-name>jdbc/Datasource3DS</jndi-name>
<track-connection-by-tx>true</track-connection-by-tx>
<isSameRM-override-value>false</isSameRM-override-value>
<xa-datasource-class>oracle.jdbc.xa.client.OracleXADataSource</xa-datasource-class>
<xa-datasource-property name="URL">
jdbc:oracle:thin:@oracle-db:1521:schema
</xa-datasource-property>
<xa-datasource-property
name="User">userName3</xa-datasource-property>
<xa-datasource-property
name="Password">pwd3</xa-datasource-property>
<exception-sorter-class-name>
org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter
</exception-sorter-class-name>
<no-tx-separate-pools/>
<metadata>
<type-mapping>Oracle9i</type-mapping>
</metadata>
</xa-datasource>
<mbean
code="org.jboss.resource.adapter.jdbc.vendor.OracleXAExceptionFormatter"
name="jboss.jca:service=OracleXAExceptionFormatter">
<depends optional-attribute-name="TransactionManagerService">
jboss:service=TransactionManager
</depends>
</mbean>
</datasources>
I've added all the DS in a single file because of the mbean declaration, which JBoss
would complain to be duplicated if I had multiple *-ds.xml files.
Anyways, what happens is that when the application tries to get a connection from the
pool, an execption is thrown:
Caused by: javax.resource.ResourceException: Unable to get managed connection for
jdbc/DataSource1DS
at
org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:441)
at
org.jboss.resource.connectionmanager.TxConnectionManager.getManagedConnection(TxConnectionManager.java:413)
at
org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:496)
at
org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
at
org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
... 129
more
Caused by: org.jboss.resource.JBossResourceException: Could not create connection; -
nested throwable: (java.sql.SQLException: Invalid argument(s) in
call)
at
org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:465)
at
org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:409)
at
org.jboss.resource.connectionmanager.InternalManagedConnectionPool.createConnectionEventListener(InternalManagedConnectionPool.java:633)
at
org.jboss.resource.connectionmanager.InternalManagedConnectionPool.getConnection(InternalManagedConnectionPool.java:267)
at
org.jboss.resource.connectionmanager.JBossManagedConnectionPool$BasePool.getConnection(JBossManagedConnectionPool.java:690)
at
org.jboss.resource.connectionmanager.BaseConnectionManager2.getManagedConnection(BaseConnectionManager2.java:404)
... 133
more
Caused by: java.sql.SQLException: Invalid argument(s) in
call
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125)
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162)
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227)
at
oracle.jdbc.xa.client.OracleXADataSource.getXAConnection(OracleXADataSource.java:96)
at
org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:449)
... 138 more
I've searched a little for solutions but no answer still, the documentation recommends
adding a property called Pad = true, on a mbean which appears not to exist on
jboss-service.xml, this appears to be stale documentation, I've read somewhere that
now it is already set as true by default, but I don't remember where exactly I've
read it.
Anyways what I aim is to be able to discuss this issue with the community, and as it goes
on I could post the solutions I've found over here, they may be particular to my
application or they may be general enough as to help someone else, as some countless
others I've found have helped.
Anyone who can throw in their two cents is welcome.
Thanks in advance,
And sorry for doing a long post :D
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/563821#563821]
Start a new discussion in Beginner's Corner at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]