HQSLDB -- File-Based Database Empty Even Though Files Have Content? Why? - spring

Folks,
My Issue
Why is an HSQLDB file-based database I have pre-populated with a schema and data not populated when I connect to it later?
I think I'm missing some small, but HUGELY IMPORTANT configuration.
My Environment
HSQLDB setup with the Maven Sql plugin and Maven Liquibase plugin.
Spring / Hibernate Webapp
Steps to Populate the Database and Run the App
Run the Sql Maven plugin to create 3 schemas in the HSQL database
Run the Maven liquibase plugin, populating with ddl and lookup data
The jdbc url I'm using within Maven to setup hsql is: jdbc:hsqldb:file:${project.basedir}/target/db/build;shutdown=true.
It translates to: jdbc:hsqldb:file:/Users/myHomeDir/work/myProj/target/db/build;shutdown=true
I have confirmed the the hsql database files are created and populated -- insert statements in the build.script file are present as expected. I can connect to the database using RazorSQL and see the data and tables present.
Running the App
I've configured my DataSource in my Spring config as follows:
<bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver" />
<property name="url" value="jdbc:hsqldb:file:/Users/myHomeDir/work/myProj/target/db/build;shutdown=true" />
<property name="username" value="sa" />
<property name="password" value="" />
I've fired up the app and see that Hibernate/Spring makes the connection to the database. A database.lck file is created so I know the app has made a connection. (Also, I've ensured that RazorSQL is shutdown and not using the database at the same time).
The Error
The error indicates that the database entities don't exist:
[INFO] Started Jetty Server
Hibernate:
select
this_.id as id5_2_,
this_.created_date as created2_5_2_,
this_.creating_user_id as creating3_5_2_,
this_.email as email5_2_,
this_.first_name as first5_5_2_,
this_.is_enabled as is6_5_2_,
this_.last_login_date as last7_5_2_,
this_.last_modified_date as last8_5_2_,
this_.last_modifying_user_id as last9_5_2_,
this_.last_name as last10_5_2_,
this_.login as login5_2_,
this_.middle_initial as middle12_5_2_,
this_.password_hash as password13_5_2_,
this_.password_history as password14_5_2_,
this_.suffix as suffix5_2_,
roles2_.user_id as user1_5_4_,
role3_.id as role2_4_,
role3_.id as id3_0_,
role3_.code as code3_0_,
role3_.description as descript3_3_0_,
role3_.name as name3_0_,
role3_.type_id as type5_3_0_,
roletype4_.id as id4_1_,
roletype4_.description as descript2_4_1_
from
security.user this_
left outer join
security.user_role roles2_
on this_.id=roles2_.user_id
left outer join
security.role role3_
on roles2_.role_id=role3_.id
left outer join
security.role_type roletype4_
on role3_.type_id=roletype4_.id
where
this_.login=?
[01/20/2012 17:30:18,440] WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: -5501, SQLState: 42501
[01/20/2012 17:30:18,440] ERROR: org.hibernate.util.JDBCExceptionReporter - user lacks privilege or object not found: USER
2012-01-20 17:30:18.443:WARN::/my-webapp/j_spring_security_check
org.hibernate.exception.SQLGrammarException: could not execute query

