JPA not saving to DB on WildFly 16 - jpa

After migrating from Wildfly-8.2.0 to Wildfly-16.0.0, my JEE application launched normally and
displayed expected data read from (PostgreSql) database, but neither of the (insert/update/delete)
operations is saving to database (with no exception fired) !
I redeployed the same application on the old version of Wildfly and (insert/update/delete) operations worked.

What was missing is to add the "eclipselink.jar" file in
"wildfly\modules\system\layers\base\org\eclipse\persistence\main"
and reference it as a "resource-root" in
"wildfly\modules\system\layers\base\org\eclipse\persistence\main\module.xml"
Unfortunatelly, no exception was fired describing the missing configuration of eclipselink!

Related

Could not initialize class com.ibm.ws.ffdc.FFDCFilter. DSRA0010E: SQL State = 28P01, Error Code = 0

Can I get assistance with the error codes coming from eclipse when I try to deploy enterprise application on websphere. I followed craig st jean, I also face another problem with configuration i.e websphere data sources using postgresql. i am using a windows machine, 64bit arch. the error codes are the topic of this question. i hope this question can be seen as relevant, since not much solutions exist for the first issue concerning com.ibm.ws.ffdc.FFDCFilter, thus if one doesn't overcome the first, how can one press on and attempt to solve the second. thanks.
Webspere logs
The test connection operation failed for data source AppDb on server server1 at node Lenovo-PCNode01 with the following exception: java.sql.SQLException: FATAL: password authentication failed for user "listmanagerremote" DSRA0010E: SQL State = 28P01, Error Code = 0. View JVM logs for further details.
I have fixed the issues with deployment in the eclipse neon IDE. I think it is either as a result of the installation of the IBM WebSphere Application Server Traditional v8.0x Developer tools for Neon, and IBM jre.
Eclipse console final message
00000063 CompositionUn A WSVR0191I: Composition unit WebSphere:cuname=ListManager in BLA WebSphere:blaname=ListManager started.
Postgre documents the 28P01 SQL State as an invalid password:
"28P01 INVALID PASSWORD invalid_password"
https://www.postgresql.org/docs/9.0/static/errcodes-appendix.html
Check your data source configuration to ensure that you have specified the correct password, or if using an authentication alias for your data source, confirm that the authentication data configuration contains the correct password, and that you have configured the data source and/or resource reference to use that authentication data.

OrientDB and PostgreSQL JDBC drivers are clashing (InvocationTargetException): is there an OrientDB JAR with everything except JDBC?

My application uses both OrientDB and PostgreSQL databases for different purposes.
It seems they were able to coexist before, but today my code stopped working. Upon debugging, it seems that the OrientDB driver is attempting to connect to my PostgreSQL database when I'm expecting the PostgreSQL driver to connect instead.
Here is the sequence of events:
OrientDB connection is made (using OrientGraphFactory.setupPool()), transaction is started.
Connection attempt is made on PostgreSQL database, error occurs when trying to create the Connection object.
Here is the segment of code that creates the PostgreSQL connection:
Class.forName("org.postgresql.Driver");
Connection connection = DriverManager.getConnection(
"jdbc:postgresql://" + [...]);
return connection;
An InvocationTargetException is thrown at the DriverManager.getConnection() line. Here is the stack trace, clearly indicating that the OrientDB driver was the one trying to connect:
Error on opening database 'jdbc:postgresql://[hostname]/[db_name]'
com.orientechnologies.orient.core.exception.ODatabaseException: Error on opening database 'jdbc:postgresql://[hostname]/[db_name]'
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:204)
at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.<init>(ODatabaseDocumentTx.java:168)
at com.orientechnologies.orient.jdbc.OrientJdbcConnection.<init>(OrientJdbcConnection.java:62)
at com.orientechnologies.orient.jdbc.OrientJdbcDriver.connect(OrientJdbcDriver.java:52)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
Indeed it seems the JDBC drivers are clashing.
I don't actually need JDBC functionality with OrientDB in this case. However, I can't find the OrientDB JAR that doesn't contain JDBC. The home page lets you download JDBC-all or JDBC-only. Where can I find a JAR with all dependencies bundled into a single JAR, but without JDBC?
This is probably not caused by the drivers themselves but by the DriverManager getting "confused" which driver handles which URL.
You can bypass the DriverManager by asking the driver directly for a connection:
Driver drv = new org.postgresql.Driver();
Properties props = new Properties();
props.put("username", "foo_user");
props.put("password", "database_password");
Connection connection = drv.getConnection("jdbc:postgresql://dbhost/db_name", props);
Unrelated, but: Class.forName("org.postgresql.Driver"); is longer necessary with current Java and driver versions.
I solved the problem here:
https://github.com/orientechnologies/orientdb/commit/8e0f4bed41999cf68ae9de229b3ff6a4260813da
It was a misunderstanding on how the DriverManager registers drivers and then calls the getConnection method.
Solutions.
My suggestion is to not use the orientdb-jdbc-all jar at all. If you don't need to work with orient embedded in your app AND access to it via JDBC it is really too big.
Instead, use your dependency management framework (maven, gradle?) to import orient jars, maybe only the orientdb-client if you need to interact with a remote db, maybe more if you need to embed orient in your app.
If you need to interact to a remote Orient Server via JDBC, use only che orientdb-jdbc. But you need the fixed one, so you should build it from source, or wait for next 2.1.8 release.
If you want to stay with the jdbc fat jar, again you can build it from source right now, or you can wait next hotfix release (2.1.8).
hope this help,
best regards

