Cannot initialize Stateless EJB3
majohnst Oct 20, 2005 2:46 PMI am trying to test a new Statless bean, but I can't get it to initialize. I have tried using the bean in a junit test using the Embedded EJB and as a regular ejb3 bean in JBoss 4.0.3. Both times I get the same error, so I figure it is my bean that is the problem. The error message is
java.lang.RuntimeException: java.lang.InstantiationException at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:336) at org.jboss.ejb3.AbstractPool.create(AbstractPool.java:42) at org.jboss.ejb3.ThreadlocalPool.get(ThreadlocalPool.java:33) at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:36) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:89) at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:89) at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:89) at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91) at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:89) at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:163) at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:60) at $Proxy19.setFeedDir(Unknown Source) at gearapalooza.test.AltrecTest.testLoad(AltrecTest.java:21) 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:585) at junit.framework.TestCase.runTest(TestCase.java:154) at junit.framework.TestCase.runBare(TestCase.java:127) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194) Caused by: java.lang.InstantiationException at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at org.jboss.ejb3.EJBContainer.construct(EJBContainer.java:332) ... 29 more
I can deploy the bean in both JBoss and Embedded, but anytime I try to call a method, that error message pops up. My bean looks like:
public interface DataFeed { ... } @Stateless public abstract class DataFeedBean implements DataFeed { ... }
My JUnit test looks like
InitialContext ctx = getInitialContext(); DataFeed dataFeed = (DataFeed)ctx.lookup(DataFeed.class.getName()); dataFeed.setFeedDir("/var/www/gearapalooza.com/feeds/");
Does anyone know why the bean cannot be initialized?