3

私のプロジェクトは初期段階にあり、休止状態に大きな問題があります。c3p0 0.9.1.2 で hibernate 4.1.8-Final を使用しています。

私は次のエンティティクラスを持っています:

@javax.persistence.Entity
@Table(name = "CUSTOMER")
public class Customer extends Entity {

    @Transient
    private static final long serialVersionUID = 3326144323537452197L;

    private String customerId;
    private String customerName;
    private boolean active;

    public Customer() {
        super();
    }

    @NaturalId
    @Column(name = "CUSTOMER_ID", nullable = false)
    public String getCustomerId() {
        return customerId;
    }

    public void setCustomerId(String customerId) {
        this.customerId = customerId;
    }

    @Lob
    @Column(name = "CUSTOMER_NAME", nullable = false)
    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    @Column(name = "ACTIVE", nullable = false)
    public boolean isActive() {
        return active;
    }

    public void setActive(boolean active) {
        this.active = active;
    }
}

ご覧のとおり、customerNameに設定されていLobます。最初の保存操作で次のエラーが発生しました。

2012-12-15 01:37:25,670 ERROR [com.edfx.adb.web.controller.AdminController] java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V
2012-12-15 01:37:25,670 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-12-15 01:37:25,670 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2012-12-15 01:37:25,670 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2012-12-15 01:37:25,670 ERROR [com.edfx.adb.web.controller.AdminController]     at java.lang.reflect.Method.invoke(Method.java:601)
2012-12-15 01:37:25,670 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.engine.jdbc.internal.proxy.AbstractStatementProxyHandler.continueInvocation(AbstractStatementProxyHandler.java:122)
2012-12-15 01:37:25,670 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
2012-12-15 01:37:25,670 ERROR [com.edfx.adb.web.controller.AdminController]     at $Proxy240.setCharacterStream(Unknown Source)
2012-12-15 01:37:25,670 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.type.descriptor.sql.ClobTypeDescriptor$3$1.doBind(ClobTypeDescriptor.java:83)
2012-12-15 01:37:25,685 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.type.descriptor.sql.BasicBinder.bind(BasicBinder.java:92)
2012-12-15 01:37:25,685 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:280)
2012-12-15 01:37:25,685 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.type.AbstractStandardBasicType.nullSafeSet(AbstractStandardBasicType.java:275)
2012-12-15 01:37:25,701 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.type.AbstractSingleColumnStandardBasicType.nullSafeSet(AbstractSingleColumnStandardBasicType.java:57)
2012-12-15 01:37:25,701 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2747)
2012-12-15 01:37:25,701 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:2722)
2012-12-15 01:37:25,701 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.persister.entity.AbstractEntityPersister$4.bindValues(AbstractEntityPersister.java:2929)
2012-12-15 01:37:25,701 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:57)
2012-12-15 01:37:25,716 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2936)
2012-12-15 01:37:25,716 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3447)
2012-12-15 01:37:25,716 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81)
2012-12-15 01:37:25,716 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
2012-12-15 01:37:25,716 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:203)
2012-12-15 01:37:25,732 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:183)
2012-12-15 01:37:25,732 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:167)
2012-12-15 01:37:25,732 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:320)
2012-12-15 01:37:25,732 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
2012-12-15 01:37:25,748 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193)
2012-12-15 01:37:25,748 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:126)
2012-12-15 01:37:25,748 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:204)
2012-12-15 01:37:25,748 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
2012-12-15 01:37:25,748 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:189)
2012-12-15 01:37:25,763 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
2012-12-15 01:37:25,763 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
2012-12-15 01:37:25,763 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:756)
2012-12-15 01:37:25,763 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.internal.SessionImpl.save(SessionImpl.java:748)
2012-12-15 01:37:25,779 ERROR [com.edfx.adb.web.controller.AdminController]     at org.hibernate.internal.SessionImpl.save(SessionImpl.java:744)
2012-12-15 01:37:25,779 ERROR [com.edfx.adb.web.controller.AdminController]     at com.edfx.adb.dao.base.BaseDao.save(BaseDao.java:21)
2012-12-15 01:37:25,779 ERROR [com.edfx.adb.web.controller.AdminController]     at com.edfx.adb.service.CustomerService.addNewCustomer(CustomerService.java:26)
2012-12-15 01:37:25,779 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-12-15 01:37:25,779 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2012-12-15 01:37:25,794 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2012-12-15 01:37:25,794 ERROR [com.edfx.adb.web.controller.AdminController]     at java.lang.reflect.Method.invoke(Method.java:601)
2012-12-15 01:37:25,794 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
2012-12-15 01:37:25,794 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
2012-12-15 01:37:25,794 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
2012-12-15 01:37:25,794 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
2012-12-15 01:37:25,810 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
2012-12-15 01:37:25,810 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
2012-12-15 01:37:25,810 ERROR [com.edfx.adb.web.controller.AdminController]     at $Proxy236.addNewCustomer(Unknown Source)
2012-12-15 01:37:25,810 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-12-15 01:37:25,810 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2012-12-15 01:37:25,826 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2012-12-15 01:37:25,826 ERROR [com.edfx.adb.web.controller.AdminController]     at java.lang.reflect.Method.invoke(Method.java:601)
2012-12-15 01:37:25,826 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:319)
2012-12-15 01:37:25,841 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
2012-12-15 01:37:25,841 ERROR [com.edfx.adb.web.controller.AdminController]     at $Proxy237.addNewCustomer(Unknown Source)
2012-12-15 01:37:25,841 ERROR [com.edfx.adb.web.controller.AdminController]     at com.edfx.adb.web.controller.AdminController.saveCustomer(AdminController.java:25)
2012-12-15 01:37:25,841 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2012-12-15 01:37:25,841 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
2012-12-15 01:37:25,841 ERROR [com.edfx.adb.web.controller.AdminController]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2012-12-15 01:37:25,857 ERROR [com.edfx.adb.web.controller.AdminController]     at java.lang.reflect.Method.invoke(Method.java:601)
2012-12-15 01:37:25,857 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.el.parser.AstValue.invoke(AstValue.java:262)
2012-12-15 01:37:25,857 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:278)
2012-12-15 01:37:25,857 ERROR [com.edfx.adb.web.controller.AdminController]     at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
2012-12-15 01:37:25,857 ERROR [com.edfx.adb.web.controller.AdminController]     at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:148)
2012-12-15 01:37:25,872 ERROR [com.edfx.adb.web.controller.AdminController]     at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
2012-12-15 01:37:25,872 ERROR [com.edfx.adb.web.controller.AdminController]     at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
2012-12-15 01:37:25,872 ERROR [com.edfx.adb.web.controller.AdminController]     at javax.faces.component.UICommand.broadcast(UICommand.java:300)
2012-12-15 01:37:25,872 ERROR [com.edfx.adb.web.controller.AdminController]     at javax.faces.component.UIData.broadcast(UIData.java:1093)
2012-12-15 01:37:25,872 ERROR [com.edfx.adb.web.controller.AdminController]     at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
2012-12-15 01:37:25,888 ERROR [com.edfx.adb.web.controller.AdminController]     at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
2012-12-15 01:37:25,888 ERROR [com.edfx.adb.web.controller.AdminController]     at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
2012-12-15 01:37:25,888 ERROR [com.edfx.adb.web.controller.AdminController]     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
2012-12-15 01:37:25,904 ERROR [com.edfx.adb.web.controller.AdminController]     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
2012-12-15 01:37:25,904 ERROR [com.edfx.adb.web.controller.AdminController]     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
2012-12-15 01:37:25,904 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
2012-12-15 01:37:25,904 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
2012-12-15 01:37:25,904 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:119)
2012-12-15 01:37:25,919 ERROR [com.edfx.adb.web.controller.AdminController]     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
2012-12-15 01:37:25,919 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
2012-12-15 01:37:25,919 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
2012-12-15 01:37:25,919 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
2012-12-15 01:37:25,935 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
2012-12-15 01:37:25,935 ERROR [com.edfx.adb.web.controller.AdminController]     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
2012-12-15 01:37:25,935 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
2012-12-15 01:37:25,935 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
2012-12-15 01:37:25,935 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
2012-12-15 01:37:25,950 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
2012-12-15 01:37:25,950 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
2012-12-15 01:37:25,950 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
2012-12-15 01:37:25,950 ERROR [com.edfx.adb.web.controller.AdminController]     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
2012-12-15 01:37:25,950 ERROR [com.edfx.adb.web.controller.AdminController]     at java.lang.Thread.run(Thread.java:722)

