wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes Call EJB from Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Call EJB from Servlet" Watch "Call EJB from Servlet" New topic
Author

Call EJB from Servlet

nga nguyet
Greenhorn

Joined: Apr 04, 2009
Posts: 1
Hi all,
Now i'm Learning EJB, i have proplem but I can't fix, can you help me, thanks very much. My program have EJB is

public class SessionBean implements ISessionBeanRemote {

public String GetAddress(String param) {
return "Agribank";
}

public String GetName(String param) {
return "Hoang Phuong Thuc";
}

}
and Interface :
public interface ISessionBeanRemote {

String GetAddress(String param);

String GetName(String param);

}

I uses function lookup:
Properties env = new Properties();

// Definir las propiededes y ubicacion de busqueda de Nombres JNDI.
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.setProperty("java.naming.provider.url", "localhost:1099");
env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming");

Context context=new InitialContext(env);

String name="SessionBean/remote";
ISessionBeanRemote sessionBeanBean=(ISessionBeanRemote)context.lookup(name);

When I write in Main function is OK but not OK in servlet, and have Error is:

java.lang.ClassNotFoundException: agribank.ISessionBeanRemote (no security manager: RMI class loader disabled)
at sun.rmi.server.LoaderHandler.loadProxyClass(LoaderHandler.java:531)
at java.rmi.server.RMIClassLoader$2.loadProxyClass(RMIClassLoader.java:628)
at java.rmi.server.RMIClassLoader.loadProxyClass(RMIClassLoader.java:294)
at sun.rmi.server.MarshalInputStream.resolveProxyClass(MarshalInputStream.java:238)
at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1500)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1463)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1699)
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

I'm not a pro at this so I did some googling and I think this tutorial might help you. I think this is happening because of some security reasons...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
 
subject: Call EJB from Servlet