springboot causing 2phase transaction commit when not needed

I have a standalone application A that invokes a webservice B deployed in jboss eap 6.2.3. the application in jboss uses a mysql datasource. This application integration is working very well.
I needed to webify the standalone application itself into a spring rest data jpa microservice
So I wrote a spring boot wrapper for that standalone application A. It runs in an embedded tomcat and invokes the aplpication B running in jboss.
I also ported some configurations logic from properties files into a embedded h2 database.
Now at places I am seeing this exception shown below for insert into the mysql by the application B inside jboss. My guess is what was a simple transaction earlier and working well has now become a 2 phase commit that sometimes fails.
How to prevent this?
Caused by: javax.transaction.RollbackException: ARJUNA016053: Could not commit transaction.
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1177)
at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:126)
at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
at org.jboss.as.ejb3.tx.CMTTxInterceptor.endTransaction(CMTTxInterceptor.java:92) [jboss-as-ejb3-7.3.3.Final-redhat-SNAPSHOT.jar:7.3.3.Final-redhat-SNAPSHOT]
... 67 more
Caused by: org.infinispan.CacheException: Could not prepare.
at org.infinispan.transaction.synchronization.SynchronizationAdapter.beforeCompletion(SynchronizationAdapter.java:70) [infinispan-core-5.2.7.Final-redhat-2.jar:5.2.7.Final-redhat-2]
at com.arjuna.ats.internal.jta.resources.arjunacore.SynchronizationImple.beforeCompletion(SynchronizationImple.java:76)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.beforeCompletion(TwoPhaseCoordinator.java:273)
at com.arjuna.ats.arjuna.coordinator.TwoPhaseCoordinator.end(TwoPhaseCoordinator.java:93)
at com.arjuna.ats.arjuna.AtomicAction.commit(AtomicAction.java:162)
at com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple.commitAndDisassociate(TransactionImple.java:1165)
... 70 more
Caused by: javax.transaction.xa.XAException
at org.infinispan.transaction.TransactionCoordinator.prepare(TransactionCoordinator.java:161) [infinispan-core-5.2.7.Final-redhat-2.jar:5.2.7.Final-redhat-2]
at org.infinispan.transaction.TransactionCoordinator.prepare(TransactionCoordinator.java:123) [infinispan-core-5.2.7.Final-redhat-2.jar:5.2.7.Final-redhat-2]
at org.infinispan.transaction.synchronization.SynchronizationAdapter.beforeCompletion(SynchronizationAdapter.java:68) [infinispan-core-5.2.7.Final-redhat-2.jar:5.2.7.Final-redhat-2]
... 75 more
Spring Boot has out-of-the-box support for JTA. When it runs in an environment where a JTA transaction manager is available, it uses that rather than creating a local transaction manager for your data store. If that's not what you want, you can disable jta support by adding spring.jta.enabled=false to your configuration.
Thanks for the answer.Will be useful in some scenarios.
However after posting I realised the flaw in the question.
standalone application A
webified application(even if a microservice runninging embeddedtomcat ) say A1
Both are actually just rest clients to rest services running in a webservice B deployed in jboss eap 6.2.3..
A and A1 might as well be replaced by just a simple human visitor visting from a browser the application B.
I dont think A or A1 can influence the transactions in any ways for B.
Right?
Anyways the problem was due to the closeness to B of the application A1.
The actual problem was related to a cluster event for the cluster in which B was deployed and triggering of it by A1. A bit complicated scenario. The only problem was that the insert was being attempted too soon before the cluster change event could even reach.

