Servlet dispatcher is currently unavailable - java

<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" />
<bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/spring"/>
<property name="username" value="monty"/>
<property name="password" value="indian"/>
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="annotatedClasses">
<list>
<value>uk.co.vinoth.spring.domain.User</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>
<bean id="myUserDAO" class="uk.co.vinoth.spring.dao.UserDAOImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>
<bean name="/user/*.htm" class="uk.co.vinoth.spring.web.UserController" >
<property name="userDAO" ref="myUserDAO" />
</bean>
</beans>
The above is my bean configuration, why do i get error when i run my application. My logs folder is empty...
org.apache.catalina.loader.StandardClassLoader#122c9df
org.springframework.web.servlet.DispatcherServlet
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1436)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1282)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1068)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Dec 22, 2010 3:44:48 PM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /interMedix threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1436)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1282)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1068)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3996)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4266)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:448)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
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.catalina.startup.Bootstrap.start(Bootstrap.java:295)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
Dec 22, 2010 3:44:48 PM org.apache.coyote.http11.Http11BaseProtocol start
INFO: Starting Coyote HTTP/1.1 on http-8181
Dec 22, 2010 3:44:48 PM org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
Dec 22, 2010 3:44:48 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/27 config=null
Dec 22, 2010 3:44:48 PM org.apache.catalina.storeconfig.StoreLoader load
INFO: Find registry server-registry.xml at classpath resource
Dec 22, 2010 3:44:49 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 558 ms
Dec 22, 2010 3:44:50 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO: Servlet dispatcher is currently unavailable
Dec 22, 2010 3:50:18 PM org.apache.catalina.core.StandardWrapperValve invoke
INFO: Servlet dispatcher is currently unavailable
But i have added spring-web-mvc to my class path which does contain this class file.

But i have added spring-web-mvc to my
class path which does contain this
class file.
How did you add something to your CLASSPATH?
If you're creating a web app, the only appropriate thing is to put .class files under WEB-INF/classes and .jar files under WEB-INF/lib. If you did anything else, I'd say that it's wrong. Modifications of the startup script should not be done; local environment variables will be ignored and unlikely to be set on the server you deploy to.
UPDATE:
If you tell me that you've done everything right according to your IDE, I'd recommend one last check: Look at the zipped or exploded WAR file that you actually deploy to Tomcat and make sure that you can see the JAR with the .class file that the error mentions. If it's not part of the WAR, you have to figure out what went wrong with your packaging. If you think the JAR is there, open it and find the .class and check the path.
You have to believe the error message you see. Instead of saying "I'm doing everything right", it's better to say "What have I missed?"

A ClassNotFoundException suggests that you don't have Spring on the classpath. Make sure it's in your WAR's lib directory.
Also, make sure you also have commons-logging.jar in your classpath. Spring depends on this.

Related

Tomcat v 9.0 - Public Key Retrieval is not allowed

I am building web application using Spring and Hibernate. I am using Tomcat version 9.0 and mysql-connector-java-8.0.12.jar
I am trying to run my program using Tomcat, I am getting this error.
Any help would be appreciated. I tried all the solutions but none worked for me.
May 12, 2019 6:01:22 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool#37045b48 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask#46e75b5c -- 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:
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:832)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool#37045b48 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask#158da6c2 -- 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:
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:832)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
May 12, 2019 6:02:54 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 0, SQLState: null
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool#37045b48 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
May 12, 2019 6:02:54 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Connections could not be acquired from the underlying database!
May 12, 2019 6:02:54 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [/web-customer-tracker] threw exception [Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection] with root cause
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:832)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask#701a20b -- 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:
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:832)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask#47b1f8e4 -- 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:
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:832)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool#37045b48 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool#37045b48 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask#48ada644 -- 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:
java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:832)
at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456)
at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:207)
at com.mchange.v2.c3p0.DriverManagerDataSource.getConnection(DriverManagerDataSource.java:175)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:220)
at com.mchange.v2.c3p0.WrapperConnectionPoolDataSource.getPooledConnection(WrapperConnectionPoolDataSource.java:206)
at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool$1PooledConnectionResourcePoolManager.acquireResource(C3P0PooledConnectionPool.java:203)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquire(BasicResourcePool.java:1138)
at com.mchange.v2.resourcepool.BasicResourcePool.doAcquireAndDecrementPendingAcquiresWithinLockOnSuccess(BasicResourcePool.java:1125)
at com.mchange.v2.resourcepool.BasicResourcePool.access$700(BasicResourcePool.java:44)
at com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask.run(BasicResourcePool.java:1870)
at com.mchange.v2.async.ThreadPoolAsynchronousRunner$PoolThread.run(ThreadPoolAsynchronousRunner.java:696)
May 12, 2019 6:02:54 PM com.mchange.v2.resourcepool.BasicResourcePool
WARNING: Having failed to acquire a resource, com.mchange.v2.resourcepool.BasicResourcePool#37045b48 is interrupting all Threads waiting on a resource to check out. Will try again in response to new client requests.
This is my database connection manager file
package com.luv2code.testdb;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.*;
/**
* Servlet implementation class TestDbServlet
*/
#WebServlet("/TestDbServlet")
public class TestDbServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* #see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// setup connection variables
String user = "springstudent";
String pass = "springstudent";
String jdbcUrl = "jdbc:mysql://localhost:3306/web_customer_tracker?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC";
String driver = "com.mysql.cj.jdbc.Driver";
// get connection to the database
try {
PrintWriter out = response.getWriter();
out.println("Connecting to Database: " + jdbcUrl);
Class.forName(driver);
Connection myConn = DriverManager.getConnection(jdbcUrl, user, pass);
out.println("SUCCESS!!");
myConn.close();
}
catch (Exception exc) {
exc.printStackTrace();
throw new ServletException(exc);
}
}
}
This is my spring-mvc.xml file
<?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:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- Add support for component scanning -->
<context:component-scan base-package="com.luv2code.springdemo" />
<!-- Add support for conversion, formatting and validation support -->
<mvc:annotation-driven/>
<!-- Define Spring MVC view resolver -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- Step 1: Define Database DataSource / connection pool -->
<bean id="myDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass" value="com.mysql.cj.jdbc.Driver" />
<property name="jdbcUrl" value="jdbc:mysql://localhost:3306/web_customer_tracker?useSSL=false&serverTimezone=UTC" />
<property name="user" value="springstudent" />
<property name="password" value="springstudent" />
<!-- these are connection pool properties for C3P0 -->
<property name="minPoolSize" value="5" />
<property name="maxPoolSize" value="20" />
<property name="maxIdleTime" value="30000" />
</bean>
<!-- Step 2: Setup Hibernate session factory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="packagesToScan" value="com.luv2code.springdemo.entity" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<!-- Step 3: Setup Hibernate transaction manager -->
<bean id="myTransactionManager"
class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- Step 4: Enable configuration of transactional behavior based on annotations -->
<tx:annotation-driven transaction-manager="myTransactionManager" />
<mvc:resources location="/resources/" mapping="/resources/**" ></mvc:resources>
</beans>
I had similar problem. Changing jdbc.url to
jdbc.url=jdbc:mysql://localhost:3306/web_customer_tracker?allowPublicKeyRetrieval=true&useSSL=false&serverTimezone=UTC
worked for me.
url="jdbc:mysql://localhost:3306/web_student_tracker?useSSL=true
I had a similar problem when I was doing the project, but its very simple just update mysql connector jar file (mysql-connector-java-8.0.12) to (mysql-connector-java-8.0.12) and it's working fine.
I had the same problem when I was doing the same course on Udemy, I fixed it just updating my mysql connector, now I am using (mysql-connector-java-8.0.16.jar) instead of (mysql-connector-java-8.0.12.jar)

Spring : Java heap space outOfMemory on bean creation's exception

I'm migrating my Spring dependencies injections, from XML declaration into the annotation style.
But now that I've migrated DAO, Services and Controllers, the server won't launch anymore :
java.lang.OutOfMemoryError: Java heap space
I can see in the stacktrace (see below) there is a BeanCreationException, but i can't know which one because the OutOfMemory exception occurs on BeanCreationException's message construction.
I already tried to increase -Xmx and -XX:MaxPermSize JVM's argument, but i believe it's like an infinite loop or something like that. The application worked perfectly before the migration to annotation.
Do you have any idea how to know where the problem come from ?
Versions : Hibernate 3.1, Spring 2.5, Tomcat 7, JDK 7
Typical applicationContext.xml content (before) :
<bean id="fooDAO" class="foo.bar.fooDAO">
<property name="sessionFactory">
<ref bean="foo_factory" /> //extends LocalSessionFactoryBean
</property>
</bean>
<bean id="fooService" class="foo.bar.fooService">
<property name="foodDAO" ref="fooDAO" />
</bean>
<bean id="fooControler" class="foo.bar.fooControler" autowire="byName">
<property name="fooService" ref="fooService" />
</bean>
After migration :
#Repository on DAO, #Service on services and #Controller on controllers.
StackTrace :
mars 12, 2018 1:37:51 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: Java heap space
at java.util.concurrent.FutureTask.report(FutureTask.java:122)
at java.util.concurrent.FutureTask.get(FutureTask.java:188)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1239)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:819)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1700)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1690)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2367)
at java.lang.AbstractStringBuilder.expandCapacity(AbstractStringBuilder.java:130)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:114)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:415)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:154)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:154)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:154)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:149)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
at org.springframework.beans.factory.BeanCreationException.toString(BeanCreationException.java:149)
at java.lang.String.valueOf(String.java:2849)
at java.lang.StringBuffer.append(StringBuffer.java:232)
at org.springframework.core.NestedExceptionUtils.buildMessage(NestedExceptionUtils.java:47)
at org.springframework.core.NestedRuntimeException.getMessage(NestedRuntimeException.java:67)
at java.lang.Throwable.getLocalizedMessage(Throwable.java:391)
at java.lang.Throwable.toString(Throwable.java:480)
mars 12, 2018 1:37:51 PM org.apache.catalina.core.ContainerBase startInternal
GRAVE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost]]

java.sql.SQLException: invalid arguments in call

