After my first try with EJB 3.1/2 Embeddable Usage yesterday, I ran on trouble and then I
exchanged mails with Carlo. May be this can help someone.
have fun!
There are a lot of bugs in Maven which leads into getting an unstable
classpath configuration. What you're seeing is a wrong version of a
component showing up.
Make sure you have Maven 2.0.9 installed and try to regenerate the
.classpath file (mvn eclipse:eclipse).
If all fails 'mvn -Dverbose=true dependency:tree' and compare this with
what you see in Eclipse.
Also, post on the forum so others might benefit. :-)
Carlo
Serge Emmanuel Pagop wrote:
Hi carlo,
firstly great job with EJB 3.1 Embeddable prototype, and today I took
a little time to try a simple example in eclipse and maven, but with
suprise the
test case run well throught the maven command "mvn test" and the same
example does not work with testing on eclipse "Run As -> JUnit Test".
May be you can give some tipps, how I can run the test case on
eclipse. Thanks.
I followed the maven pom installation step as on the jboss wiki
site:
http://wiki.jboss.org/wiki/EJB31Embeddable
1) here is the test case
public class HelloBeanTest {
private static final Logger log =
Logger.getLogger(HelloBeanTest.class);
private static String getBaseURLToResource( String resource ) {
URL url =
Thread.currentThread().getContextClassLoader().getResource(resource);
String s = url.toString();
return s.substring(0, s.length() - resource.length());
}
@Test
public void test1() throws NamingException {
log.info("Test #1");
Properties properties = new Properties();
// Not according to spec!
properties.setProperty(EJBContainer.EMBEDDABLE_MODULES_PROPERTY,
getBaseURLToResource("org/ormsys/ejb3/HelloBean.class"));
EJBContainer container =
EJBContainer.createEJBContainer(properties);
// Note that global naming isn't working yet.
InitialContext ctx = new InitialContext();
Hello bean = (Hello)ctx.lookup("HelloBean/local");
String now = new Date().toString();
String actual = bean.sayHello(now);
assertEquals("Hello " + now, actual);
container.close();
}
}
2) Here is the error trace
java.lang.NoSuchFieldError: factoryFinder
at org.jboss.virtual.VFS.init(VFS.java:71)
at org.jboss.virtual.VFS.(VFS.java:51)
at
org.jboss.ejb3.embedded.JBossEJBContainer.deployMain(JBossEJBContainer.java:140)
at
org.jboss.ejb3.embedded.JBossEJBContainer.deployMain(JBossEJBContainer.java:134)
at
org.jboss.ejb3.embedded.JBossEJBContainer.(JBossEJBContainer.java:88)
at
org.jboss.ejb3.embedded.JBossEJBContainerProvider.createEJBContainer(JBossEJBContainerProvider.java:56)
at javax.ejb.EJBContainer.createEJBContainer(EJBContainer.java:99)
at org.ormsys.ejb3.HelloBeanTest.test1(HelloBeanTest.java:36)
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 org.junit.internal.runners.TestMethod.invoke(TestMethod.java:59)
at
org.junit.internal.runners.MethodRoadie.runTestMethod(MethodRoadie.java:98)
at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:79)
at
org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:87)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:77)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:42)
at
org.junit.internal.runners.JUnit4ClassRunner.invokeTestMethod(JUnit4ClassRunner.java:88)
at
org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at
org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at
org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at
org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at
org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)