gpt4 book ai didi

java - setCharacterStream 引起的 AbstractMethodError

转载 作者:行者123 更新时间:2023-11-30 07:22:45 26 4
gpt4 key购买 nike

我正在部署一个在我自己的机器上运行的 war 并收到错误:

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)在互联网上阅读我的消息帖子@https://developer.jboss.org/thread/213711?tstart=0&_sscc=t :

use Hibernate with c3p0.

I had exactly the same problem after an attempt to upgrade from Hibernate 4.1.3 to 4.1.8.

Downgrading back to 4.1.3 solved the problem.

c3p0 version in both cases is the same: 0.9.1.

2) 答案为Abstract Method Error指出这可能是“由于某些 jar 文件中的版本不兼容。”

3) 同样的错误:Error when saving @Lob with hibernate java mysql

更新2

通过更改 server.xml 中的 Resource driverClass,我能够绕过该错误(修复?)。

我有以下内容:

<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. 更新 tomcat/lib 文件夹中的 JAR 文件
  2. 在我的 server.xml 资源定义中切换到不同的驱动程序。

更新 Jar 文件

在我的pom.xml中添加定义并不奇怪,因为它们似乎不是在 war 中生成的。我求助于更新 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

切换到不同的驱动程序

通过更改 server.xml 中的 Resource driverClass,我能够绕过该错误(修复?)。

我有以下内容:

<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"/>

我有一种感觉,因为之前的开发人员已经编写了之前的定义,所以这个开关一定有一个缺点。

关于java - setCharacterStream 引起的 AbstractMethodError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37275208/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com