I am learning to integrate hibernate with spring to connect to Oracle 11g using the below code. But stuck with the same error from few days. Please help me resolve this. i have tried the different solutions mentioned in other answers given for questions with the same error, but no luck.
Any relevant solutions welcome.
Thanks,
Nisha
spring.xml
<?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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
<bean id="serverDatasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" >
<value>oracle.jdbc.driver.OracleDriver</value>
</property>
<property name="url" >
<value>jdbc:oracle:thin:#10.23.225.22:1521:PRACTICE</value>
</property>
<!-- <property name="username" value="SCOTT"/>
<property name="password" value="tiger"/>-->
</bean>
<bean id="dataSource" class="org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter">
<property name="targetDataSource" ref="serverDatasource"/>
<property name="username"><value>SCOTT</value></property>
<property name="password"><value>tiger</value></property>
</bean>
<!-- Hibernate 5 SessionFactory bean definition -->
<bean id="Hibernate5SessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="annotatedClasses">
<list>
<value>com.springHibernate.model.Person</value>
</list>
</property>
<property name="HibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>
<prop key="hibernate.current_session_context_class">thread</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
<bean id="personDao" class="com.springHibernate.dao.PersonDaoImpl">
<property name="sessionFactory" ref="Hibernate5SessionFactory"></property>
</bean>
</beans>
Main Method: SpringHibernateMain
package com.springHibernate.main;
import java.util.List;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.springHibernate.dao.PersonDao;
import com.springHibernate.model.Person;
public class SpringHibernateMain {
public static void main(String[] args) {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
PersonDao personDao = context.getBean(PersonDao.class);
Person p = new Person();
p.setId(1);
p.setName("John");
p.setCountry("United States");
personDao.save(p);
List<Person> person = personDao.listPerson();
for(Person p1 : person){
System.out.println("Person List:" + p1);
}
}
}
Stack Trace:
ERROR: Unable obtain JDBC Connection
java.sql.SQLException: invalid arguments in call
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:236)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:155)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:130)
at org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter.doGetConnection(UserCredentialsDataSourceAdapter.java:162)
at org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter.getConnection(UserCredentialsDataSourceAdapter.java:145)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
at org.hibernate.internal.SessionFactoryImpl$3.obtainConnection(SessionFactoryImpl.java:643)
at org.hibernate.hql.spi.id.IdTableHelper.executeIdTableCreationStatements(IdTableHelper.java:67)
at org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy.finishPreparation(GlobalTemporaryTableBulkIdStrategy.java:125)
at org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy.finishPreparation(GlobalTemporaryTableBulkIdStrategy.java:42)
at org.hibernate.hql.spi.id.AbstractMultiTableBulkIdStrategyImpl.prepare(AbstractMultiTableBulkIdStrategyImpl.java:88)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:451)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:465)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:708)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:724)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:416)
at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:401)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:753)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.springHibernate.main.SpringHibernateMain.main(SpringHibernateMain.java:14)
May 16, 2016 12:59:16 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 17433, SQLState: null
May 16, 2016 12:59:16 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: invalid arguments in call
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:47)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:87)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getPhysicalConnection(LogicalConnectionManagedImpl.java:109)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.getConnectionForTransactionManagement(LogicalConnectionManagedImpl.java:227)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.begin(LogicalConnectionManagedImpl.java:234)
at org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorImpl$TransactionDriverControlImpl.begin(JdbcResourceLocalTransactionCoordinatorImpl.java:214)
at org.hibernate.engine.transaction.internal.TransactionImpl.begin(TransactionImpl.java:52)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1525)
at com.springHibernate.dao.PersonDaoImpl.save(PersonDaoImpl.java:25)
at com.springHibernate.main.SpringHibernateMain.main(SpringHibernateMain.java:24)
Caused by: java.sql.SQLException: invalid arguments in call
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:236)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:153)
at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:144)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:155)
at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:130)
at org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter.doGetConnection(UserCredentialsDataSourceAdapter.java:162)
at org.springframework.jdbc.datasource.UserCredentialsDataSourceAdapter.getConnection(UserCredentialsDataSourceAdapter.java:145)
at org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl.getConnection(DatasourceConnectionProviderImpl.java:122)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:386)
at org.hibernate.resource.jdbc.internal.LogicalConnectionManagedImpl.acquireConnectionIfNeeded(LogicalConnectionManagedImpl.java:84)
... 8 more
As It is mentioned in the Stacktrace it is unable to get the connection.
invalid arguments in call
Exception in thread "main" org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC Connection
In datasource driver name should be like below
<value>oracle.jdbc.OracleDriver</value>
In procedure if we give incorrect type mapping from java type to oracle data type then we will get
org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for proc SQL state [99999]; error code [17068]; Invalid argument(s) in call; nested exception is java.sql.SQLException: Invalid argument(s) in call
To fix this we need to map respective data type.
Instead
PersonDao personDao = context.getBean(PersonDao.class);
Try with
PersonDao personDao = (PersonDao) context.getBean("personDao");
So your Bean Id in spring.xml
Solved this, at last, by adding just the jars in lib/required folder of Hibernate zip file. Till then i had added all the jars in the lib folder.

Hibernate failing to read or write a org.joda.time.LocalDate

