Roxello wrote:
OK. followed readme. same result (jdk1.6.0). so rebuilt my lab rat machine from scratch, wipe disk, winxp re-install etc.
installed these packages:
jdk1.5.0_11
apache-ant-1.6.5
hsqldb_1_8_0_7
hibernate-3.2.2.ga
jpwh-gettingstarted-061110
no edting/alterations.
result:
Code:
C:\helloworld\helloworld-ejb3>ant run
Buildfile: build.xml
compile:
copymetafiles:
[copy] Copying 7 files to C:\helloworld\helloworld-ejb3\build
run:
[java] 17:11:41,248 INFO LocalTxDataSource:117 - Bound datasource to JNDI name 'java:/HelloWorldDS'
[java] Exception in thread "main" javax.naming.NameNotFoundException: MessageHandlerBean not bound
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
[java] at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
[java] at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
[java] at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:626)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
[java] at javax.naming.InitialContext.lookup(InitialContext.java:351)
[java] at hello.HelloWorld.main(Unknown Source)
[java] Java Result: 1
BUILD SUCCESSFUL
Total time: 8 seconds
------ END OF Roxello's QUOTE ----------
I had the same problem. And found 2 possible causes:
1)
I noticed that the problem did not occure when using the ANT build file provided in the examples, but did occur when running it manually from Eclipse without ANT.
When the ANT java task attribute
Code:
fork="true"
is removed from the build file, the problem does occur.
Ant doc about the fork attribute: "if enabled triggers the class execution in another VM (disabled by default)".
2)
If I run it from the command line (outside Eclipse), I have to use the full absolute classpath. For example, this will fail (NameNotFoundException):
(Current directory is c:\java\build)
Code:
java -cp "..\lib\*;." hello.HelloWorld
and this will succeed:
Code:
java -cp "..\lib\*;c:\java\build" hello.HelloWord
The EJB3StandaloneBootstrap.scanClasspath() method in the main method of HelloWorld must also be set correctly.
In my case it will succeed when using:
(Current directory is c:\java\build\)
Code:
EJB3StandaloneBootstrap.scanClasspath("build");
(Which is a bit strange because I'm already in the "build" dir. Specifing it again makes no sense to me, but without it, it will fail.)
but fails when using the absolute path something like:
Code:
EJB3StandaloneBootstrap.scanClasspath("c:/java/build".replace("/", File.separator));
Also note that the jboss docs say:
Quote:
public static void scanClasspath(java.lang.String paths)
Scan java.class.path System property for jars that contain EJB3 files.
This is unportable and unreliable. Use with caution.
---
Edit:
the most simple solution:
You can simply change the scanclasspath to:
Code:
EJB3StandaloneBootstrap.scanClasspath();
Then you don't have to use the "fork" attribute; Eclipse and other IDE's can run it directly; and command line doesn't require the absolute path, so that this will also work:
Code:
java -cp "../lib/*;." hello.HelloWorld