Hello,
In your bean or the implementation class, make sure you annotate the
stateful / stateless providing it with the JNDI name :
@Stateful(name="asful", mappedName="ASfulbeanJNDI")
Then in your client refer to it as:
public class ASfulJavaClient {
public static void main(String args[]) {
try {
InitialContext ic = new InitialContext();
ASful aSful = (ASful) ic.lookup("ASfulbeanJNDI");
aSful.setId("duke");
System.out.println("Sful id = " + aSful.getId());
} catch(Exception e) {
e.printStackTrace();
}
}
}
Add the directory of your classes to the client.
eve
From: corrado.marinaro_at_marinaro.chTo: ejb_at_glassfish.dev.java.netDate: Wed, 5 Mar 2008 15:14:52 +0100Subject: AW: Cannot call EJB outside the project
Hello,
trhx fort he answer. The ASful is noted with Remote. In the Sun-Example there is no note about setting any thing. The clou should be : Annotation and that’s it. That’s apparantely not like that?
I’m using a glassfish server …
The following call rocks (but that’s not that I want … ):
public class ASfulJavaClient {
public static void main(String args[]) {
try {
InitialContext ic = new InitialContext();
ASful aSful = (ASful) ic.lookup("com.company.companydb.ejbstuff.ASful");
aSful.setId("duke");
System.out.println("Sful id = " + aSful.getId());
} catch(Exception e) {
e.printStackTrace();
}
}
}
By the way, the EJB and the SfulJavaClient sits in the same package aswell as the example above … strange behavior …
Von: Cheng.Fang_at_Sun.COM [mailto:Cheng.Fang_at_Sun.COM] Gesendet: Mittwoch, 5. März 2008 15:05An: ejb_at_glassfish.dev.java.netBetreff: Re: Cannot call EJB outside the project
Hi,Did you include com.company.companydb.ejbstuff.ASful and its dependency in your client classpath? Note the root exception ClassNotFoundException: com.company.companydb.ejbstuff.ASful. And ASful should be a remote business interface. -chengCorrado Marinaro wrote:
Hello,
This is the deployment on the glassfish server, and I cann see clearliy the : “RemoteBusinessJndiName”
INFO: EJBSCLookup:: sc.getEjbContainerAvailabilityEnabledFromConfig() ==> false
05.03.2008 07:22:34 com.sun.enterprise.iiop.POARemoteReferenceFactory createReferenceFactory
INFO: POARemoteRefFactory addSFSBVersionPolicy? false
05.03.2008 07:22:34 com.sun.ejb.containers.BaseContainer initializeHome
INFO: **RemoteBusinessJndiName: com.company.companydb.ejbstuff.ASful; remoteBusIntf: com.company.companydb.ejbstuff.ASful
05.03.2008 07:22:34 com.sun.enterprise.naming.NamingManagerImpl bindObjects
INFO: naming.bind
05.03.2008 07:22:34 com.sun.enterprise.iiop.POARemoteReferenceFactory createReferenceFactory
INFO: POARemoteRefFactory checking if SFSBVersionPolicy need to be added
05.03.2008 07:22:34 com.sun.ejb.base.sfsb.util.EJBServerConfigLookup needToAddSFSBVersionInterceptors
INFO: EJBSCLookup:: sc.getEjbContainerAvailabilityEnabledFromConfig() ==> false
05.03.2008 07:22:34 com.sun.enterprise.iiop.POARemoteReferenceFactory createReferenceFactory
Call that from another project :
package thepackage;
import javax.naming.InitialContext;
public class SfulJavaClient {
public static void main(String args[]) {
try {
InitialContext ic = new InitialContext();
Sful sful = (Sful) ic.lookup("com.company.companydb.ejbstuff.ASful");
sful.setId("duke");
System.out.println("Sful id = " + sful.getId());
} catch(Exception e) {
e.printStackTrace();
}
}
}
This error occur:
javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.company.companydb.ejbstuff.ASful [Root exception is java.lang.ClassNotFoundException: com.company.companydb.ejbstuff.ASful]
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:367)
at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:74)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:344)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at thepackage.SfulJavaClient.main(SfulJavaClient.java:12)
Caused by: java.lang.ClassNotFoundException: com.company.companydb.ejbstuff.ASful
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:621)
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:337)
... 5 more
--------------------------------------------------------------------- To unsubscribe, e-mail: ejb-unsubscribe_at_glassfish.dev.java.net For additional commands, e-mail: ejb-help_at_glassfish.dev.java.net
_________________________________________________________________
Get Hotmail on your mobile, text MSN to 63463!
http://mobile.uk.msn.com/pc/mail.aspx