I'm a newbie in the J2EE/EJB field and I'm following some basic examples. I have implemented a very simple class that sums 2 number. I have the home and remote interfaces and the Enterprise Bean (stateless) itself.
Adder.java //Remote interface
AdderHome.java //Home interface
AdderBean.java //The EJB class
When testing it as an EJB application, everything works perfectly. But now, I'd like to test it as a JSP page but I get an error (actually there's no output) at the point in which the remote interface is instantiated from the home interface.
In time: I'm using J2EE 1.4 with JBoss 4.
Here's the code of the JSP page. It's supposed to only print out one line.
<%@page import="javax.naming.*" %>
<%@page import="javax.rmi.PortableRemoteObject" %>
<%@page import="java.util.Properties" %>
<%@page import="com.lucasmariano.*" %>
<%
//Preparing the properting to be put in the InitialContext
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost:1099");
try {
//Get an Initial Context
InitialContext jndiContext = new InitialContext(properties);
System.out.println("got context");
//get a reference to the bean
Object ref = jndiContext.lookup("Adder");
System.out.println("got reference");
//Get a reference to this to the bean's home interface
AdderHome home = (AdderHome) PortableRemoteObject.narrow(ref, AdderHome.class);
out.println("GETTING OBJECT <BR />");
//create an Adder object from the Home interface
//###### HERE IS THE PROBLEM!!! #######
Adder adder = home.create();
out.println("ADDER OBJECT CREATED <BR />");
out.println("2 + 5 = " + adder.add(2,5));
}catch(Exception e ){
System.out.println(e.toString());
}
%>
Do I need to add some new value to my web.xml?