Just to make sure, can't it be caused by conflict of table name (USER) with SQL keyword?
Try to use different table name instead, or at least configure Hibernate to escape it (#Table(name = "\"user\"")).

Related

SonarCloud: Getting error when running ant and sonar connecting to sonar cloud

We have a setup where we use SonarQube with Ant and connect to SonarCloud (https://sonarcloud.io). This setup was always working from local developer machine and also from bitbucket pipelines. Since two days, we have been getting below error on local and bitbucket pipelines. Below is the stacktrace:
Project.sonar:
[sonar:sonar] Apache Ant(TM) version 1.10.5 compiled on July 10 2018
[sonar:sonar] SonarQube Ant Task version: 2.5
[sonar:sonar] Loaded from: file:<redacted_path>/sonarqube-ant-task-2.5.jar
[sonar:sonar] User cache: /Users/<user>/.sonar/cache
BUILD FAILED
<redacted_path>/build-sonar.xml:120: java.lang.IllegalStateException: not started
at org.sonarsource.scanner.api.EmbeddedScanner.checkLauncherExists(EmbeddedScanner.java:244)
at org.sonarsource.scanner.api.EmbeddedScanner.stop(EmbeddedScanner.java:164)
at org.sonarsource.scanner.ant.SonarQubeTask.launchAnalysis(SonarQubeTask.java:101)
at org.sonarsource.scanner.ant.SonarQubeTask.execute(SonarQubeTask.java:81)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
at org.apache.tools.ant.Task.perform(Task.java:350)
at org.apache.tools.ant.Target.execute(Target.java:449)
at org.apache.tools.ant.Target.performTasks(Target.java:470)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:834)
at org.apache.tools.ant.Main.startAnt(Main.java:223)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
Below is the command that we use for running sonar:
ant compile Project.sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.organization=<org_name> -Dsonar.login=<token_which_has_all_privs>
We have tried changing the sonar.login token with a new one (thinking that old might have expired) but it didn't work with new one also.
I am not able to find any help anywhere else regarding this error since it does not say much. I see other errors like "WebApp did not start" but that seems to be related to the use case where SonarQube is running on local. But in our case we are connecting to https://sonarcloud.io host. We have also tried with sonar.login and sonar.password and it still fails.
Any help would be appreciated.
Update 1 for mc1arke question Is this sufficient? I can create a new basic build-sonar.xml and provide it but it will only have below content and some properties/variables specific for our environment.
Extract from build-sonar.xml looks as below:
<taskdef uri="antlib:org.sonar.ant" resource="org/sonar/ant/antlib.xml">
<classpath>
<pathelement location="${lib.dir}/sonarqube-ant-task-2.5.jar"/>
</classpath>
</taskdef>
<target name="Project.sonar">
<property name="sonar.projectKey" value="ProjectKey" />
<property name="sonar.projectName" value="ProjectName" />
<property name="sonar.projectVersion" value="1.0" />
<property name="sonar.sources" value="${src.dir}" />
<property name="sonar.binaries" value="${build.dir}" />
<property name="sonar.java.binaries" value="${build.dir}" />
<property name="sonar.java.libraries" value="${lib.dir}/*.jar"/>
<property name="sonar.java.test.libraries" value="${lib.dir}/*.jar"/>
<property name="sonar.java.source" value="1.8" />
<property name="sonar.exclusions" value="<some modules>"/>
<property name="sonar.jacoco.reportPath" value="${junit.reports}/coverage/jacoco.exec"/>
<property name="sonar.junit.reportsPath" value="${junit.reports}" />
<property name="sonar.jacoco.itReportPath" value="${junit.reports}/coverage/jacoco-it.exec"/>
<property name="sonar.coverage.exclusions" value="<some modules>"/>
<sonar:sonar/>
</target>
Update 2: I looked at the sonar code in EmbeddedScanner.java, IsolatedLauncherFactory.java, and IsolatedLauncherProxy.java which actually should be throwing the error. I also ran the ant command in -v mode and below is the output of it:
Project.sonar:
[antlib:org.sonar.ant] Could not load definitions from resource org/sonar/ant/antlib.xml. It could not be found.
[sonar:sonar] Apache Ant(TM) version 1.10.5 compiled on July 10 2018
[sonar:sonar] SonarQube Ant Task version: 2.5
[sonar:sonar] Loaded from: file:<redacted_path>/sonarqube-ant-task-2.5.jar
[sonar:sonar] keyStore is :
[sonar:sonar] keyStore type is : jks
[sonar:sonar] keyStore provider is :
[sonar:sonar] init keystore
[sonar:sonar] init keymanager of type SunX509
[sonar:sonar] User cache: /Users/<user.name>/.sonar/cache
[sonar:sonar] Extract sonar-scanner-api-batch in temp...
[sonar:sonar] Get bootstrap index...
[sonar:sonar] Download: https://sonarcloud.io/batch_bootstrap/index
[sonar:sonar] Get bootstrap completed
So looking at the code and its output I think below is the code flow:
EmbeddedScanner.checkLauncherExists() --> IsolatedLauncherFactory.createLauncher() --> JarDownloader.download() --> JarDownloader.getScannerEngineFiles() --> BootstrapIndexDownloader.getIndex()
From the log, it seems that the index was returned successfully. But either the JarDownloader.getScannerEngineFiles() or JarDownloader.download() failed because the log statement logger.debug("Create isolated classloader..."); right after List<File> jarFiles = jarDownloader.download() in IsolatedLauncherFactory.createLauncher() is not printed.
Reference: Sonar source code available here
Your issue is that sonar-ant-plugin does not seem to support SonarCloud. The plugin depends on an old version of sonar-scanner-api which attempts to retrieve a list of Jars to download by retrieving /batch_bootstrap/index from the remote SonarQube server. SonarCloud doesn't provide such a URL, but does have /bootstrap/index which newer versions of sonar-scanner-api do use.
Update: version 2.6.0.1426 of the scanner for Ant has been released to fix the issue.

Hibernate/c3pO doesn't work under Tomcat - Windows 10: apparent deadlock

My app uses Hibernate and c3po, and isn't starting under windows 10 + eclipse Oxygen + Tomcat 8, while under Linux works fine with the same configuration.
These are some lines the console shows when starting Tomcat
2017/11/27 18:21:03 WARN com.mchange.v2.async.ThreadPoolAsynchronousRunner - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector#15cc07ce -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
This should a connection problem as reported here .
This seems confirmed by an exception I get:
2017/11/27 18:21:14 WARN com.mchange.v2.resourcepool.BasicResourcePool - com.mchange.v2.resourcepool.BasicResourcePool$AcquireTask#1e723184 -- Acquisition Attempt Failed!!! Clearing pending acquires. While trying to acquire a needed new resource, we failed to succeed more than the maximum number of allowed acquisition attempts (30). Last acquisition attempt exception:
org.postgresql.util.PSQLException: FATALE: the remaining connection slots are reserveed to non replica superusers connections
at org.postgresql.core.v3.ConnectionFactoryImpl.readStartupMessages(ConnectionFactoryImpl.java:469)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:112)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:66)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:125)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:30)
at org.postgresql.jdbc4.Jdbc4Connection.<init>(Jdbc4Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:393)
From postgresql log I see there are many connection until the db says it cannot allocate more. The connections are far above 10, while I have this in my hibernate.cfg.xml
<property name="hibernate.c3p0.min_size">1</property>
<property name="hibernate.c3p0.max_size">3</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
psql -h localhost -U user db works fine
I used Wireshark and RawCap under Windows to capture the connections and it seems the connections are acquired, as the log says, but after seeing Postgres saying "ready for queries", they are closed, if I saw well.
What else can I look at to debug what's happening??
It turned out that I was using the wrong postgresql driver. I have java 8, and using PostgreSQL JDBC 4.2 Driver, 42.1.4 solved the issue.

