This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Five Lines of Code and have Christian Clausen on-line!
See this thread for details.
Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

naming exception

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I am new to EJB running my first application am getting the
following exception

javax.naming.NoInitialContextException: Cannot instantiate class: com.sun.enter
rise.naming.SerialInitContextFactory. Root exception is java.lang.ClassNotFoun
Exception: com.sun.enterprise.naming.SerialInitContextFactory
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:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:217)
at com.sun.naming.internal.VersionHelper12.loadClass(VersionHelper12.ja
a:42)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
49)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:24
)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at HelloClient.main(HelloClient.java:11)

jndi.properties file is

java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory
java.naming.factory.url.pkgs=com.sun.enterprise.naming

and classpth includes
set classpath=C:\JBOSS\jboss-3.0.8_tomcat-4.1.24\server\all\lib\jboss-j2ee.jar;


thankx in advance
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, there is a mismatch between the App Server you are using and the values in your JNDI porperties which looks like they are trying to reach a Sun Enterprise App Server.

For JBoss you need the following in your jndi.properties file instead

java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming rg.jnp.interfaces
 
santosh gunake
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

now am getting the following error

javax.naming.CommunicationException: Receive timed out. Root exception is java.
net.SocketTimeoutException: Receive timed out
at java.net.PlainDatagramSocketImpl.receive(Native Method)
at java.net.DatagramSocket.receive(DatagramSocket.java:671)
at org.jnp.interfaces.NamingContext.discoverServer(NamingContext.java:10
23)
at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:1112)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:479)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:472)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at HelloClient.main(HelloClient.java:16)

Client code

Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put(Context.PROVIDER_URL,"jnp://localhost:1099";);
System.out.println("1");
InitialContext ctx = new InitialContext(env);
System.out.println("2");
Object obj = ctx.lookup("ejb/HelloTest");
System.out.println("3");
HelloHome home = (HelloHome)PortableRemoteObject.narrow(obj, HelloHome.class);
System.out.println("4");
HelloRemote remote = home.create();
System.out.println(remote.hello());
remote.remove();

ejb-jar.xml

<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>HelloHome</home>
<remote>HelloRemote</remote>
<ejb-class>HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>


jboss.xml

<jboss>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<jndi-name>ejb/HelloTest</jndi-name>
</session>
</enterprise-beans>

<resource-manager>
</resource-manager>

</jboss>

and application.xml

<application>
<module>
<ejb>SimpleStateless.jar</ejb>
</module>
</application>
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic