-
1. Re: jboss and jbuilder, ejb & servlets - how?
seybaaa Jan 11, 2002 1:30 PM (in response to adrian79)well I have made a war with my servlet,and a jar
with my ejb,then just copy the war in tomcat webApp
then just pus jar in jboss deploy that works very find
good luck -
2. Re: jboss and jbuilder, ejb & servlets - how?
sebaseba Jan 24, 2002 10:43 AM (in response to adrian79)I do not know the details of your JNDI configuration, but it looks to me like you need to replace
InitialContext jndiContext = new InitialContext();
by something like this:
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
prop.put(Context.PROVIDER_URL, "localhost:1099");
Context ctx = new InitialContext(prop);
Otherwise your servlet does not know how to connect to JNDI, as suggested by the error message you are getting.
Sebastian -
3. Re: jboss and jbuilder, ejb & servlets - how?
alcaponi Feb 5, 2002 6:06 AM (in response to adrian79)Hi all,
Following Sebastian's post, I'm trying to run a servlet on Tomcat 3.2 that would look up an EJB on JBoss 3.0a and invoke that EJB's method.
(Both Tomcat and JBoss are on my localhost)
Now when I invoke the servlet from a JSP, I get the following error:
Internal Servlet Error:
javax.servlet.ServletException: Naming Exception creating Initial Context
Cannot instantiate class: org.jnp.interfaces.NamingContextFactory
at com.mybean.CalculateLoanServlet.init(CalculateLoanServlet.java:34)
at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
at org.apache.tomcat.core.Handler.init(Handler.java:215)
at org.apache.tomcat.core.ServletWrapper.init(ServletWrapper.java:296)
at org.apache.tomcat.core.Handler.service(Handler.java:254)
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:806)
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:752)
at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:213)
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501)
at java.lang.Thread.run(Thread.java:484)
This is the servlet init method where the exception occurs.
import java.io.*;
import java.util.*;
import javax.rmi.PortableRemoteObject;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import org.jnp.interfaces.NamingContextFactory;
public class CalculateLoanServlet extends HttpServlet
{
private static final String CONTENT_TYPE = "text/html";
protected Context initCtx = null;
/**Initialize global variables*/
public void init(ServletConfig config) throws ServletException
{
super.init(config);
try
{
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL, "localhost:1099");
Context initCtx = new InitialContext(env);
}
catch(NamingException ne)
{
throw new ServletException("Naming Exception creating Initial Context " +
ne.getMessage());
}
}
...
}
Can anyone help?
Thanx!
Al -
4. Re: jboss and jbuilder, ejb & servlets - how?
sammy-t Feb 6, 2002 2:19 AM (in response to adrian79)The original error seemed to be a classpath problem. You can test that theory quickly by copying $JBOSS_HOME/client/*.jar to $JAVA_HOME/jre/lib/ext then restart your server. This will only help on the ClassNotFound errors, the other errors appear to be genuine JNDI configuration problems that I haven't seen yet :) If that 5 second hack fixes your ClassNotFound error, then you need to fix your classpath properly else the Java-Grue will eat you. I run Tomcat independantly of JBoss, and I had that problem because Tomcat's startup script wasn't adding jboss/client to the extdirs.