Win a copy of Head First Android this week in the Android 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

how to resolve this problem in simple stand alone java application.

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Team,

I am new to use Java messaging i had developed one code but it propted me some error.

How to specify class name in environment or system property.

Exception in thread "main" java.lang.NullPointerException
at com.jsm.example.BilboRingQueueSender.main(BilboRingQueueSender.java:31)
Naming Exception: 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
 
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post your code here
 
arvind kushwaha
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



This is sender code written by using eclipse gyanmede but when it try to run the above program its show me an error please tell how to solve the above problem.
 
bhanu chowdary
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the app server you are using???
 
arvind kushwaha
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not using any app server.....its just standalone java application....I want to know to set the jndi.properties file eclipse how should i do it and where should i write it..and please provide me what should be written in jndi.properties files.
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
even with a jndi.properties file, you still need a provider for your jndi naming..
Do you have an app server running locally???

Here's some sample code you could use if you're running Weblogic on port 7001 and don't have to login.

Properties env = new Properties( );
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,
"t3://localhost:7001");

InitialContext jndi = new InitialContext(env);

At this point, you have a valid context that can be used to look up queues, etc.
 
bhanu chowdary
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

arvind kushwaha wrote:I am not using any app server.....its just standalone java application....I want to know to set the jndi.properties file eclipse how should i do it and where should i write it..and please provide me what should be written in jndi.properties files.


Arvind,
My knowledge on JMS is limited. But as far as I know you create a queue/Topic in a Java EE compliant application server giving it a JNDI name, then send your messages to that queue/topic. For that as Lanny mentioned you have to pass some properties while instantiating the InitialContext.

env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");


This weblogic.jndi.WLInitialContextFactory part of the above code defers from one application server to another. If you are using a application server other than weblogic you have to refer to the documentation of that particular app server.

 
arvind kushwaha
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Bhanu ,

I really appricate your help but i know how to use JMS with application server. I want to want whether it possible, to write a code of JMS without using application server. IF yes how should do it. The code which is attached is reffered by website. But whenever i tried to run this application it produce error which is attached below...I really stucked at this point. I tried so many examples but it gives me same error and i dont know how to resolve it..

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(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.jsm.example.BilboRingQueueSender.main(BilboRingQueueSender.java:19)Naming Exception: 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

Exception in thread "main" java.lang.NullPointerException
at com.jsm.example.BilboRingQueueSender.main(BilboRingQueueSender.java:32)

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm also wondering if I can write some test JMS code without a real server. I'm trying to test failover response so maybe it's best i DON'T have an actual server set up. Still researching but I'll be following this thread and updating with my progress.
reply
    Bookmark Topic Watch Topic
  • New Topic