I'm using UserType 3.2.0-GA, Hibernate 4.3.8, talking to an existing mysql instance on AWS (RDS).
I'm trying to upgrade the app from Hibernate 3.2.6 and joda-time-hibernate 1.1.
The failing property:
<property name="birthdate" not-null="true" type="org.joda.time.LocalDate"/>
The model:
import org.joda.time.LocalDate;
...
public LocalDate getBirthdate() {
return this.birthdate;
}
The error when trying to read existing data:
org.hibernate.type.SerializationException: could not deserialize (Caused by: java.io.StreamCorruptedException: invalid stream header: 31393936)
org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:262)
org.hibernate.internal.util.SerializationHelper.deserialize(SerializationHelper.java:306)
org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:155)
org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:130)
org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:44)
org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:71)
org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:64)
org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:267)
org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:263)
org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:253)
org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:338)
...
java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:804)
The error when trying to write new data:
WARN: SQL Error: 1292, SQLState: 22001
Apr 12, 2016 5:12:07 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: Data truncation: Incorrect date value: '��' for column 'birthdate' at row 1
Apr 12, 2016 5:12:07 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper$StandardWarningHandler logWarning
WARN: SQL Warning Code: 1292, SQLState: HY000
Apr 12, 2016 5:12:07 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper$StandardWarningHandler logWarning
WARN: Incorrect date value: '��' for column 'birthdate' at row 1
org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.DataException: could not execute statement
As you can see, i'm using Spring to configure things. My hibernate properties in spring are:
<bean id="hibernateProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="properties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.generate_statistics">true</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.EhCacheRegionFactory</prop>
<prop key="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="jadira.usertype.autoRegisterUserTypes">true</prop>
</props>
</property>
</bean>
Turns out i got it to work by setting the type to:
<property name="birthdate" not-null="true" type="org.jadira.usertype.dateandtime.joda.PersistentLocalDate"/>
Unfortunately, i don't understand why this works or is even necessary. More explanation would be great.

Create bean for sessionFactory in applicaionContext

