2011-08-15 18 views
1

J2EEアプリケーションをjdk1.4からjdk1.6にアップグレードしている途中で、別のアプリケーションサーバーに移行しています。はい、たくさんの動く部分。しかし、私はMockrunnerとMockEjbを使っていくつかのjunitテストを書いていました。私は次のようなものを呼び出します。 MockContextFactory.setAsInitial(); InitialContext context = new InitialContext(); 次にクラスをコンテキストにバインドします。jdk1.6へのアップグレード時にMockEJBが失敗する

しかし、新しいInitialContext()を作成しようとする私のすべてのテストは、このようなスタックトレースで失敗し、なぜそれが分からないのですか?すべてのヘルプははるかに高く評価され、感謝、

junit.framework.AssertionFailedError: Exception in constructor: test_notExactfindMatch (java.lang.ExceptionInInitializerError 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at net.sf.cglib.proxy.EnhancerEmitter.setThreadCallbacks(EnhancerEmitter.java:194) 
    at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:371) 
    at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:351) 
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:193) 
    at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:330) 
    at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:246) 
    at org.mockejb.interceptor.InterceptableProxy.create(InterceptableProxy.java:43) 
    at org.mockejb.jndi.MockContextFactory.getInitialContext(MockContextFactory.java:47) 
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) 
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) 
    at javax.naming.InitialContext.init(InitialContext.java:223) 
    at javax.naming.InitialContext.<init>(InitialContext.java:175) 
    at com.princetonecom.rtds.billerfinder.BillerSynonymFinderTest.<init>(BillerSynonymFinderTest.java:42) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
    at junit.framework.TestSuite.createTest(TestSuite.java:61) 
    at junit.framework.TestSuite.addTestMethod(TestSuite.java:283) 
    at junit.framework.TestSuite.<init>(TestSuite.java:146) 
    at org.junit.internal.runners.JUnit38ClassRunner.<init>(JUnit38ClassRunner.java:71) 
    at org.junit.internal.builders.JUnit3Builder.runnerForClass(JUnit3Builder.java:14) 
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) 
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29) 
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) 
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null 
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:206) 
    at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:92) 
    at net.sf.cglib.proxy.MethodProxy.helper(MethodProxy.java:115) 
    at net.sf.cglib.proxy.MethodProxy.create(MethodProxy.java:86) 
    at javax.naming.Context$$EnhancerByCGLIB$$b7a6712.<clinit>(<generated>) 
    ... 38 more 
Caused by: java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:373) 
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:193) 
    ... 42 more 
Caused by: java.lang.SecurityException: Prohibited package name: java.lang 
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:401) 
    ... 48 more 
) 
    at junit.framework.Assert.fail(Assert.java:47) 
    at junit.framework.TestSuite$1.runTest(TestSuite.java:97) 
    at junit.framework.TestCase.runBare(TestCase.java:134) 
    at junit.framework.TestResult$1.protect(TestResult.java:110) 
    at junit.framework.TestResult.runProtected(TestResult.java:128) 
    at junit.framework.TestResult.run(TestResult.java:113) 
    at junit.framework.TestCase.run(TestCase.java:124) 
    at junit.framework.TestSuite.runTest(TestSuite.java:232) 
    at junit.framework.TestSuite.run(TestSuite.java:227) 
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 

junit.framework.AssertionFailedError: Exception in constructor: test_notStartsWithFindMatch (java.lang.ExceptionInInitializerError 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at net.sf.cglib.proxy.EnhancerEmitter.setThreadCallbacks(EnhancerEmitter.java:194) 
    at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:371) 
    at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:351) 
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:193) 
    at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:330) 
    at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:246) 
    at org.mockejb.interceptor.InterceptableProxy.create(InterceptableProxy.java:43) 
    at org.mockejb.jndi.MockContextFactory.getInitialContext(MockContextFactory.java:47) 
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) 
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288) 
    at javax.naming.InitialContext.init(InitialContext.java:223) 
    at javax.naming.InitialContext.<init>(InitialContext.java:175) 
    at com.princetonecom.rtds.billerfinder.BillerSynonymFinderTest.<init>(BillerSynonymFinderTest.java:42) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) 
    at junit.framework.TestSuite.createTest(TestSuite.java:61) 
    at junit.framework.TestSuite.addTestMethod(TestSuite.java:283) 
    at junit.framework.TestSuite.<init>(TestSuite.java:146) 
    at org.junit.internal.runners.JUnit38ClassRunner.<init>(JUnit38ClassRunner.java:71) 
    at org.junit.internal.builders.JUnit3Builder.runnerForClass(JUnit3Builder.java:14) 
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) 
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29) 
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57) 
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null 
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:206) 
    at net.sf.cglib.reflect.FastClass$Generator.create(FastClass.java:92) 
    at net.sf.cglib.proxy.MethodProxy.helper(MethodProxy.java:115) 
    at net.sf.cglib.proxy.MethodProxy.create(MethodProxy.java:86) 
    at javax.naming.Context$$EnhancerByCGLIB$$b7a6712-2.<clinit>(<generated>) 
    ... 38 more 
Caused by: java.lang.reflect.InvocationTargetException 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:373) 
    at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:193) 
    ... 42 more 
Caused by: java.lang.SecurityException: Prohibited package name: java.lang 
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:401) 
    ... 48 more 
) 
    .... 
+0

この問題を解決するために、非常に単純化されたプロジェクトとテストケースを作成しました。 jdk 1.5.0_21を使用した場合、jre環境をjdk 1.6.0_18または0_21に変更するだけでテストケースが機能します。上記のようなスタックダンプを取得します。ここでは、非常に簡単なテストケースです: – Bob

+0

申し訳ありませんが、エディタのために長くかかった... 'パブリッククラスMyTestはTestCaseを拡張{ protected InitialContext context; \t {MockContextFactory.setAsInitial();} public void setUp()throws Exception { \t System.out.println( "セットアップ中"); \tコンテキスト=新しいInitialContext(); } \t public void testHello(){ \t \t assertTrue( "Hello there"、1 == 1); \t} }「 すべてのアイデアは評価されています。ありがとう – Bob

+0

Mockrunner、MockEJB、jdk6をテスト環境に使っている人はいますか?ありがとう – Bob

答えて

3

は、まあ、より密接に依存関係を見た後、私たちは使用していた私たちのcglib jarファイルが古くなったと判断しました。私は瓶をcglib-2.2.2.jarにアップグレードし、すべてが機能しているようだ。

関連する問題