This discussion is archived
2 Replies Latest reply: Dec 8, 2010 6:52 AM by gimbal2 RSS

Tomcat to Glassfish not working

807254 Newbie
Currently Being Moderated
Hello I am trying to connect to a remote ejb from tomcat 6 with the ejb residing on glassfish 3.I am using the guide at [glassfish |] for advice.
My servers tomcat 6 and glassfish 3 are running on different ports and are on the same machine running on localhost.I want to get the most current technique to connect to a ejb in glassfish 3.I have tried to implement and use parts of tutorials but have not found one answer sufficient to my use.

I am using netbeans 6.9.I have followed he steps laid out in the glassfish guide.I have read to just include the gf-client.jar file which includes links to needed files.
here STEP 3:

"Note that the Java EE 6 API classes are automatically included by gf-client.jar so there is no need to explicitly add javaee.jar to the classpath. gf-client.jar refers to many other .jars from the GlassFish installation directory so it is best to refer to it from within the installation directory itself rather than copying it(and all the other .jars) to another location."

This is what I am doing.
I have tried using the appserv-rt.jar file to remove the java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory.Though I don`t know the best way in that I got another error.

What library files do I include and where do I include them.I have included my ejb netbeans ejb.jar file so I just need the right libraries in the right places.Please offer you opinion and suggestions.

calling code
Context ic = null;
            Properties props = new Properties();
            // optional.  Defaults to localhost.  Only needed if web server is running
            // on a different host than the appserver
            props.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
            // optional.  Defaults to 3700.  Only needed if target orb port is not 3700.
            props.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
            ic = new  InitialContext(props);
            ExpoServiceFacadeRemote foo = (ExpoServiceFacadeRemote)ic.lookup(ExpoServiceFacadeRemote.class.getName());
        } catch (Exception e) {
        } finally {
here I got an error in
ic = new  InitialContext(props);
SEVERE: null
javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enterprise.naming.SerialInitContextFactory [Root exception is java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory]
        at javax.naming.spi.NamingManager.getInitialContext(
        at javax.naming.InitialContext.getDefaultInitCtx(
        at javax.naming.InitialContext.init(
        at javax.naming.InitialContext.<init>(
        at javax.servlet.http.HttpServlet.service(
        at javax.servlet.http.HttpServlet.service(
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(
        at org.apache.catalina.core.StandardWrapperValve.invoke(
        at org.apache.catalina.core.StandardContextValve.invoke(
        at org.apache.catalina.core.StandardHostValve.invoke(
        at org.apache.catalina.valves.ErrorReportValve.invoke(
        at org.apache.catalina.core.StandardEngineValve.invoke(
        at org.apache.catalina.connector.CoyoteAdapter.service(
        at org.apache.coyote.http11.Http11Processor.process(
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
Caused by: java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory
        at org.apache.catalina.loader.WebappClassLoader.loadClass(
        at org.apache.catalina.loader.WebappClassLoader.loadClass(
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(
        at com.sun.naming.internal.VersionHelper12.loadClass(
        at javax.naming.spi.NamingManager.getInitialContext(
        ... 19 more
  • 1. Re: Tomcat to Glassfish not working
    807254 Newbie
    Currently Being Moderated
    Hello still looking into this is there some extra known setup restrictions
  • 2. Re: Tomcat to Glassfish not working
    gimbal2 Guru
    Currently Being Moderated
    java.lang.ClassNotFoundException: com.sun.enterprise.naming.SerialInitContextFactory
    Java cannot make it any more clear to you: this class does not exist in the classpath of your application, so it cannot do its work. If you don't know how to deal with classnotfound errors, I suggest you put a little research into that topic as you'll be seeing it a lot when you continue to use Java.

    You need a certain jar or multiple jars from the glassfish server that contain all the JNDI provider classes and make those available to your client application. I'm not very familiar with Glassfish, but a quick google search turned up the name 'gf-client.jar' which seems very logical.


  • Correct Answers - 10 points
  • Helpful Answers - 5 points