WebSphere 7.0 remote client rollback global UserTransaction

I'm observing weird behavior for WebSphere 7.0.0.21:
Architecture:
Simple EJB bean with annotation #Local, #Remote Interfaces and transactional method marked as #Required
Standalone command line client that looks up remote "jta/usertransaction" and transactional EJB method. Client code starts user transaction, executes method and then tries to rollback it.
Expected behavior: (I see it on Jboss) rollback of DB transaction
Observed behavior: (On WAS 7.0.0.21) commit of DB transaction
I see that client transaction is changing from STATUS_NO_TRANSACTION(6) to STATUS_ACTIVE(0) and then again to STATUS_NO_TRANSACTION(6) after rollback.
I tried to Google it but didn't find any results
Any ideas on this scenario ? I'm pretty much ready to file the issue to IBM.
thanks,
UPDATE:
Finally after long wait and interactions with IBM support I got it resolved:
No problems with IBM JRE
For Sun/Oracle JRE it requires extra configuration for ORB e.g.
jndiProperties.put("java.naming.corba.orb", com.ibm.CORBA.iiop.ORB.init((String[])null, orbProperties));
and orb.properties from WAS or AppClient JRE is required to be provided as "orbProperties"

How to install Drools Dashbuilder MySQL?

I have installed successfully Drools KIE-WB with MYSQL (in Tomcat), and I want to achieve the same goal with the dashbuilder.
My dashbuilder package is jbpm-dashbuilder-6.1.0-SNAPSHOT-tomcat-7. And I have tested two different options:
The first tested option is:
Executing the file in tomcat-7.0.50\webapps\dashbuilder\WEB-INF\etc\sql\1-create-mysql.sql. It creates some tables, but seems that something is missed, because this error appears when starting the server:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'dashboarddb.processinstancelog' doesn't exist
The second tested option is:
Change tomcat-7.0.50\webapps\dashbuilder\META-INF\context.xml to have the next datasource
<Resource name="jdbc/jbpm" auth="Container"
type="javax.sql.DataSource" username="drools-user" password="pass" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/dashboarddb?useUnicode=true&characterEncoding=UTF8"
maxActive="8"
/>
And in tomcat-7.0.50\webapps\dashbuilder\WEB-INF\etc\hibernate.cfg.xml I have added the next line:
<property name="hibernate.hbm2ddl.auto">update</property>
To force Hibernate to create all tables in MySQL. This almost work (create several tables) but an error appears:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '1-title-Dashboards Showcase' for key 'PRIMARY'
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
...
And I have no idea how to fix it (because I have no information about what Hibernate is doing and creating).
I have no more ideas of how to install the dashboard using MySQL. Any clue about how to achieve it?
The two webapps (Kie-wb and jBPM dashboard) must share the same database since the jBPM dashboard feeds from the jBPM history-log (more details here https://github.com/droolsjbpm/jbpm-dashboard/tree/master/jbpm-dashboard-distributions/src/main/tomcat7).
So you first need to deploy and run kie-wb against a given data source. Let's say you named it "kie-wb". Once you have kie-wb running (tables created on DB) you can proceed deploying jbpm-dashboard, which must be configured to connect against the same "kie-wb" datasource.
DON'T enable auto ddl update as it's not recommended in production. You can either run the script 1-create-mysql.sql prior to the app. deployment or just let the app run it on start up (auto running the script it's actually done by the app itself if it doesn't detect some required tables).
If you follow the steps above everything should be working fine.
Otherwise, don't hesitate to ask again.