Re: [JBoss-user] Problems accessing an ejb from a servlet.
Hi all, I have copied all the .jar files for the $JBOSS_HOME/client to the lib folder of the tomcat-3.2.2 context serving the client ejb servlet. Now where I am I going wrong. Thank you in advance. Allan Kamau. --- Allan Kamau <[EMAIL PROTECTED]> wrote: > I am reposting this question after unsuccessful > debugging. I have learnt one thing though, the line > "Got Context" is been executed then the exception > gets > thrown as I never get to see the line "Got > reference". > I think the problem could be in the way I have set > the > environmental variables. > Thanks in advance > Allan Kamau. > > --- Allan Kamau <[EMAIL PROTECTED]> wrote: > > I am running tomcat and JBoss separately. And I > > would > > like to access an ejb from a servlet just as my > > client > > application did. > > > > I tried the ejb interest example and it worked > just > > fine. > > The client application was able to communicated > with > > a > > remote ejb. I modified this client application > into > > a > > servlet and complied it just fine. > > During execution, the servlet throws the exception > > below. Sure JBoss was running as I did > successfully > > run the usual client application. > > Then copied the > jbosssx-client.jar,jboss-client.jar, > > jnp-client.jar and even the jaas.jar and ejb.jar > > files > > into tomcats lib directory, but the error > persisted > > (even after restarting tomcat). > > > > Error javax.naming.NoInitialContextException: > Cannot > > instantiate class: > > org.jnp.interfaces.NamingContextFactory [Root > > exception is java.lang.ClassNotFoundException: > > org.jnp.interfaces.NamingContextFactory] > > > > The servlet looks like this. > > (see attachment). > > > > > > > > __ > > Do You Yahoo!? > > Get personalized email addresses from Yahoo! Mail > > http://personal.mail.yahoo.com/> package > com.burudani.interest; > > import java.util.Properties; > > import javax.rmi.PortableRemoteObject; > > import javax.naming.*; > > import com.burudani.interest.Interest; > > import com.burudani.interest.InterestHome; > > import java.io.*; > > import java.text.*; > > import java.util.*; > > import javax.servlet.http.*; > > import javax.servlet.*; > > > > > > > > public class InterestClientServlet extends > > HttpServlet > > { > > private void executeServer(String > > JavaNamingProviderURLValue,String > > JndiContextLookupValue,PrintWriter out) > > { > > out.println("inside executeServer()"); > > String JavaNamingProviderURL="localhost:1099"; > > String JndiContextLookup="Interest"; > > Date ServerDate=new Date(); > > SimpleDateFormat sdf; > > sdf=new SimpleDateFormat("dd MMM > hh:mm:ss:ms > > zzz"); > > try > > { > > /*System.out.println("Set the > > \"java.naming.provider.url\""); > > BufferedReader br=new BufferedReader (new > > InputStreamReader(System.in)); > > String str="";int i; > > for (i=0;i<1;i++) > > str=br.readLine(); > > JavaNamingProviderURL=str; > > System.out.println("Enter the lookup jndi Name > > of remote object"); > > br=new BufferedReader (new > > InputStreamReader(System.in)); > > for (i=0;i<1;i++) > > str=br.readLine(); > > */ > > > > JavaNamingProviderURL=JavaNamingProviderURLValue; > > JndiContextLookup=JndiContextLookupValue; > > out.println("Setting the > > \"java.naming.provider.url\""); > > out.println(JavaNamingProviderURL); > > out.println("Setting the lookup jndi Name of > > remote object"); > > out.println(JndiContextLookup); > > } > > catch(Exception ioe) > > { > > System.out.println("Problems reading your > values > > "+ioe.toString()); > > } > > //set up the naming provider, this may not be > > necessary, depending on how your Java system is > > configured. > > Properties env=new Properties(); > > > > > env.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory"); > > > > > //env.setProperty("java.naming.provider.url","localhost:1099"); > > > > > env.setProperty("java.naming.provider.url",JavaNamingProviderURL); > > > > > env.setProperty("java.naming.factory.url.pkgs","org.jboss.naming"); > > try > >
Re: [JBoss-user] Problems accessing an ejb from a servlet.
I am reposting this question after unsuccessful debugging. I have learnt one thing though, the line "Got Context" is been executed then the exception gets thrown as I never get to see the line "Got reference". I think the problem could be in the way I have set the environmental variables. Thanks in advance Allan Kamau. --- Allan Kamau <[EMAIL PROTECTED]> wrote: > I am running tomcat and JBoss separately. And I > would > like to access an ejb from a servlet just as my > client > application did. > > I tried the ejb interest example and it worked just > fine. > The client application was able to communicated with > a > remote ejb. I modified this client application into > a > servlet and complied it just fine. > During execution, the servlet throws the exception > below. Sure JBoss was running as I did successfully > run the usual client application. > Then copied the jbosssx-client.jar,jboss-client.jar, > jnp-client.jar and even the jaas.jar and ejb.jar > files > into tomcats lib directory, but the error persisted > (even after restarting tomcat). > > Error javax.naming.NoInitialContextException: Cannot > instantiate class: > org.jnp.interfaces.NamingContextFactory [Root > exception is java.lang.ClassNotFoundException: > org.jnp.interfaces.NamingContextFactory] > > The servlet looks like this. > (see attachment). > > > > __ > Do You Yahoo!? > Get personalized email addresses from Yahoo! Mail > http://personal.mail.yahoo.com/> package com.burudani.interest; > import java.util.Properties; > import javax.rmi.PortableRemoteObject; > import javax.naming.*; > import com.burudani.interest.Interest; > import com.burudani.interest.InterestHome; > import java.io.*; > import java.text.*; > import java.util.*; > import javax.servlet.http.*; > import javax.servlet.*; > > > > public class InterestClientServlet extends > HttpServlet > { > private void executeServer(String > JavaNamingProviderURLValue,String > JndiContextLookupValue,PrintWriter out) > { > out.println("inside executeServer()"); > String JavaNamingProviderURL="localhost:1099"; > String JndiContextLookup="Interest"; > Date ServerDate=new Date(); > SimpleDateFormat sdf; > sdf=new SimpleDateFormat("dd MMM hh:mm:ss:ms > zzz"); > try > { > /*System.out.println("Set the > \"java.naming.provider.url\""); > BufferedReader br=new BufferedReader (new > InputStreamReader(System.in)); > String str="";int i; > for (i=0;i<1;i++) > str=br.readLine(); > JavaNamingProviderURL=str; > System.out.println("Enter the lookup jndi Name > of remote object"); > br=new BufferedReader (new > InputStreamReader(System.in)); > for (i=0;i<1;i++) > str=br.readLine(); > */ > > JavaNamingProviderURL=JavaNamingProviderURLValue; > JndiContextLookup=JndiContextLookupValue; > out.println("Setting the > \"java.naming.provider.url\""); > out.println(JavaNamingProviderURL); > out.println("Setting the lookup jndi Name of > remote object"); > out.println(JndiContextLookup); > } > catch(Exception ioe) > { > System.out.println("Problems reading your values > "+ioe.toString()); > } > //set up the naming provider, this may not be > necessary, depending on how your Java system is > configured. > Properties env=new Properties(); > > env.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory"); > > //env.setProperty("java.naming.provider.url","localhost:1099"); > > env.setProperty("java.naming.provider.url",JavaNamingProviderURL); > > env.setProperty("java.naming.factory.url.pkgs","org.jboss.naming"); > try > { > InitialContext jndiContext=new > InitialContext(env); > out.println("Got context"); > //Object ref=jndiContext.lookup("Interest"); > Object > ref=jndiContext.lookup(JndiContextLookup); > out.println("Got Reference"); > > //Get a reference from this to the Bean's
Re: [JBoss-user] Problems accessing an ejb from a servlet.
> "Allan" == Allan Kamau <[EMAIL PROTECTED]> writes: Allan> I am running tomcat and JBoss separately. And I would Allan> like to access an ejb from a servlet just as my client Allan> application did. Allan> I tried the ejb interest example and it worked just Allan> fine. Allan> The client application was able to communicated with a Allan> remote ejb. I modified this client application into a Allan> servlet and complied it just fine. Allan> During execution, the servlet throws the exception Allan> below. Sure JBoss was running as I did successfully Allan> run the usual client application. Allan> Then copied the jbosssx-client.jar,jboss-client.jar, Allan> jnp-client.jar and even the jaas.jar and ejb.jar files Allan> into tomcats lib directory, but the error persisted Allan> (even after restarting tomcat). I'm not certain this will make a difference here, but I believe the jar files needed by the application have to be stored in the WEB-INF/lib directory, not the $TOMCAT_HOME/lib directory. -- === David M. Karr ; Best Consulting [EMAIL PROTECTED] ; Java/Unix/XML/C++/X ; BrainBench CJ12P (#12004) ___ JBoss-user mailing list [EMAIL PROTECTED] http://lists.sourceforge.net/lists/listinfo/jboss-user