簡単に言えば、エラーメッセージは次のとおりです。

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

このエラーをグーグルで検索すると、最初のリンクで、休止状態の 4.1.3-Final にダウングレードすると問題を解決できることがわかりました。そして、それはうまくいきました。しかし、私の目的は、最新バージョンの休止状態を使用することです。休止状態には接続プールがあまりないことを読みました。接続プールが必要な場合の原因。サーバーからそのプールを取得します。

私の質問は、JBoss AS 7 で実行されている実稼働環境で、サードパーティの c3p0 を使用する必要があるかどうかです。そうでない場合は、c3p0 を削除できます。または、この問題の解決策はありますか?

4

3 に答える 3

11

c3p0-0.9.2-pre7 にアップデートしてください。これは成熟しています。予期せぬ事態が発生しない限り、次のリリースは c3p0-0.9.2 final になります。hibernate は最近、いくつかの JDBC4 依存関係を追加しました。c3p0 はまだ JDBC4 を完全にサポートしていません (ただし、0.9.2 が完成した後)、c3p0-0.9.2-pre7 はこれらのメソッドをサポートして休止状態の依存関係を維持します。

0.9.2-pre7 は、0.9.1.2 のドロップイン置換です。c3p0-0.9.1.2.jar を削除して、c3p0-0.9.2-pre7.jar と mchange-commons-java-0.2.3.2.jar の両方に置き換えます。または、Maven central [groupId: com.mchange, artifactId: c3p0, version: 0.9.2-pre7] を使用して、推移的な依存関係に残りを任せます。ダウンロード情報などについては、ドキュメントの一番上、http: //www.mchange.com/projects/c3p0/ を参照してください。

