This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques and have Mario Casciaro & Luciano Mammino on-line!
See this thread for details.
Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

naming exception

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
I can't renounce my name. It's on all my stationery! And hinted in this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic