File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes JNDI lookup error in MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "JNDI lookup error in MDB" Watch "JNDI lookup error in MDB" New topic
Author

JNDI lookup error in MDB

karthik kummar
Greenhorn

Joined: Jun 23, 2010
Posts: 11
Hi Friends i am new to java beans. i am trying to implement Simple MDB using Netbean tool. but in client programming, i am getting error at JNDI lookup line. i am using JBOSS as server. my coding details are given below.

MDB code:



ejb-jar.xml:





jboss.xml:




client code:





MDB is deploying without any error, but while run the client program 21st line searching for connection factory getting failed with error as null pointer exception whether i have to change in *.xml files. could you please advice on this.
Andrew Moko
Ranch Hand

Joined: Dec 16, 2011
Posts: 55
karthik kummar wrote:Hi Friends i am new to java beans. i am trying to implement Simple MDB using Netbean tool. but in client programming, i am getting error at JNDI lookup line. i am using JBOSS as server. my coding details are given below.

MDB code:



ejb-jar.xml:





jboss.xml:




client code:





MDB is deploying without any error, but while run the client program 21st line searching for connection factory getting failed with error as null pointer exception whether i have to change in *.xml files. could you please advice on this.


It simply means You have a NPE AND You need to initialize the jndiContext and optionally pass in the environmental configuration variables to the constructor:

Context jndiContext = new InitialContext(); // use default environmental vars
or
jndiContext = new InitialContext(env); // env - configuration property file with env. variables.

karthik kummar
Greenhorn

Joined: Jun 23, 2010
Posts: 11
Hi,

I am used "Context jndiContext = new InitialContext();" class to initialize the JNDI. I am getting below mentioned error.

run:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at view.SimpleMessageBeanClient.<init>(SimpleMessageBeanClient.java:30)
at view.SimpleMessageBeanClient.main(SimpleMessageBeanClient.java:54)


I do not know how to configure property file with environment variables. so i did not tryied that.


Could you please advice on this to solve.
James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1030
    
    5

The standard set of JNDI properties are:


java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
java.naming.factory.url.pkgs=org.jboss.naming.client


These values may vary depending on your version of JBoss. They should be defined in a file called jndi.properties which is on the classpath when the client code runs.
karthik kummar
Greenhorn

Joined: Jun 23, 2010
Posts: 11
Hi,
I am not using to use JBOSSMQ. i am using JMS and deploying under JBOSS AS. I think we have to give the above mentioned JNDI config only for JBOSSMQ. may i correct?

i need to connect via my own connection factory and Queue. How to do this.

could you please advice on this.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JNDI lookup error in MDB