问题
I'm working on a websphere 6.1 migration to jboss EAP 6.3. I find that the deployment process is very simple in jboss content that my old server contains only wars.
the configuration of shared libraries has passed without problem, but the problem is with the configuration of datasources a java.sql.SQLException error: You can not commit with autocommit set! block passage.
I searched on google most say that this is the standard, and that we must change the code to setAutoCommit (Fasle).
But in my case, in order that this passage is transparent for developers or with minimal change, I can't change the war. The area of my intervention are application server only.
Below configuration file standalone.xml:
thank you for guiding me if another issue that deals with the same problem, I have not found a similar problem. even if it is something elementary in my opinion !!
Similar questions but need more detail
Any ideas please ?
<datasource jta="true" jndi-name="java:/jdbc/XXXXPool" pool-name="XXXXPool" enabled="true" use-ccm="true">
<connection-url>jdbc:oracle:thin:@xxxxxxxxx:1521:xxx</connection-url>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<datasource-class>oracle.jdbc.pool.OracleConnectionPoolDataSource</datasource-class>
<connection-property name="autoCommit"> <!-- not working -->
false
</connection-property>
<driver>OracleJDBCDriver</driver>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
<security>
<user-name>xx</user-name>
<password></password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<timeout>
<set-tx-query-timeout>false</set-tx-query-timeout>
<blocking-timeout-millis>0</blocking-timeout-millis>
<idle-timeout-minutes>0</idle-timeout-minutes>
<query-timeout>0</query-timeout>
<use-try-lock>0</use-try-lock>
<allocation-retry>0</allocation-retry>
<allocation-retry-wait-millis>0</allocation-retry-wait-millis>
</timeout>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
<drivers>
<driver name="OracleJDBCDriver" module="oracle.jdbc"/>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
Error:
java.sql.SQLException: You cannot commit with autocommit set!
16:38:40,205 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection.jdbcCommit(BaseWrapperManagedConnection.java:1071)
16:38:40,206 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.jboss.jca.adapters.jdbc.WrappedConnection.commit(WrappedConnection.java:758)
16:38:40,206 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at com.client.Series.utiles.UserUtilesClass.checkUser(UserUtilesClass.java:370)
16:38:40,206 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at com.client.Series.form.LoginForm.validate(LoginForm.java:65)
16:38:40,206 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:942)
16:38:40,206 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
16:38:40,207 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
16:38:40,207 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
16:38:40,207 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
16:38:40,207 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
16:38:40,208 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
16:38:40,208 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
16:38:40,208 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
16:38:40,208 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
16:38:40,209 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
16:38:40,209 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
16:38:40,209 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
16:38:40,209 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
16:38:40,209 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
16:38:40,210 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
16:38:40,210 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
16:38:40,210 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:926)
16:38:40,211 ERROR [stderr] (http-/xxx.xx.xx.xx:8080-1) at java.lang.Thread.run(Unknown Source)
回答1:
I am afraid this is the only way of doing this: to set the autocommit option to false programatically when obtaining every connection. And the main reason for that is the JCA spec where the auto-commit mode of the Connection object participating in a transaction is set to off (false). That's why you can not change the auto-commit mode within the transaction.
来源:https://stackoverflow.com/questions/28670759/jboss-eap-workaround-default-setting-connection-autocommit-true