hibernate では c3p0 は必要ありません。他の接続プールを使用できます。しかし、私は偏見がありますが、c3p0 はかなり良い選択だと思います! (私は c3p0 の作者です。)

于 2012-12-14T23:11:28.410 に答える
4

新しいバージョンの hibernate は と互換性がありません0.9.1.1hibernate-c3p0:4.3.0.CR1に明示的に依存するものを使用しc3p0:0.9.2.1ます。

考えられる原因:

  • プロジェクトには、推移的な依存関係として c3p0 の古いバージョンを使用する他の依存関係がある可能性があります
  • 古いグループ ID はc3p0であり、新しいグループ ID は であるためcom.mchange、maven は両方をクラスパスに追加した可能性があります。
  • 偶然、クラスローダーがc3p0:c3p0:0.9.1.1代わりにクラスをロードcom.mchange:c3p0:0.9.2.1しました (groupId は変更されていますが、パッケージは同じです)。

ソリューション

c3p0 依存関係の grep

`$mvn dependency:tree |grep -B5 "c3p0"`
[INFO] +- org.hibernate:hibernate-c3p0:jar:4.3.0.CR1:compile
[INFO] |  \- com.mchange:c3p0:jar:0.9.2.1:compile
[INFO] |     \- com.mchange:mchange-commons-java:jar:0.2.3.4:compile
--
[INFO] +- org.quartz-scheduler:quartz:jar:2.2.1:compile
[INFO] |  \- c3p0:c3p0:jar:0.9.1.1:compile

古いものを除外してください!

<dependency>
    <groupId>org.quartz-scheduler</groupId>
    <artifactId>quartz</artifactId>
    <version>${quartz.version}</version>
    <exclusions>
        <exclusion>
             <groupId>c3p0</groupId>
             <artifactId>c3p0</artifactId>
             <!-- Bcoz this version is incompatible with hibernate -->
         </exclusion>
    </exclusions>
</dependency>
于 2014-11-13T08:51:49.977 に答える
2

hibernate-core 4.2.8.Final、hibernate-c3p0 4.2.8.Final、c3p0 0.9.2.x。同様の問題がありました: java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setNString(ILjava/lang/String;)V

c3p0 のバージョンを 0.9.5-pre6 に変更し、問題を修正しました。

于 2013-12-16T11:26:40.780 に答える