MockEJB fails when upgrade to jdk1.6

1k Views Asked by At

We are in the process of upgrading our J2EE application from jdk1.4 to jdk1.6 along with moving to a different application server. Yes, lots of moving parts. However, I had written a number of junit tests using Mockrunner and MockEjb where I call things like: MockContextFactory.setAsInitial(); InitialContext context = new InitialContext(); then proceed to bind classes to the context.

However, all my tests that try to create the new InitialContext() fail with a stack trace like this and I can't figure out why? Any help is much appreciated, thanks,

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
)
    ....
1

There are 1 best solutions below

0
On

Well after looking at the dependencies more closely I determined that our cglib jar that we were using was out of date. I upgraded the jar to cglib-2.2.2.jar and all seems to be working.