Hi!
I have been playing with JBoss for a couple of weeks, I installed and
configured JBoss+Tomcat and installed, built and run the Interest sample and
everything went OK. So I tried to run the Interest EJB from a servlet client
instead of a standalone client and got into trouble. I have looked into the
list archives and it seems that a number of people are having the same
problem. Many ideas have been floated around but I have not seen a final
solution, so I would like to provide as much information as possible to see
if someone can look into this. So:
a) The EJB is properly deployed since you can run it without problems from a
standalone client. The client looks up the EJB using JDNI, finds it and runs
it without problem. The EJB outputs a message on the JBoss console to
confirm that it has been run. The Jboss.xml correctly lists the appropiate
JNDI name which is "interest/Interest" and the JBoss log correctly shows
this EJB being deployed under this name
b) I transformed the code of the sample client into a servlet. Here is what
my code looks like:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;
import javax.naming.*;
import com.web_tomorrow.interest.*;
public class InterestClient extends HttpServlet {
public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out;
String title = "Servlet interface to EJB";
response.setContentType("text/html");
out = response.getWriter();
out.println("<HTML><HEAD><TITLE>");
out.println(title);
out.println("</TITLE></HEAD><BODY bgcolor=\"#FFFFFF\">");
out.println("<H1>" + title + "</H1>");
Properties env = new Properties();
env.setProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
env.setProperty("java.naming.provider.url", "localhost:1099");
try
{
// Get a naming context
InitialContext jndiContext = new InitialContext(env);
out.println("Got context");
// Get a reference to the Interest Bean
Object ref = jndiContext.lookup("interest/Interest");
out.println("Got reference");
// Get a reference from this to the Bean's Home interface
InterestHome home = (InterestHome)
PortableRemoteObject.narrow (ref, InterestHome.class);
out.println("Got home");
// Create an Interest object from the Home interface
Interest interest = home.create();
out.println("Create home");
// call the calculateCompoundInterest() method to do the calculation
out.println("Interest on 2000 units, at 10% per period, compounded
over 2 periods is:");
out.println(interest.calculateCompoundInterest (2000, 0.10, 2));
}
catch(Exception e)
{
out.println(e.getMessage());
} finally {
out.println("</BODY></HTML>");
out.close();
}
}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>
I can build this servlet without problems and I can also run it, so it seems
properly deployed. But when I run it I get a NamingException, which is
generated by the lookup("interest/Interest") call. This is the same name
used in the standalone client, so it is not a question of using the wrong
JDNI name.
c) I recompiled the code of the jnp package to see if I could get more
information on what is going on. I found that when the method lookup is
called in the client in the NamingContext class, located in the
NamingContext.java file, a ClassNotFoundException is generated when the
lookup(Name name) method calls the lookup method of the remote server (line
355: Object res = naming.lookup(n);)
d) I also put some logging println lines in the lookout method of the
jnpserver (in file NamingServer.java) and I found that both in the case of
the standalone client and the servlet, the jnpserver is correctly called and
it finds the appropiate object. I put some println lines to display the name
being looked up and the object found and in both cases I got the same
information:
looking for interest/Interest
found java.rmi.MarshalledObject@53248168
e) So my hypothesis is that the naming server correctly finds the EJB, but
when it is sent back to the naming client, it is somehow corrupted or
something like that. This seems a RMI problem and I feel that I have run
into something too complicated for me, so this is the point to ask for help
:-)
g) My configuration: I am running JBoss-2.2 with EmbeddedTomcat 3.2.1 in a
windows 2000 enviroment with JDK13
Thanks in advance for your help!
Carlos
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user