• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JNDI lookup error in MDB

 
karthik kummar
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic