Forums Register Login

EJB JNDI NoInitialContext Exception

+Pie Number of slices to send: Send
Hi Friends,

Iam new to EJB. Iam running a simple SLSB application on eclipse using JBOSS 5 AS. Iam getting this exception.


Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: jboss.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: jboss.jndi.WLInitialContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.InitialContext.<init>(Unknown Source)
at session.client.Clientside.main(Clientside.java:22)
Caused by: java.lang.ClassNotFoundException: jboss.jndi.WLInitialContextFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)
... 5 more

my code is like this:

jndi.properties

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.Provider.url=t3://localhost:8080

client.java

public class Clientside {

/**
* @param args
* @throws Exception
*/

public static void main(String[] args) throws Exception {

Properties p=new Properties();
p.load(new FileInputStream("jndi.properties"));
InitialContext ic = new InitialContext(p);

Add add=(Add)ic.lookup("SampleAppEJB.ejbModule.session.stateless.Add");
System.out.println("the sum is"+add.add(1,2));

}

}
I don't knw where the prblem is. i also added the following jar files to the client application

jbossall-client.jar
jboss-ejb3-common-client.jar
jboss-ejb3-core-client.jar

can any one suggest me the solution . thanks in advance

+Pie Number of slices to send: Send
Try this for your JNDI properties:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming.client
java.naming.factory.provider.url=localhost:1099

I have noticed that your provider is started with "P" instead of "p".
+Pie Number of slices to send: Send
hi, thanks for replying it worked but another exception came

Exception in thread "main" javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1640)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1757)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:689)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
at javax.naming.InitialContext.lookup(Unknown Source)
at session.client.Clientside.main(Clientside.java:24)
Caused by: java.net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive0(Native Method)
at java.net.PlainDatagramSocketImpl.receive(Unknown Source)
at java.net.DatagramSocket.receive(Unknown Source)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:1609)
... 5 more

i didn't understood where it is comming. can you tell me the solution for this one also .thanks in advance
+Pie Number of slices to send: Send
you have to use :

Hashtable hashtable = new Hashtable();

hashtable.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
hashtable.put("java.naming.provider.url", "jnp://localhost:1099");
hashtable.put("java.naming.factory.url.pkgs", "org.jnp.interfaces");

InitialContext context = new InitialContext(hashtable);


some j2ee with jboss5 lib:
+Pie Number of slices to send: Send
use this library from jboss 5 server : add lib into your project classpath

concurrent.jar
jboss-aop-client.jar
jboss-common-core.jar
jboss-ejb3-common.jar
jboss-ejb3-core.jar
jboss-ejb3-proxy.jar
jboss-ejb3-security.jar
jboss-integration.jar
jboss-javaee.jar
jboss-logging-spi.jar
jboss-remoting-aspects.jar
jboss-security-spi.jar
jbosssx.jar
jboss-transaction-aspects.jar
jmc.jar
jnpserver.jar
jogl.jar
+Pie Number of slices to send: Send
hi,thanks for your reply. but still i couldn't solved it. iam using jndi properties file and passing it to the initial context.still do i have to write them in hash table also ?
even though i changed the code to hash code i got exception called name not found exception at look up line.

i have added the jars but i couldn't found some of the jar they are these


i tried to download from net but i couldn't found some of the jars those are :

jogl.jar

their is some difference between the jars you mentioned and i have in my server/client/ libraries are they are same ?

you mentioned i have
jboss-ejb3-core.jar jboss-ejb3-core-client.jar

jboss-ejb3-proxy.jar jboss-ejb3-proxy-client.jar

jboss-ejb3-security.jar jboss-ejb3-security-client.jar

can you help out . thanks in advance
Shiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2936 times.
Similar Threads
help me,applet invoke ejb
JBoss Remote Lookup
NoInitialContextException
can't call method lookup("path") of Entity Bean
Please help me to run a client
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 14:23:24.