This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I have written a simple remote interface, home interface, the bean class, the deployment descriptor and the vendoe specific xml file (all manually) to test a simple Hello World case. Now I have created the HelloWorld.jar file with the files in its proper folders -- i.e. I kept Hello.class (Remote interface) HelloHome.class (Home interface) HelloBean.class (Bean class) within a folder called "examples" while I kept ejb-jar.xml (Deployment descriptor) jboss.xml (Vendor specific file) within a folder called "META-INF" I successfully deployed the jar file (created by jar cf HelloWorld.jar *) into the deployment directory of JBOSS. I now have the HelloClient file. Few points to take not of -- I am working from the folder "samples" and I have three folders "src", "examples" and "META-INF" as the sub-folders. I am using "package examples" in all the java files which are placed in the "src" folder. I have compiled the files using "java -d examples src\*.java" This resulted in the generation of the corresponding 4 class files in the "examples" folder. Now the main file is when I am trying to execute the Client file. I am trying to execute the following command from the "samples" folder --- "java examples.HelloClient" This is giving the following errors -- C:\JBoss-2.4.3_Tomcat-3.2.3\samples>java examples.HelloClient Exception in thread "main" javax.naming.NoInitialContextException: Need to speci fy class name in environment or system property, or as an applet parameter, or i n an application resource file: java.naming.factory.initial at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6 40) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243 ) at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav a:280) at javax.naming.InitialContext.lookup(InitialContext.java:347) at examples.HelloClient.main(HelloClient.java:36) I am listing the full codes for the 4 java files --- Hello.java
HelloHome.java
HelloBean.java
HelloClient.java
Above 4 files are part from Ed Roman's book.
jboss.xml
ejb-jar.xml
CAN ANYONE PLEASE HELP ME ?? [ May 28, 2002: Message edited by: Arijit Ghosh ]
I think that the client can't find the directory on the jboss server to lookup the ejb. It needs to specify the url of the server and the factory to create an initial context. Have you set up a jndi.properties file? Create one and put it in your classpath. Put the following in it: java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=localhost:1099 java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces [ May 28, 2002: Message edited by: jon boydell ]
Arijit Ghosh
Ranch Hand
Joined: Feb 01, 2002
Posts: 174
posted
0
Hello Jon, Thanks for the reply. Just one clarification... Does this mean the steps that I had listed in the problem are correct i.e. Am I doing the steps correctly? There is one jndi.properties file in the default conf folder. I have edited that and included all that you have mentioned. I tried to execute it again but the same error is shown. Is it because of the classpath ? Do I have to set the classpath to "DEFAULT" folder in my Autoexec.bat file ? Thanks in advance.
Arijit Ghosh
Ranch Hand
Joined: Feb 01, 2002
Posts: 174
posted
0
C:\JBoss-2.4.3_Tomcat-3.2.3\samples>java examples.HelloClient Exception in thread "main" javax.naming.NoInitialContextException: Cannot instan tiate class: org.jnp.interfaces.NamingContextFactory. Root exception is java.la ng.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:198) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:186) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265) at java.lang.ClassLoader.loadClass(ClassLoader.java:262) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:207) at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.jav a:42) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6 49) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243 ) at javax.naming.InitialContext.init(InitialContext.java:219) at javax.naming.InitialContext.<init>(InitialContext.java:195) at examples.HelloClient.main(HelloClient.java:30) When I added the following to my classpath above errors occured. "set CLASSPATH=%CLASSPATH%;C:\JBoss-2.4.3_Tomcat-3.2.3\jboss\conf\default" I already have the following classpath set -- "set CLASSPATH=%CLASSPATH%;C:\JBoss-2.4.3_Tomcat-3.2.3\samples\examples" All Hello example class files are stored in the directory "examples" And as I have mentioned before I am executing "java examples.HelloClient" from the "samples" folder. Please help !
Arijit Ghosh
Ranch Hand
Joined: Feb 01, 2002
Posts: 174
posted
0
Thanks Jon! Got the problem... I had not included the jboss-client and jnp-client jar files in my classpath :roll: :roll:
if u are using jboss3.0+ go to C:\jboss3\cong\defualt\jndi.properties uncomment the lines. Then copy that file to the client folder. Jawwad Ahmed SCJP SCWCD jawwad_java@yahoo.com
Arijit Ghosh
Ranch Hand
Joined: Feb 01, 2002
Posts: 174
posted
0
Hi, If I have downloaded JBOSS 2.4.4 or 2.4.5 i.e. 2.4.x version, and have also downloaded Tomcat 4.x version separately, how can I integrate them together ? Is it by editing the MLET code in jboss.conf file ?