Tomcat cannot create TCPS Oracle JDBC connection

I'm using database connection through JDBC in tomcat.
Our environment is Tomcat 7 + JDK 8 and Oracle 12c.
As I can only connect to Oracle database through TCPS (and which we are using Oracle's wallet), so I have to modify my current Tomcat server.xml to create JDBC connection to Oracle.
My updated configuration snippet
<Resource auth="Container" driverClassName="oracle.jdbc.driver.OracleDriver"
initialSize="10"
jdbcInterceptors="org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReportJmx(threshold=10000)"
jmxEnabled="true" logAbandoned="true" maxActive="100" maxIdle="100"
maxWait="10000"
name="jdbc/jndiconnection" password="XXXXXX" removeAbandoned="true"
type="javax.sql.DataSource" url=""jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=hostname)(PORT=1234))(CONNECT_DATA=(SERVICE_NAME=servicename)))"
username="XXXXXXXX" validationInterval="30000" validationQuery="SELECT 1 FROM DUAL" />
I added truststore/trusttypey/keystore/keytype as parameters,however I got error:
Caused by: oracle.net.ns.NetException: Unable to initialize ssl context.
at oracle.net.nt.CustomSSLSocketFactory.getSSLSocketFactory(CustomSSLSocketFactory.java:296)
at oracle.net.nt.TcpsNTAdapter.connect(TcpsNTAdapter.java:117)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:370)
... 73 more
Caused by: oracle.net.ns.NetException: Unable to initialize the key store.
at oracle.net.nt.CustomSSLSocketFactory.getKeyManagerArray(CustomSSLSocketFactory.java:369)
at oracle.net.nt.CustomSSLSocketFactory.getSSLSocketFactory(CustomSSLSocketFactory.java:279)
... 76 more
Caused by: java.security.KeyStoreException: SSO not found
at java.security.KeyStore.getInstance(KeyStore.java:851)
at oracle.net.nt.CustomSSLSocketFactory.getKeyManagerArray(CustomSSLSocketFactory.java:357)
... 77 more
Caused by: java.security.NoSuchAlgorithmException: SSO KeyStore not available
at sun.security.jca.GetInstance.getInstance(GetInstance.java:159)
at java.security.Security.getImpl(Security.java:695)
at java.security.KeyStore.getInstance(KeyStore.java:848)
... 78 more
Then I followed the instruction from : https://sysapp.wordpress.com/2010/08/31/how-to-oracle-wallet-with-jdbc-thin-driver-datasource-tomcat/
However in the article it is using PROTOCAL as TCP but not TCPS.
<Resource
name="jdbc/confluence"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:/#mywallet"
connectionProperties=”oracle.net.wallet_location=/opt/wallet"/>
Then I got error:
Caused by: oracle.net.ns.NetException: The method specified in wallet_location is not supported. Location: /opt/wallet
at oracle.net.nt.CustomSSLSocketFactory.getSSLSocketFactory(CustomSSLSocketFactory.java:219)
at oracle.net.nt.TcpsNTAdapter.connect(TcpsNTAdapter.java:117)
at oracle.net.nt.ConnOption.connect(ConnOption.java:133)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:370)
... 73 more
I have written Java sample code to connect through TCPS and the connection works fine.
Did I missed some key points in the configuration file? And is there any other way to create Oracle's TCPS connection through JDBC?
”oracle.net.wallet_location=/opt/wallet"
That's not what the property is supposed to be. It is supposed to be :
(SOURCE=(METHOD=file)(METHOD_DATA=(DIRECTORY=/opt/wallet)))
The error message you get is because it cannot find a "METHOD=" in the one you provided.
There are a few steps that you need to follow.
(1) Make sure you have oraclepki.jar, osdt_core.jar, osdt_cert.jar in the classpath
(2) Also, specify the location of cwallet.sso file through the following system property. You can create a setenv.sh and add required system properties.
Also, enable another system property as shown here.
export JAVA_OPTS="$CATALINA_OPTS -Doracle.net.wallet_location='(SOURCE=(METHOD=file)(METHOD_DATA=(DIRECTORY=/test/wallet/)))'"
export JAVA_OPTS="$CATALINA_OPTS -Doracle.net.ssl_server_dn_match=true"
(3) Make sure you have the certificate information in the URL as shown here.
Please copy the 'security' part of the URL from your certificate.
(description=
(address=(protocol=tcps)(port=1522)(host=myorclhostname))
(connect_data=(service_name=myorcldb))
(security=(ssl_server_cert_dn=
"CN=CMAN, O=Oracle Database , C=US"))
)
(4) You need to activate oracle PKI provider. To statically enable it:
Change java.security file of JRE (JRE_HOME/jre/lib/security/java.security):
security.provider.7=oracle.security.pki.OraclePKIProvider
Refer to "SSL with JDBC driver" for more details.