UPDATE: Show full application context
Good day.
I try to integrate spring and hibernate and tapestry, but have problems with some beans in application-context.xml
Here my pom.xml part with hibernate and spring.
I use IDE: Idea 12, with supporting of spring, tapestry and hibernate framework, so some jar file in lib directory.
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.2.Final</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
Here my applicationcontext.xml, part for sessionFactry bean
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/reframework</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>root</value>
</property>
</bean>
<bean id="namingStrategy"
class="org.springframework.beans.factory.config.FieldRetrievingFactoryBean">
<property name="staticField">
<value>org.hibernate.cfg.ImprovedNamingStrategy.INSTANCE</value>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="namingStrategy">
<ref bean="namingStrategy"/>
</property>
<property name="mappingResources">
<list>
<!--<value>genericdaotest/domain/Person.hbm.xml</value>-->
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLMyISAMDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<bean id="extendedFinderNamingStrategy"
class="com.packtpub.domain.finder.classes.ExtendedFinderNamingStrategy" />
<!-- Dao Layer generic config-->
<bean id="finderIntroductionAdvisor" class="com.packtpub.domain.finder.classes.FinderIntroductionAdvisor"/>
<bean id="abstractDaoTarget"
class="com.packtpub.domain.dao.ReDAO" abstract="true">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
<property name="namingStrategy">
<ref bean="extendedFinderNamingStrategy" />
</property>
</bean>
<bean id="abstractDao"
class="org.springframework.aop.framework.ProxyFactoryBean" abstract="true">
<property name="interceptorNames">
<list>
<value>finderIntroductionAdvisor</value>
</list>
</property>
</bean>
<!-- Dao Layer instances -->
<bean id="objectDao" parent="abstractDao">
<property name="proxyInterfaces">
<value>com.packtpub.domain.dao.objects.IObjectDAO</value>
</property>
<property name="target">
<bean parent="abstractDaoTarget">
<constructor-arg>
<value>com.packtpub.domain.entities.ObjectEntity</value>
</constructor-arg>
</bean>
</property>
</bean>
</beans>
But, when I start my applicationt, it gives me an exception
Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
as I understood after searching in hibernate 4 there is no such class, but what I need to do, to solve it?
Here full stacktrace
[DEBUG] AppModule.IObjectService Loading class com.packtpub.services.ObjectService.
[DEBUG] AppModule.IObjectService Marking class com.packtpub.services.ObjectService to be (re-)loaded
[DEBUG] AppModule.IObjectService BEGIN Analyzing com.packtpub.services.ObjectService
[DEBUG] AppModule.IObjectService END Analyzing com.packtpub.services.ObjectService
[DEBUG] AppModule.IObjectService Invoking constructor public com.packtpub.services.ObjectService() (for service 'IObjectService')
[INFO] support.ClassPathXmlApplicationContext Refreshing org.springframework.context.support.ClassPathXmlApplicationContext#5b905255: startup date [Tue Jan 08 21:05:19 MSK 2013]; root of context hierarchy
[INFO] xml.XmlBeanDefinitionReader Loading XML bean definitions from class path resource [WEB-INF/applicationContext.xml]
[INFO] support.DefaultListableBeanFactory Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#989472: defining beans [dataSource,namingStrategy,sessionFactory,extendedFinderNamingStrategy,finderIntroductionAdvisor,abstractDaoTarget,abstractDao,objectDao]; root of factory hierarchy
[INFO] datasource.DriverManagerDataSource Loaded JDBC driver: com.mysql.jdbc.Driver
[INFO] support.DefaultListableBeanFactory Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#989472: defining beans [dataSource,namingStrategy,sessionFactory,extendedFinderNamingStrategy,finderIntroductionAdvisor,abstractDaoTarget,abstractDao,objectDao]; root of factory hierarchy
[ERROR] ioc.Registry Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
[ERROR] ioc.Registry Operations trace:
[ERROR] ioc.Registry [ 1] Triggering event 'action' on Index:increment
[ERROR] TapestryModule.RequestExceptionHandler Processing of request failed with uncaught exception: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
org.apache.tapestry5.ioc.internal.OperationException: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider [at classpath:com/packtpub/pages/Index.tml, line 19]
at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.logAndRethrow(OperationTrackerImpl.java:121)
at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:88)
at org.apache.tapestry5.ioc.internal.PerThreadOperationTracker.invoke(PerThreadOperationTracker.java:87)
at org.apache.tapestry5.ioc.internal.RegistryImpl.invoke(RegistryImpl.java:1124)
at org.apache.tapestry5.internal.structure.ComponentPageElementResourcesImpl.invoke(ComponentPageElementResourcesImpl.java:146)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.triggerContextEvent(ComponentPageElementImpl.java:1053)
at org.apache.tapestry5.internal.services.ComponentEventRequestHandlerImpl.handle(ComponentEventRequestHandlerImpl.java:81)
at org.apache.tapestry5.internal.services.ImmediateActionRenderResponseFilter.handle(ImmediateActionRenderResponseFilter.java:42)
at $ComponentEventRequestHandler_11e927111127.handle(Unknown Source)
at org.apache.tapestry5.internal.services.AjaxFilter.handle(AjaxFilter.java:42)
at $ComponentEventRequestHandler_11e927111127.handle(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$41.handle(TapestryModule.java:2476)
at $ComponentEventRequestHandler_11e927111127.handle(Unknown Source)
at $ComponentEventRequestHandler_11e9271110ae.handle(Unknown Source)
at org.apache.tapestry5.internal.services.ComponentRequestHandlerTerminator.handleComponentEvent(ComponentRequestHandlerTerminator.java:43)
at org.apache.tapestry5.services.InitializeActivePageName.handleComponentEvent(InitializeActivePageName.java:39)
at $ComponentRequestHandler_11e9271110b0.handleComponentEvent(Unknown Source)
at $ComponentRequestHandler_11e92711107b.handleComponentEvent(Unknown Source)
at org.apache.tapestry5.internal.services.ComponentEventDispatcher.dispatch(ComponentEventDispatcher.java:46)
at $Dispatcher_11e92711107e.dispatch(Unknown Source)
at $Dispatcher_11e927111078.dispatch(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$RequestHandlerTerminator.service(TapestryModule.java:302)
at org.apache.tapestry5.internal.services.RequestErrorFilter.service(RequestErrorFilter.java:26)
at $RequestHandler_11e927111079.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$3.service(TapestryModule.java:902)
at $RequestHandler_11e927111079.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$2.service(TapestryModule.java:892)
at $RequestHandler_11e927111079.service(Unknown Source)
at org.apache.tapestry5.internal.services.StaticFilesFilter.service(StaticFilesFilter.java:90)
at $RequestHandler_11e927111079.service(Unknown Source)
at com.packtpub.services.AppModule$1.service(AppModule.java:98)
at $RequestFilter_11e927111074.service(Unknown Source)
at $RequestHandler_11e927111079.service(Unknown Source)
at $RequestHandler_11e92711106d.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$HttpServletRequestHandlerTerminator.service(TapestryModule.java:253)
at org.apache.tapestry5.internal.gzip.GZipFilter.service(GZipFilter.java:53)
at $HttpServletRequestHandler_11e92711106f.service(Unknown Source)
at org.apache.tapestry5.internal.services.IgnoredPathsFilter.service(IgnoredPathsFilter.java:62)
at $HttpServletRequestFilter_11e92711106b.service(Unknown Source)
at $HttpServletRequestHandler_11e92711106f.service(Unknown Source)
at org.apache.tapestry5.services.TapestryModule$1.service(TapestryModule.java:852)
at $HttpServletRequestHandler_11e92711106f.service(Unknown Source)
at $HttpServletRequestHandler_11e92711106a.service(Unknown Source)
at org.apache.tapestry5.TapestryFilter.doFilter(TapestryFilter.java:171)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1822)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.tapestry5.runtime.ComponentEventException: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider [at classpath:com/packtpub/pages/Index.tml, line 19]
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1136)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.access$3100(ComponentPageElementImpl.java:61)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1057)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl$5.invoke(ComponentPageElementImpl.java:1054)
at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.invoke(OperationTrackerImpl.java:74)
... 58 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.packtpub.services.ObjectService.AddObject(ObjectService.java:27)
at $IObjectService_11e92711112a.AddObject(Unknown Source)
at $IObjectService_11e9271110ab.AddObject(Unknown Source)
at com.packtpub.pages.Index.onActionFromIncrement(Index.java:61)
at com.packtpub.pages.Index.dispatchComponentEvent(Index.java)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.dispatchEvent(ComponentPageElementImpl.java:927)
at org.apache.tapestry5.internal.structure.ComponentPageElementImpl.processEventTriggering(ComponentPageElementImpl.java:1112)
... 62 more
Caused by: java.lang.NoClassDefFoundError: org/hibernate/cache/CacheProvider
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2442)
at java.lang.Class.privateGetPublicMethods(Class.java:2562)
at java.lang.Class.getMethods(Class.java:1427)
at java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1261)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1122)
at java.beans.Introspector.getBeanInfo(Introspector.java:414)
at java.beans.Introspector.getBeanInfo(Introspector.java:161)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:224)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:149)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:324)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptorInternal(BeanWrapperImpl.java:354)
at org.springframework.beans.BeanWrapperImpl.isWritableProperty(BeanWrapperImpl.java:430)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1362)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
... 79 more
Caused by: java.lang.ClassNotFoundException: org.hibernate.cache.CacheProvider
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
... 95 more
[INFO] AppModule.TimingFilter Request time: 714 ms
Based on that exception, you have conflicting jars. You haven't posted the full pom, but I see you mixed a spring 2.0 (spring-jdbc) with spring 3.1.1 jars. You need to see the entire dependency tree and figure out where the conflicting hibernate jar is coming from. Use the the following maven command to see the dependency tree: mvn dependency:tree

Categories