I get a NullPointerException on the console of my tomcat at my first connection to the database with createEntityManager(). I am using:
apache tomcat 8.0.24
eclipselink 2.6.1-RC1 (indirectly used by JPA)
sqlite jdbc 3.8.10.1
The log message is the following:
[EL Warning]: connection: 2015-08-21 16:01:51.569--java.lang.NullPointerException
[EL Info]: 2015-08-21 16:01:51.585--ServerSession(29156874)--EclipseLink, version: Eclipse Persistence Services - 2.6.1.v20150605-31e8258
[EL Info]: connection: 2015-08-21 16:01:52.365--Not able to detect platform for vendor name [SQLite33.8.10.1]. Defaulting to [org.eclipse.persistence.platform.database.DatabasePlatform]. The database dialect used may not match with the database you are using. Please explicitly provide a platform using property "eclipselink.target-database".
[EL Info]: connection: 2015-08-21 16:01:52.505--ServerSession(29156874)--/file:/C:/eclipse_ee/workspaces/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jeejpa/WEB-INF/classes/_training-jpa login successful
My application seems to work fine - do I have to care about the warning about the NullPointerException? Or do I have to care about the info?
Not able to detect platform for vendor name [SQLite33.8.10.1].
Defaulting to [org.eclipse.persistence.platform.database.DatabasePlatform].
The database dialect used may not match with the database you are using.
Please explicitly provide a platform using property "eclipselink.target-database".
EDIT:
Thanks to help of #baumato and the setting <property name="eclipselink.target-database" value="Database" />the info about Not able to detect... doesn't show up any more. The detailed NullPointerException now is:
[EL Finest]: jpa: 2015-08-21 16:44:52.954--ServerSession(12993102)--Thread(Thread[http-nio-8443-exec-6,5,main])--Begin deploying Persistence Unit training-jpa; session /file:/C:/eclipse_ee/workspaces/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/jeejpa/WEB-INF/classes/_training-jpa; state Predeployed; factoryCount 1
[EL Finest]: jpa: 2015-08-21 16:44:52.964--ServerSession(12993102)--Thread(Thread[http-nio-8443-exec-6,5,main])--Bean Validation Factory was not initialized: [javax/validation/Validation].
[EL Warning]: connection: 2015-08-21 16:44:52.974--Thread(Thread[http-nio-8443-exec-6,5,main])--java.lang.NullPointerException
at org.eclipse.persistence.platform.server.ServerPlatformUtils.createServerPlatform(ServerPlatformUtils.java:99)
at org.eclipse.persistence.sessions.factories.SessionManager.init(SessionManager.java:77)
at org.eclipse.persistence.sessions.factories.SessionManager.<clinit>(SessionManager.java:71)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.addSessionToGlobalSessionManager(EntityManagerSetupImpl.java:907)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.initSession(EntityManagerSetupImpl.java:2671)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:675)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:205)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:305)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:337)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:303)
at de.training.beans.LoginBean.login(LoginBean.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.el.parser.AstValue.invoke(AstValue.java:247)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:654)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at de.training.filter.URILoggerFilter.doFilter(URILoggerFilter.java:24)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at de.training.filter.LoginFilter.doFilter(LoginFilter.java:38)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1527)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1484)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
[EL Finer]: 2015-08-21 16:44:52.974--Thread(Thread[http-nio-8443-exec-6,5,main])--initializing session manager
This exception is not about database platform but about application server platform. It's not fatal.
SessionManager#init() method does following:
String platformClass
= ServerPlatformUtils.detectServerPlatform(null);
try {
detectedPlatform
= ServerPlatformUtils.createServerPlatform(
null, platformClass,
SessionManager.class.getClassLoader());
} catch (NullPointerException npe) {
//some platforms may not be handling 'null' session well,
//so be defensive here and only log throwable here
detectedPlatform = null;
LOG.logThrowable(SessionLog.WARNING,
AbstractSessionLog.CONNECTION, npe);
}
So null is used as detected server platform and EclipseLink will consider that current application server platform does not have multitenancy support (which Apache Tomcat does not have).
This code in SessionManager is related to new WebLogic feature and you may simply ignore it.
2.7.0 throws ServerPlatformException instead of NPE but this change was not bacported to 2.6.1.
If you guys would like to add Apache Tomcat platform detection, please open enhancement request on Eclipselink Bugzilla and vote for it to give it a priority.
I would suggest to add following properties in the properties section of your persistence.xml to get detailed debug information:
<property name="eclipselink.logging.level" value="ALL" />
<property name="eclipselink.logging.level.sql" value="FINE"/>
<property name="eclipselink.logging.parameters" value="true" />
<property name="eclipselink.logging.connection" value="true" />
<property name="eclipselink.logging.session" value="true" />
<property name="eclipselink.logging.thread" value="true" />
<property name="eclipselink.logging.timestamp" value="true" />
And as the info message states, try to set the property:
<property name="eclipselink.target-database" value="Auto" />
Since "Auto" is the default, this might not help. So set the target-database to "Database". This uses a generic database, if your target database is not listed and your JDBC driver does not support the metadata required for Auto. See more at: http://www.eclipse.org/eclipselink/documentation/2.4/jpa/extensions/p_target_database.htm#sthash.y1lrDjUn.dpuf)
<property name="eclipselink.target-database" value="Database" />
Related
I'm using Knowage and have setup a data source, many parameterized datasets, and a cockpit.
I have a detailed report that requires many datasets.
The cockpit started freezing and I have to restart the Knowage server to get it to respond.
I split the report into different pages, and it seemed to help because it only loads some of the data at a time.
But now I added another dataset [14 total] and the server crashed again.
I'm monitoring the server through a jmx agent to understand why it's hanging, but the utilization seems fine.
Tomcat just hangs and never responds.
It appears the servlet has stopped processing requests, but I don't see any errors in the logs that look fatal.
The heap utilization is not bad, but does look anomalous.
Top output -
Errors in log -
[http-nio-8080-exec-17] 09 Mar 2021 15:46:49,390 ERROR it.eng.spagobi.api.v3.DataSetMainDTO.isGeoDataSet:51 - Error during check of Geo spatial column
com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: (String)"<?xml version="1.0" encoding="UTF-8"?>
<META version="1">
<COLUMNLIST>
<COLUMN alias="label" fieldType="ATTRIBUTE" multivalue="false" name="label" type="java.lang.String"/>
<COLUMN alias="amount" fieldType="MEASURE" multivalue="false" name="amount" type="java.math.BigDecimal"/>
</COLUMNLIST>
<DATASET>
<PROPERTY name="resultNumber" value="2"/>
</DATASET>
</META>
"; line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1798)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:663)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:561)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1892)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:747)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4129)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3988)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2992)
at it.eng.spagobi.utilities.json.JSONUtils.toJSONObject(JSONUtils.java:98)
at it.eng.spagobi.analiticalmodel.execution.service.ExecuteAdHocUtility.hasGeoHierarchy(ExecuteAdHocUtility.java:128)
.......
[http-nio-8080-exec-9] 09 Mar 2021 15:50:48,509 ERROR it.eng.spagobi.rest.interceptors.RestExceptionMapper.toResponse:59 - Catched service error:
javax.ws.rs.NotSupportedException: RESTEASY003065: Cannot consume content type
at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:403)
at org.jboss.resteasy.core.registry.SegmentNode.match(SegmentNode.java:137)
at org.jboss.resteasy.core.registry.RootNode.match(RootNode.java:43)
at org.jboss.resteasy.core.registry.RootClassNode.match(RootClassNode.java:48)
at org.jboss.resteasy.core.ResourceMethodRegistry.getResourceInvoker(ResourceMethodRegistry.java:445)
at org.jboss.resteasy.core.SynchronousDispatcher.getInvoker(SynchronousDispatcher.java:260)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:197)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:228)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at sun.reflect.GeneratedMethodAccessor973.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:282)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:279)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:549)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:314)
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:170)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:225)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:47)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:149)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:145)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at sun.reflect.GeneratedMethodAccessor977.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:282)
at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:279)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject.java:549)
at org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:314)
at org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:253)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:191)
at org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:47)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:149)
at org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:145)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:144)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
....
I believe the issue was caused by the limit of DB connections, and max wait in server.xml.
I noticed an error about attributes in the jndi configuration, and updated them.
The freezing has not occurred again, yet.
<!-- KNOWAGE -->
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxTotal="20" maxIdle="10"
maxWaitMillis="-1" name="jdbc/knowage" type="javax.sql.DataSource"
url="jdbc:mysql://localhost:3306/knowagedb" username="knowageuser" password="knowagepassword" />
<!-- KNOWAGE CACHE -->
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" maxTotal="20" maxIdle="4"
maxWaitMillis="30000" name="jdbc/ds_cache" type="javax.sql.DataSource"
url="jdbc:mariadb://localhost:3310/cache" username="root" password="root" />
I've made these changes, along with jmx export to prometheus, and a few memory tweaks to make knowage run better on kubernetes.
Have a look here -
https://github.com/savantly-net/knowage-docker
I am developing JavaEE 8 app with GlassFish 5.0.0 and I want to access database that resides in Microsoft SQL server. I attached Microsoft SQL driver 7.0 jre8 in Maven.
When I deploy the app and try to open a page which accesses the database, I got a crash. StackTrace below.
java.lang.NoSuchMethodError: sun.security.internal.spec.TlsMasterSecretParameterSpec.getExtendedMasterSecretSessionHash()[B
at com.sun.crypto.provider.TlsMasterSecretGenerator.engineGenerateKey(TlsMasterSecretGenerator.java:107)
at javax.crypto.KeyGenerator.generateKey(KeyGenerator.java:546)
at sun.security.ssl.Handshaker.calculateMasterSecret(Handshaker.java:1174)
at sun.security.ssl.Handshaker.calculateKeys(Handshaker.java:1120)
at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1126)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:351)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:984)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:919)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1072)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
at com.microsoft.sqlserver.jdbc.TDSChannel.enableSSL(IOBuffer.java:1756)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectHelper(SQLServerConnection.java:2391)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.login(SQLServerConnection.java:2042)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connectInternal(SQLServerConnection.java:1889)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.connect(SQLServerConnection.java:1120)
at com.microsoft.sqlserver.jdbc.SQLServerDriver.connect(SQLServerDriver.java:700)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at datas.DatabaseDatas.getLelang(DatabaseDatas.java:19)
at org.apache.jsp.company.halaman_005futama_005fcompany_jsp._jspService(halaman_005futama_005fcompany_jsp.java:595)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1580)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:652)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:591)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:371)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:463)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:168)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:242)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:539)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
at java.lang.Thread.run(Thread.java:748)
The code that triggers the crash is here:
public class DatabaseDatas {
private final static String sqlconn = "jdbc:sqlserver://<redacted>;" +
"databaseName=dbName";
/**
* Gets Lelang data in LelangList
* #return Data in LelangList table
*/
public static ResultSet getLelang(){
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection sqlconnection = DriverManager.getConnection(sqlconn,"sa","password"); //this is the one which trigger the crash
sqlconnection.isValid(0); //ignore this
Statement sta = sqlconnection.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY);
String sql = "SELECT * FROM ListLelang";
return sta.executeQuery(sql);
} catch (ClassNotFoundException|SQLException e) {
e.printStackTrace();
}
return null;
}
I use Jetbrains Intellij IDEA 2018.2.3 as IDE and set JDK 1.8.0_151 as Project SDK. I've also set javax.sql.DataSource and java.sql.driver in JDBC Connection Pool in GlassFish 5 Admin panel.
I have no idea why this happens. I can't find my error anywhere on the Internet.
Please help me resolve this problem. I can provide more info if needed (as long as it's not personal info). Thank you.
EDIT: Actually I forget to test the connection pool. After I try to 'ping' via Glassfish 5 Admin Panel, I got the same error as the one in the stacktrace above.
Glassfish admin panel error when pinging to MSSQL connection
With Java EE you shouldn't open the database connection to your SQL-Server manually with the DriverManager. The application server (Glassfish) in your case is responsible for opening the connections and pooling them.
As you said you already configured Glassfish for the DataSource and the JDBC Connection Pool you won't need to do this in your code again. You can now use the DataSource with injecting it via #Resource(lookup="JNDI_NAME_OF_YOUR_DATASOURCE") DataSource dataSource; in your code (EJB or CDI) and work with it. You get the Connection with dataSource.getConnection();.
If you plan to use the EntityManager and work with JPA, you need a persistence.xml file in your application in the following directory: src/main/resources/META-INF and it could look like the following:
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd"
version="2.2">
<persistence-unit name="prod" transaction-type="JTA">
<jta-data-source>JNDI_NAME_OF_YOUR_CONFIGURED_DATASOURCE</jta-data-source>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
</properties>
</persistence-unit>
</persistence>
With this setup you can now inject the EntityManager in your CDI or EJB bean with #Resource EntityManager entityManager; and use it.
With this approach, you make sure that the application server is managing every infrastructure-related stuff (dealing with a database) and you can focus on your business logic.
The following tutorial might help you further: https://javaee.github.io/tutorial/resource-creation002.html
I decided to ditch Glassfish completely (because as far as I see, Glassfish is quite out of date at the time of this writing) and using Apache TomEE (webservice version) as a web servlet.
And it works just fine, even with latest JDK (1.8.0_181)! No more errors regarding MSSQL anymore.
(Please note: if not appropriate to post here, grateful if the administrator help to remove it. Thanks)
Background: there is an application that deployed on tomcat 8 in windows server 2008 r2. Currently the server is running and the application runs properly. The team leader told us the application is written by a programmer who already resigned the company two years ago. The program does not have any code changes after the programmer's resignation.
For some reasons, we have to change (upgrade) windows server 2008 r2 to windows server 2012 r2.
The application requires java 1.7 and tomcat 8 to run, so we installed those software in windows server 2012 r2.
We copy the war file from windows server 2008 r2 and paste in windows server 2012 r2. After copy and paste the war file, we deploy the war file in tomcat web application manager (the same action in windows server 2008 r2).
Once we deploy the war file, we try to start the application. However, when we click the "Start" button, we wait for a while and the tomcat message displays "FAIL - Application at context path/path-name could not be started".
We checked the software version, and they are same as in windows server 2008 r2.
We get confused about the message because the war file works in the windows server 2008 r2.
We check the localhost.2017-07-13.log file and we notice there are some exception. We would like post the content of the log here.
13-Jul-2017 15:00:42.464 INFO [http-nio-8080-exec-8]
org.apache.catalina.core.ApplicationContext.log Initializing Spring root
WebApplicationContext
13-Jul-2017 15:00:43.214 SEVERE [http-nio-8080-exec-8]
org.apache.catalina.core.StandardContext.listenerStart Exception sending
context initialized event to listener instance of class
org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'dataSource' defined in ServletContext resource [/WEB-
INF/applicationContext.xml]: Error setting property values; nested exception
is org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property
'driverClassName' threw exception; nested exception is
java.lang.IllegalStateException: Could not load JDBC driver class
[net.sourceforge.jtds.jdbc.Driver]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.app
lyPropertyValues(AbstractAutowireCapableBeanFactory.java:1279)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.pop
ulateBean(AbstractAutowireCapableBeanFactory.java:1010)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doC
reateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.r
un(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.cre
ateBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(Abstra
ctBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingle
ton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(Abstract
BeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
anFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBe
anFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstanti
ateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactory
Initialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractA
pplicationContext.java:380)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(Contex
tLoader.java:244)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextL
oader.java:187)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(Context
LoaderListener.java:49)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4729
)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5167
)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:945)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:466)
at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1556)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(Unknown Source)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(Unknown Source)
at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1460)
at org.apache.catalina.manager.HTMLManagerServlet.upload(HTMLManagerServlet.java:289)
at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:210)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:213)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:614)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1:
org.springframework.beans.MethodInvocationException: Property
'driverClassName' threw exception; nested exception is
java.lang.IllegalStateException: Could not load JDBC driver class
[net.sourceforge.jtds.jdbc.Driver]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPro
pertyAccessor.java:104)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPro
pertyAccessor.java:59)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.app
lyPropertyValues(AbstractAutowireCapableBeanFactory.java:1276)
... 64 more
We don't understand is why the program works in windows server 2008 r2 but it does not work in windows server 2012 r2?
Currently we are still finding the source code of the program but from the log file, it mentioned about [/WEB-INF/applicationContext.xml] and [net.sourceforge.jtds.jdbc.Driver], we guess when we get the source code, we need to find the xml file and the driver, is it correct?
Grateful for your advice please. Thank you.
Edit
We just find the source code and we open the applicationContext.xml and there is a bean for net.sourceforge.jtds.jdbc.Driver. Not sure why it does not work in windows server 2012 r2.
Here is code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="net.sourceforge.jtds.jdbc.Driver" />
<property name="url" value="jdbc:jtds:sqlserver://{host}:1433;DatabaseName=myDB" />
<property name="username" value="user" />
<property name="password" value="Password" />
</bean>
</beans>
You say (emphasis mine)
The application requires java 1.7 and tomcat 8 to run, so we installed
those software in windows server 2012 r2.
We copy the war file from windows server 2008 r2 and paste in windows
server 2012 r2. After copy and paste the war file, we deploy the war
file in tomcat web application manager (the same action in windows
server 2008 r2).
The error message says
java.lang.IllegalStateException: Could not load JDBC driver class
[net.sourceforge.jtds.jdbc.Driver]
Means: You did not sufficiently reproduce the original implementation. As you might miss more than just this driver (it could just be the first to fail) I'm suggesting a full diff over both directories. Figure out what's deployed in both installations.
Hint: Tomcat has a global classpath in its lib directory, this contains code that every webapp can use.
I have really tried to find a solution to this problem - but I can't seem to figure it out. I really hope you guys know what to do.
My Spring MVC application has begun to lose the connection to the database, and I don't know why. It is driving me crazy.
Spring DB setup:
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://ip/database-name
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.show-sql=false
spring.datasource.tomcat.initialSize=5
spring.datasource.tomcat.maxActive=55
spring.datasource.tomcat.maxIdle=21
spring.datasource.tomcat.minIdle=13
spring.datasource.tomcat.testWhileIdle=true
spring.datasource.tomcat.timeBetweenEvictionRunsMillis=34000
spring.datasource.tomcat.minEvictableIdleTimeMillis=55000
spring.datasource.tomcat.validationInterval=34000
spring.datasource.tomcat.testOnBorrow=true
spring.datasource.tomcat.validationQuery=SELECT 1
spring.datasource.tomcat.removeAbandoned=true
spring.datasource.tomcat.removeAbandonedTimeout=233
spring.jpa.hibernate.ddl-auto=update
I have tried to specify 'autoReconnect=true' because I found answers, that suggested that - but it hasn't solved my problem.
Error log:
WARN 5220 --- [-nio-443-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 08S01
ERROR 5220 --- [-nio-443-exec-6] o.h.engine.jdbc.spi.SqlExceptionHelper : The last packet successfully received from the server was 60,401,089 milliseconds ago. The last packet sent successfully to the server was 60,401,089 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection val
idity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
ERROR 5220 --- [-nio-443-exec-6] w.a.UsernamePasswordAuthenticationFilter : An internal error occurred while trying to authenticate the user.
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: The last packet successfully received from the server was 60,401,089 milliseconds ago. The last packet sent successfully to the server was 60,401,089 milliseconds ago. is longer than the server configured value of 'wait_timeout'. You should consider either expiring and/or testing connection validity before use in your application, increasing the server configured values for client timeouts, or using the Connector/J connection property 'autoReconnect=true' to avoid this problem.
at sun.reflect.GeneratedConstructorAccessor277.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_91]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_91]
at com.mysql.jdbc.Util.handleNewInstance(Util.java:404) ~[mysql-connector-java-5.1.38.jar:5.1.38]
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:981) ~[mysql-connector-java-5.1.38.jar:5.1.38]
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3652) ~[mysql-connector-java-5.1.38.jar:5.1.38]
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2460) ~[mysql-connector-java-5.1.38.jar:5.1.38]
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625) ~[mysql-connector-java-5.1.38.jar:5.1.38]
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551) ~[mysql-connector-java-5.1.38.jar:5.1.38]
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861) ~[mysql-connector-java-5.1.38.jar:5.1.38]
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1962) ~[mysql-connector-java-5.1.38.jar:5.1.38]
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:82) ~[hibernate-core-4.3.11.Final.jar:4.3.11.Final]
... 111 common frames omitted
Caused by: java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method) ~[na:1.8.0_91]
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109) ~[na:1.8.0_91]
at java.net.SocketOutputStream.write(SocketOutputStream.java:153) ~[na:1.8.0_91]
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82) ~[na:1.8.0_91]
at java.io.BufferedOutputStream.write(BufferedOutputStream.java:126) ~[na:1.8.0_91]
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:3633) ~[mysql-connector-java-5.1.38.jar:5.1.38]
... 117 common frames omitted
Thanks.
I was facing a similar problem, try 2 things:
Change spring.datasource.url=jdbc:mysql://ip/database-name to spring.datasource.url=jdbc:mysql://ip/database-name?autoReconnect=true
I was using c3p0 in my application, configuring idleConnectionTestPeriod and preferredTestQuery resolved my issue
<!-- DB Configuration -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="${jdbc_url}" />
<property name="user" value="${jdbc_username}" />
<property name="password" value="${jdbc_password}" />
<property name="driverClass" value="${jdbc_driver_class}" />
<!-- these are C3P0 properties -->
<property name="acquireIncrement" value="1" /> <!-- Determines how many connections at a time c3p0 will try to acquire when the pool is exhausted. -->
<property name="minPoolSize" value="${jdbc_min_pool_size}" />
<property name="maxPoolSize" value="${jdbc_max_pool_size}" />
<property name="maxIdleTime" value="100" /> <!-- Seconds a Connection can remain pooled but unused before being discarded. Zero means idle connections never expire. -->
<!--set this value less then mysql wait_timeout -->
<property name="idleConnectionTestPeriod" value="100"/> <!-- If this is a number greater than 0, C3P0 will test all idle, pooled but unchecked-out connections, every this number of seconds-->
<property name="preferredTestQuery" value="select 1"/> <!--a query used to test connections-->
</bean>
Your property spring.datasource.tomcat.validationInterval seems to do the same. From the error it seems that MySQL wait_timeout in your case is 60,401,089 ms, so the validationInterval seems less than that, but still try reducing it to 100 and see if the error reoccurs. If that doesn't work try configuring c3p0 and using the config I mentioned.
I am using a simple java application for manipulating the table records from browser. I have used hibernate for making DAO calls. The application works fine on normal usage. However when the application is idle for 1 to 2 days the following exception occurs.
Caused by: java.sql.SQLException: IO
Error: Connection reset
After using c3p0 the dle time extended up to 10 days. But I want the application to be running up all the time.
I have been using Linux sever. JDK 1.5. Tomcat server 6.
My Hibernate config,
jdbc:oracle:thin:#something.com:1789:patentmd
oracle.jdbc.driver.OracleDriver
<property name="hibernate.connection.username">something</property>
<property name="hibernate.connection.password">something</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.show_sql">true</property>
<!-- <property name="hibernate.current_session_context_class">thread</property> -->
<property name="c3p0.acquire_increment">1</property>
<property name="c3p0.idle_test_period">30</property>
<property name="c3p0.max_size">5</property>
<property name="c3p0.min_size">2</property>
<property name="c3p0.max_statements">5</property>
<property name="c3p0.timeout">180</property>
<!-- Mapping Resources. One entry should exist for each table -->
<mapping resource="com/hibernate/pojo/clientgrp/ClientGroup.hbm.xml"/>
<mapping resource="com/hibernate/pojo/applepub/Apple_Pub.hbm.xml"/>
<mapping resource="com/hibernate/pojo/prspub/Prs_Pub.hbm.xml"/>
</session-factory>
The full stack trace,
$$$$$$$$$$ sessionfactory is not null
Connection : true
Hibernate: select clientgrou0_.MGR_PRS_ID as MGR1_0_, clientgrou0_.MGR_PRS_NAME as MGR2_0_, clientgrou0_.MGR_CLIENT_GROUP as
MGR3_0_, clientgrou0_.UPDATE_DT as UPDATE4_0_, clientgrou0_.CREATE_DT as CREATE5_0_, clientgrou0_.DEPT_NM as DEPT6_0_ from
CLIENTGROUPS clientgrou0_
############ ClientGroupDAO.getAll() , hibernate exception org.hibernate.exception.JDBCConnectionException: could not execu
te query
ClientGroupTableHandler.getAllRecords() $$$$$$$$ exception occured 6org.hibernate.HibernateException: org.hibernate.excepti
on.JDBCConnectionException: could not execute query
ClientGroupTableHandler.Main() $$$$$$$$ exception occured 1java.lang.Exception: org.hibernate.HibernateException: org.hiber
nate.exception.JDBCConnectionException: could not execute query
java.lang.Exception: org.hibernate.HibernateException: org.hibernate.exception.JDBCConnectionException: could not execute qu
ery
at com.web.servlets.ClientGroupTableHandler.getAllRecords(ClientGroupTableHandler.java:294)
at com.web.servlets.ClientGroupTableHandler.Main(ClientGroupTableHandler.java:76)
at com.web.servlets.ClientGroupTableHandler.doPost(ClientGroupTableHandler.java:56)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)
Caused by: org.hibernate.HibernateException: org.hibernate.exception.JDBCConnectionException: could not execute query
at com.hibernate.dao.ClientGroupDAO.getAll(ClientGroupDAO.java:76)
at com.web.servlets.ClientGroupTableHandler.getAllRecords(ClientGroupTableHandler.java:288)
... 16 more
Caused by: org.hibernate.exception.JDBCConnectionException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:99)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.loader.Loader.doList(Loader.java:2536)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
at org.hibernate.loader.Loader.list(Loader.java:2271)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:452)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:363)
at org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1268)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:102)
at com.hibernate.dao.ClientGroupDAO.getAll(ClientGroupDAO.java:45)
... 17 more
Caused by: java.sql.SQLException: IO Error: Connection reset
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:876)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1203)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
at org.hibernate.loader.Loader.doQuery(Loader.java:802)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
at org.hibernate.loader.Loader.doList(Loader.java:2533)
... 25 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at oracle.net.ns.DataPacket.send(DataPacket.java:199)
at oracle.net.ns.NetOutputStream.flush(NetOutputStream.java:211)
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:227)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:100)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:123)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:79)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1122)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1099)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:288)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:863)
... 35 more
Blockquote
Looks strange, are you holding on to a stale Hibernate Session in some way? You should always get a fresh Hibernate Session and release it afterwards.
The underlying connection is stale.
The normal course of action is either to get the connection pool to test the connection before you use it.
For C3P0:
c3p0.testConnectionOnCheckout=true
c3p0.preferredTestQuery="select 1 from dual"
http://community.jboss.org/wiki/HowToConfigureTheC3P0ConnectionPool
The other option is to set the min number of connections to 0, and make sure the pool is configured to evict unused connections before the database connection timeout is reached.
Add this property in your hibernate config file. I hope it ll work.
<property name="connection.provider_class">
org.hibernate.connection.C3P0ConnectionProvider
</property>