2011-08-11 24 views
1

現在、JPA JerseyサーブレットとImで依存関係注入にGuiceを使用しようとしています。問題は、私は次のエラーを取得することを、次のとおりです。Google GuiceとJPA注入 - 奇妙なエラー

Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: com.google.inject.CreationException: Guice creation errors: 

1) null returned by binding at com.google.inject.persist.jpa.JpaPersistModule.configurePersistence(JpaPersistModule.java:63) 
but parameter 1 of com.google.inject.persist.jpa.JpaPersistService.<init>() is not @Nullable 
    while locating java.util.Properties annotated with @com.google.inject.persist.jpa.Jpa() 
    for parameter 1 at com.google.inject.persist.jpa.JpaPersistService.<init>(JpaPersistService.java:43) 
at com.google.inject.persist.jpa.JpaPersistModule.configurePersistence(JpaPersistModule.java:67) 
while locating com.google.inject.persist.jpa.JpaPersistService 
    for field at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.emProvider(JpaLocalTxnInterceptor.java:33) 
at com.google.inject.persist.jpa.JpaPersistModule.configurePersistence(JpaPersistModule.java:76) 

2) null returned by binding at com.google.inject.persist.jpa.JpaPersistModule.configurePersistence(JpaPersistModule.java:63) 
but parameter 1 of com.google.inject.persist.jpa.JpaPersistService.<init>() is not @Nullable 
    while locating java.util.Properties annotated with @com.google.inject.persist.jpa.Jpa() 
    for parameter 1 at com.google.inject.persist.jpa.JpaPersistService.<init>(JpaPersistService.java:43) 
    at com.google.inject.persist.jpa.JpaPersistModule.configurePersistence(JpaPersistModule.java:67) 
    while locating com.google.inject.persist.jpa.JpaPersistService 
    while locating com.google.inject.persist.UnitOfWork 
    for field at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.unitOfWork(JpaLocalTxnInterceptor.java:36) 
    at com.google.inject.persist.jpa.JpaPersistModule.configurePersistence(JpaPersistModule.java:76) 
2 errors 

私はこのエラーを生成するコードは次のとおりです。

install(new JpaPersistModule("theseen")); 
filter("/*").through(PersistFilter.class); 

私はEntitiManagerをインスタンス化し、これらの行のコメントを外すことで、「標準」の方法を使用している場合、 何も起こりません。

EntityManagerFactory emf = Persistence 
      .createEntityManagerFactory("theseen"); 
EntityManager em = emf.createEntityManager(); 

em.getTransaction().begin(); 
em.merge(s); 
em.getTransaction().commit(); 

は魅力的です。だから、データベース接続が正常でなければならないと思う。

エラーになる可能性はありますか?私は別のテスト環境で同じアプリケーションをテストし、それは動作します!どちらのマシンも、Glassfish 3.1、Eclipse Indigoとm2eclipse、m2wtpの統合を使用しています。私はGuice 3.0をguice-persist 3.0とguice-servlet 3.0で使用します。アプリケーションが動作しているマシンはOpenJDKを使ってUbuntu 11.04を実行し、問題が発生するマシンはWindows 7とJDK1.6v26を使用します。私は通常、Glassfishが提供するデータソースを使用しますが、プレーンなpersistence.xmlを使用しても動作しません。

私は真剣に混乱しています... Guice Injection for JPAの問題は何ですか?

答えて

2

誰もが私が強引に行ってきました答えていないので:

完全GlassfishのとWebAppの再インストール働いていた...

何かが私のローカルマシン上で、ここでのテストの長いヶ月の間に破壊されている必要があります。

+2

私は、google closure template jarがguice 3.0とguice 2.0を混ぜ合わせることによってguiceを逆さまにしてしまうことを発見しました。それは不可能なものを使用します... – Johnnycube

+0

あなたのコメントは本当に助けになりました!非常に同じエラーがありました。原因は、以前のバージョンのTestNGをmavenビルドのguice 3とともに使用していたためです。その古いTestNG jarはguice 2を内部に持っていました...最新のTestNGバージョンに置き換えられ、テストは再び実行されます。私の正しい方向性を与えてくれてありがとう! –