Hi,
I'm setting my first steps with EJB (using the JBoss Application Server) in
Eclipse.
Building a web-based application doesn't give any problems (there are plenty of
good tutorials available) but making an (standalone) Application Client for my
Beans gives a problem. Strangely enough not many tutorials handle that
subject...
The problem is I don't know how to do a Bean lookup from my Java Application.
RandomBean just generates a random number.
Here is some code I found, though this gives an error (see below):
| package randomclient;
|
| import javax.naming.Context;
| import javax.naming.InitialContext;
| import javax.rmi.PortableRemoteObject;
| import random.RandomRemote;
| import random.RandomRemoteHome;
|
| public class RandomClient
| {
| public static void main(String[] args) throws Exception
| {
| Context initial = new InitialContext();
| Context env=(Context)initial.lookup("java:comp/env");
| Object obj=env.lookup("ejb/RandomBean");
| RandomRemoteHome home=(RandomRemoteHome)
| PortableRemoteObject.narrow(obj,RandomRemoteHome.class);
| RandomRemote b=home.create();
| System.out.println(b.random());
| }
| }
|
This is the error I'm getting:
Exception in thread "main" javax.naming.NoInitialContextException: Need to
specify class name in environment or system property, or as an applet
parameter, or in an application resource file: java.naming.factory.initial
| at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
| at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
| at
javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:284)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at Main.main(Main.java:15)
|
It has to do with the Lookup() function (probably wrong values there) but I
have absolutely no idea what to fill in there.
Does someone have an idea please?
Thanks a lot in advance!
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3913277#3913277
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3913277
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user