I have a very pesky problem and i can't seem to find the answer anywhere.
My application throws this exception when trying to persist a @Lob:
java.lang.AbstractMethodError
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setCharacterStream(DelegatingPreparedStatement.java:328)
at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setCharacterStream(DelegatingPreparedStatement.java:328)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy32.setCharacterStream(Unknown Source)
at org.hibernate.type.descriptor.sql.ClobTypeDescriptor$3$1.doBind(ClobTypeDescriptor.java:83)
at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:92)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:280)
at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:275)
at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:57)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2747)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3152)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3087)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3416)
at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:140)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:276)
at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1213)
at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:402)
at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101)
...(more)
I am running on Tomcat 6.0.36(also tried tomcat 7).
MySQL 4.1.22 database.
Code is compiled with jdk 7 and built with gradle.
My dependencies are:
+--- javax.mail:mail:1.4 -> 1.4.1
| \--- javax.activation:activation:1.1
+--- org.slf4j:slf4j-api:1.5.6 -> 1.6.1
+--- log4j:log4j:1.2.13 -> 1.2.16
+--- org.apache.wicket:wicket:1.4.15
| \--- org.slf4j:slf4j-api:1.5.8 -> 1.6.1
+--- org.apache.wicket:wicket-extensions:1.4.15
| +--- org.apache.wicket:wicket:1.4.15 (*)
| \--- org.slf4j:slf4j-api:1.5.8 -> 1.6.1
+--- mysql:mysql-connector-java:5.1.26
+--- com.microsoft.sqlserver:sqljdbc4:4.0
+--- com.itextpdf:itextpdf:5.4.2
+--- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.0.Final -> 1.0.1.Final
+--- org.hibernate:hibernate-core:4.1.9.Final
| +--- antlr:antlr:2.7.7
| +--- org.jboss.logging:jboss-logging:3.1.0.GA
| +--- org.javassist:javassist:3.17.1-GA
| +--- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.0.Final
| +--- dom4j:dom4j:1.6.1
| | \--- xml-apis:xml-apis:1.0.b2
| +--- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final
| \--- org.hibernate.common:hibernate-commons-annotations:4.0.1.Final
| \--- org.jboss.logging:jboss-logging:3.1.0.CR2 -> 3.1.0.GA
+--- org.hibernate:hibernate-entitymanager:4.1.9.Final
| +--- org.jboss.logging:jboss-logging:3.1.0.GA
| +--- org.javassist:javassist:3.17.1-GA
| +--- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:1.0.0.Final
| +--- dom4j:dom4j:1.6.1 (*)
| +--- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final
| +--- org.hibernate:hibernate-core:4.1.9.Final (*)
| \--- org.hibernate.common:hibernate-commons-annotations:4.0.1.Final (*)
+--- foo.bar.data-services:foor-bar-data:2.0.0.275
| +--- org.slf4j:slf4j-api:1.6.1
| +--- org.hibernate:hibernate-core:4.1.6.Final -> 4.1.9.Final (*)
| +--- org.hibernate.javax.persistence:hibernate-jpa-2.0-api::1.0.1.Final -> 1.0.1.Final
| +--- org.slf4j:slf4j-log4j12:1.6.1
| | +--- org.slf4j:slf4j-api:1.6.1
| | \--- log4j:log4j:1.2.16
| +--- log4j:log4j:1.2.16
| \--- commons-configuration:commons-configuration:1.9
| +--- commons-lang:commons-lang:2.6
| \--- commons-logging:commons-logging:1.1.1
+--- javax.transaction:jta:1.1
+--- dom4j:dom4j:1.6.1 (*)
+--- antlr:antlr:2.7.6 -> 2.7.7
+--- commons-collections:commons-collections:3.2.1
+--- commons-configuration:commons-configuration:1.9 (*)
+--- commons-dbcp:commons-dbcp:1.4
| \--- commons-pool:commons-pool:1.5.4 -> 1.5.7
+--- commons-pool:commons-pool:1.5.7
+--- commons-logging:commons-logging:1.1.1
+--- commons-dbutils:commons-dbutils:1.4
+--- commons-lang:commons-lang:2.6
+--- commons-io:commons-io:2.4
+--- org.apache.commons:commons-email:1.2
| +--- javax.mail:mail:1.4.1 (*)
| \--- javax.activation:activation:1.1
+--- javax.servlet:servlet-api:2.5
+--- javax.servlet.jsp:jsp-api:2.1
\--- org.slf4j:slf4j-log4j12:1.5.6 -> 1.6.1 (*)
So looking at the exception, it seems like the application is trying to call the tomcat-dbcp.jar in the CATALINA_BASE/lib folder. But i would expect it to call my commons-dbcp.jar in my classpath.
But frankly i'm at a loss, i tried a lot of things, but can't seem to get this working... Thanks in advance for your help. Tell me if you need more information.
EDIT 1:
server.xml
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener SSLEngine="on" className="org.apache.catalina.core.AprLifecycleListener"/>
<Listener className="org.apache.catalina.core.JasperListener"/>
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<GlobalNamingResources>
<Resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase"/>
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" logAbandoned="true" maxActive="100" maxIdle="10" maxWait="10000" name="jdbc/foo" removeAbandoned="true" removeAbandonedTimeout="300" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/foo?autoReconnect=true&dumpQueriesOnException=true" username="root" validationQuery="select 1"/>
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver" logAbandoned="true" maxActive="20" maxIdle="5" maxWait="10000" name="jdbc/bar" removeAbandoned="true" removeAbandonedTimeout="300" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/bar?autoReconnect=true&dumpQueriesOnException=true" username="root" validationQuery="select 1"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
<Engine defaultHost="localhost" name="Catalina">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true" xmlNamespaceAware="false" xmlValidation="false">
<Context docBase="foo" path="/foo" reloadable="true" source="org.eclipse.jst.j2ee.server:foo"/></Host>
</Engine>
</Service>
</Server>
The solution was to use tomcat 7. This has a version of tomcat-dbcp.jar that actually has the DelegatingPreparedStatement.setCharacterStream that the application needed.
My problem was that when i tried it on my tomcat 7 server, i still got the same error at the same place in my application. This was caused by an old version of mysql-connector-java(5.0.5 if i remember correctly) that was lingering in my tomcat lib folder due to earlier attempts to make this work. This older version apparently had precedence over my own mysql-connector-java(newest version) that i have as a dependency. Because this gave me the same exception, it seemed that it did not change anything in my situation, while it actually did.
When i figured this out, the rest was easy, my only problem was that i couldn't upgrade very easily to tomcat 7, since other applications are currently running on our tomcat 6 version in the production environment. So the solution was to copy the tomcat-dbcp.jar from a tomcat 7 dist to our tomcat 6 server and replacing the one that was already there.
Hope this will help others as well, thanks to everyone for all the help in any case!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With