OpenAM with OpenDJ - NameNotFoundException: ldap/idp/userDN - when starting up JBoss

I'm using OpenAM, with its embedded OpenDJ as the LDAP service, to protect my web application running on JBoss 7.
When I start my JBoss I get this error:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ldapUserDN'
...
Caused by: javax.naming.NameNotFoundException: ldap/idp/userDN -- service jboss.naming.context.java.ldap.idp.userDN
So apparently Spring is looking for the JNDI node ldap/idp/userDN. But the jboss configuration file that I got with the project has these entries:
<simple name="ldap/opendj/url" value="ldap://localhost:50389"/>
<simple name="ldap/opendj/userDN" value="cn=Directory Manager"/>
<simple name="ldap/opendj/password" value="mypassword"/>
<simple name="ldap/opendj/baseDN" value="dc=opensso,dc=java,dc=net"/>
And these properties are added to my JNDI tree on JBoss.
If I change these to "ldap/idp/userDN", for instance, then I get rid of the error, but I was wondering if there's anywhere, where "ldap/opendj/userDN" should be mapped to "ldap/idp/userDN", that I've missed.
If you're using Spring LDAP, the actual configuration of the ldap-context-source goes in the a spring config file, and might look like this:
<jee:jndi-lookup jndi-name="ldap/idp/url" id="ldapUrl"/>
<jee:jndi-lookup jndi-name="ldap/idp/userDN" id="ldapUserDN"/>
<jee:jndi-lookup jndi-name="ldap/idp/password" id="ldapPassword"/>
<jee:jndi-lookup jndi-name="ldap/idp/baseDN" id="ldapBaseDN"/>
<ldap:context-source url="#{ldapUrl}"
username="#{ldapUserDN}"
password="#{ldapPassword}"
base="#{ldapBaseDN}"
native-pooling="true"/>
So the jndi entries in your jboss config file should match the ones above.

