setCharacterStream引起的AbstractMethodError

时间:2016-05-17 11:45:44

标签: java spring

我正在部署一场正在我自己的机器上运行并发生错误的战争:

java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V

完整堆栈跟踪:

14:35:18.734 [scheduler-1] ERROR o.s.s.s.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task.
java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V
        at org.hibernate.type.descriptor.sql.ClobTypeDescriptor$4$1.doBind(ClobTypeDescriptor.java:131) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:90) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:286) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:281) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:56) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2857) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3121) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3581) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:104) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:463) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:349) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:350) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:56) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1222) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.internal.SessionImpl.managedFlush(SessionImpl.java:425) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.beforeTransactionCommit(JdbcTransaction.java:101) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.commit(AbstractTransactionImpl.java:177) ~[hibernate-core-4.3.6.Final.jar:4.3.6.Final]
        at org.hibernate.jpa.internal.TransactionImpl.commit(TransactionImpl.java:77) ~[hibernate-entitymanager-4.3.6.Final.jar:4.3.6.Final]
        at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:515) ~[spring-orm-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757) ~[spring-tx-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726) ~[spring-tx-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:478) ~[spring-tx-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:272) ~[spring-tx-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95) ~[spring-tx-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) ~[spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) ~[spring-aop-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at com.sun.proxy.$Proxy73.apply(Unknown Source) ~[na:na]
        at ec.europa.eu.egrants.emailmonitoring.services.chains.forms.ApplicationFormChain.apply(ApplicationFormChain.java:37) ~[email-monitoring-1.0-SNAPSHOT.jar:na]
        at ec.europa.eu.egrants.emailmonitoring.services.chains.forms.ApplicationFormChain.apply(ApplicationFormChain.java:19) ~[email-monitoring-1.0-SNAPSHOT.jar:na]
        at ec.europa.eu.egrants.emailmonitoring.ChainService.forEach(ChainService.java:50) ~[email-monitoring-1.0-SNAPSHOT.jar:na]
        at ec.europa.eu.egrants.emailmonitoring.ChainService.execute(ChainService.java:62) ~[email-monitoring-1.0-SNAPSHOT.jar:na]
        at ec.europa.eu.egrants.emailmonitoring.services.email.EmailLocalFolderMonitor.execute(EmailLocalFolderMonitor.java:81) ~[email-monitoring-1.0-SNAPSHOT.jar:na]
        at ec.europa.eu.egrants.emailmonitoring.services.email.EmailScheduler.pollEmails(EmailScheduler.java:27) ~[email-monitoring-1.0-SNAPSHOT.jar:na]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_71]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_71]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_71]
        at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_71]
        at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) ~[spring-context-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-4.0.7.RELEASE.jar:4.0.7.RELEASE]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [na:1.7.0_71]
        at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:304) [na:1.7.0_71]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:178) [na:1.7.0_71]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.7.0_71]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_71]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_71]
        at java.lang.Thread.run(Thread.java:745) [na:1.7.0_71]

更新

1)在互联网上阅读我{@ 3}}的消息:

  

将Hibernate与c3p0一起使用。

     

尝试升级后我遇到了完全相同的问题   Hibernate 4.1.3到4.1.8。

     

降级回4.1.3解决了这个问题。

     

c3p0版本在两种情况下都是相同的:0.9.1。

2)https://developer.jboss.org/thread/213711?tstart=0&_sscc=t状态的答案可能是"由于某些jar文件中的版本不兼容。"

3)同样的错误:Abstract Method Error

UPDATE2

我可以通过更改Resource driverClass中的server.xml来绕过错误(修复?)。

我有以下内容:

<Resource auth="Container"
      driverClass="oracle.jdbc.OracleDriver"
      maxPoolSize="20"
      minPoolSize="2"
      acquireIncrement="1"
      name="jdbc/g"
      user="egrants" 
      password="egrants"
      factory="org.apache.naming.factory.BeanFactory"
      type="com.mchange.v2.c3p0.ComboPooledDataSource"
      jdbcUrl="jdbc:oracle:thin:@//localhost:1521/XE"
      automaticTestTable="t_test_c3p0" idleConnectionTestPeriod="300"/>

更改为以下内容会停止错误:

<Resource
        name="jdbc/g"
        auth="Container"
        type="javax.sql.DataSource"
        driverClassName="oracle.jdbc.OracleDriver"
        url="jdbc:oracle:thin:@127.0.0.1:1521:xe"
       factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
        username="root"
        password="root"
        maxActive="20"
        validationQuery="SELECT 1 FROM DUAL;"
        testOnBorrow="true"
        maxIdle="10"
        maxWait="-1"/>

我有一种感觉,尽管此开关必须有一个缩减,因为之前的开发人员已经编写了上一个定义。

我如何使用原始c3p0定义但避免错误?

接下来要尝试的事情:

  1. 更改tomcat服务器上的jar文件?
  2. 修改我的pom.xml

1 个答案:

答案 0 :(得分:1)

摘要

我找到了两个解决方法/修复:

  1. 更新tomcat/lib文件夹
  2. 中的JAR文件
  3. 切换到server.xml资源定义中的其他驱动程序。
  4. 更新Jar文件

    在我的pom.xml中添加一个定义并不奇怪,因为它们似乎没有在战争中生成。我试图更新tomcat/lib文件夹中的jar。

    cd apache-tomcat-6_0_36-ep-01/lib
    ls
    mv c3p0-0.9.2-pre4.jar c3p0-0.9.2-pre4.jar.OLD
    wget http://central.maven.org/maven2/com/mchange/c3p0/0.9.5/c3p0-0.9.5.jar
    
    mv mchange-commons-java-0.2.2.jar mchange-commons-java-0.2.2.jar.OLD
    wget http://central.maven.org/maven2/com/mchange/mchange-commons-java/0.2.9/mchange-commons-java-0.2.9.jar
    

    切换到不同的驱动程序

    我可以通过更改Resource driverClass中的server.xml来绕过错误(修复?)。

    我有以下内容:

    <Resource auth="Container"
          driverClass="oracle.jdbc.OracleDriver"
          maxPoolSize="20"
          minPoolSize="2"
          acquireIncrement="1"
          name="jdbc/g"
          user="root" 
          password="root"
          factory="org.apache.naming.factory.BeanFactory"
          type="com.mchange.v2.c3p0.ComboPooledDataSource"
          jdbcUrl="jdbc:oracle:thin:@//localhost:1521/XE"
          automaticTestTable="t_test_c3p0" idleConnectionTestPeriod="300"/>
    

    更改为以下内容会停止错误:

    <Resource
            name="jdbc/g"
            auth="Container"
            type="javax.sql.DataSource"
            driverClassName="oracle.jdbc.OracleDriver"
            url="jdbc:oracle:thin:@127.0.0.1:1521:xe"
           factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
            username="root"
            password="root"
            maxActive="20"
            validationQuery="SELECT 1 FROM DUAL;"
            testOnBorrow="true"
            maxIdle="10"
            maxWait="-1"/>
    

    我有一种感觉,尽管此开关必须有一个缩减,因为之前的开发人员已经编写了上一个定义。