Spring transaction/entity manager don't compensate for stale connections (on websphere + openJPA)?

The goal is to have a J2EE application running on a WebsphereApplicationServer 7, which accesses a JDBC datasource (DB2) via OpenJPA 2.0. On most of our testservers, my code is working fine; however, we have one testserver where the EntityManager aborts / does not get initialized properly because of a stale connection ("java.net.SocketException: Broken pipe"):
<openjpa-2.1.2-SNAPSHOT-r422266:1384519 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: Failed to execute query "select count(x.profSurname) from Surname x where x.profUsrstate = 0". Check the query syntax for correctness. See nested exception for details.
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:872)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:794)
at org.apache.openjpa.kernel.DelegatingQuery.execute(DelegatingQuery.java:542)
at org.apache.openjpa.persistence.QueryImpl.execute(QueryImpl.java:315)
at org.apache.openjpa.persistence.QueryImpl.getResultList(QueryImpl.java:331)
at org.apache.openjpa.persistence.QueryImpl.getSingleResult(QueryImpl.java:359)
(...)
Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException: [jcc][t4][2030][11211][4.13.127] A communication error occurred during operations on the connection's underlying socket, socket input stream,
or socket output stream. Error location: T4Agent.sendRequest() - flush (-1). Message: Broken pipe. ERRORCODE=-4499, SQLSTATE=08001 {prepstmnt 1826931080 SELECT COUNT(t0.PROF_SURNAME) FROM EMPINST.SURNAME t0 WHERE (t0.PROF_USRSTATE = CAST(? AS BIGINT)) optimize for 1 row [params=?]} [code=-4499, state=08001]
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:281)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:265)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.access$700(LoggingConnectionDecorator.java:72)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:1183)
at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:284)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1787)
at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:274)
at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:499)
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:424)
at com.ibm.ws.persistence.jdbc.sql.SelectImpl.execute(SelectImpl.java:89)
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:391)
at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:427)
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230)
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220)
at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94)
at org.apache.openjpa.kernel.QueryImpl$PackingResultObjectProvider.open(QueryImpl.java:2070)
at org.apache.openjpa.kernel.QueryImpl.singleResult(QueryImpl.java:1320)
at org.apache.openjpa.kernel.QueryImpl.toResult(QueryImpl.java:1242)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:1007)
at org.apache.openjpa.kernel.QueryImpl.execute(QueryImpl.java:863)
... 113 more
---- Begin backtrace for Nested Throwables
com.ibm.websphere.ce.cm.StaleConnectionException: [jcc][t4][2030][11211][4.13.127] A communication error occurred during operations on the connection's underlying socket, socket input stream,
or socket output stream. Error location: T4Agent.sendRequest() - flush (-1). Message: Broken pipe. ERRORCODE=-4499, SQLSTATE=08001
at sun.reflect.GeneratedConstructorAccessor91.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
at java.lang.reflect.Constructor.newInstance(Constructor.java:527)
at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapExceptionHelper(GenericDataStoreHelper.java:607)
at com.ibm.websphere.rsadapter.GenericDataStoreHelper.mapException(GenericDataStoreHelper.java:666)
at com.ibm.ws.rsadapter.AdapterUtil.mapException(AdapterUtil.java:2271)
at com.ibm.ws.rsadapter.jdbc.WSJdbcUtil.mapException(WSJdbcUtil.java:1185)
at com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeQuery(WSJdbcPreparedStatement.java:726)
at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:286)
at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeQuery(LoggingConnectionDecorator.java:1181)
at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:284)
at org.apache.openjpa.jdbc.kernel.JDBCStoreManager$CancelPreparedStatement.executeQuery(JDBCStoreManager.java:1787)
at org.apache.openjpa.lib.jdbc.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:274)
at org.apache.openjpa.jdbc.sql.SelectImpl.executeQuery(SelectImpl.java:499)
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:424)
at com.ibm.ws.persistence.jdbc.sql.SelectImpl.execute(SelectImpl.java:89)
at org.apache.openjpa.jdbc.sql.SelectImpl.execute(SelectImpl.java:391)
at org.apache.openjpa.jdbc.sql.LogicalUnion$UnionSelect.execute(LogicalUnion.java:427)
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:230)
at org.apache.openjpa.jdbc.sql.LogicalUnion.execute(LogicalUnion.java:220)
at org.apache.openjpa.jdbc.kernel.SelectResultObjectProvider.open(SelectResultObjectProvider.java:94)
(...)
Caused by: java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:103)
at java.net.SocketOutputStream.write(SocketOutputStream.java:147)
at com.ibm.db2.jcc.t4.fb.b(fb.java:1685)
at com.ibm.db2.jcc.t4.fb.a(fb.java:1633)
at com.ibm.db2.jcc.t4.a.D(a.java:421)
... 138 more
I am working with OpenJPA using the Springframework 3.0 JpaTransactionManager and LocalContainerEntityManagerFactory to get my persistence context:
<tx:annotation-driven transaction-manager="lctxManager" />
<bean id="lctxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="lcentityManagerFactory"></property>
</bean>
<bean id="lcentityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="activities"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
<property name="showSql" value="false"></property>
</bean>
</property>
</bean>
The persistence.xml is as follows:
<persistence-unit name="activities" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>jdbc/activities</non-jta-data-source>
<!-- My classes -->
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="openjpa.TransactionMode" value="local" />
</properties>
I need to restart the server on which the application runs for the Exception to vanish again -- before it (randomly?) pops up again.
On googling the problem, I found a site that mentioned it was faulty code (no commit on transactions) that causes the problem: http://mikeschubert.com/2006/08/03/javanetsocketex/
However, I am under the impression that the JPATransactionManager is supposed to take care of that.
Other websites mentioned that implementing a connection pool would help (when using Hibernate in communication with a Tomcat-server, e.g. elegantly handling stale database connections in Hibernate/Spring Transactions); however, the Websphere Application Server already manages a connections pool for the jdbc/activities datasource (minSize: 1; maxSize: 10; Connection timeout: 180 sec; Reap time: 180sec; Unused timeout: 1800 sec, Purge policy: FailingConnectionOnly).
Any hints on where I should start looking into the problem would be great.
There is a possibility that if you don't set DB2COMM registry variable then communication error might happen.
DB2COMM should be set to TCPIP.

Resources