• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

javax.naming.NoInitialContextException: Need to specify class name in environment or system property

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

I am working on a simple standalone java client to test a web service. When I run, I get following stack trace:


Here is the simple class:

public static void main(String[] args) {
// TODO Auto-generated method stub
try {
SalesOrderCreateOutService service = new SalesOrderCreateOutService();
SalesOrderCreateOut servicePort = service.getSalesOrderCreate_Out_Port();
javax.xml.ws.BindingProvider bp = (javax.xml.ws.BindingProvider) servicePort;
Map<String, Object> context = bp.getRequestContext();
// context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "<URL>.wsdl");
context.put(BindingProvider.USERNAME_PROPERTY, "USER");
context.put(BindingProvider.PASSWORD_PROPERTY, "PWD");
SalesOrderResponse response = null;
Project salesOrderCreateRequest = new Project();
Header header = new Header();
header.setTitle("EAST COAST SHEET METAL MOTOR WARRANTY");
salesOrderCreateRequest.setHeader(header);
try {
response = servicePort.salesOrderCreateOut(salesOrderCreateRequest);
} catch (SalesOrderError_Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TRETURN treturn = response.getTRETURN();
Iterator ls = treturn.getItem().iterator();
while(ls.hasNext()){
TRETURN.Item tempItem = (TRETURN.Item)ls.next();
System.out.println(tempItem.getMESSAGE());
break;
}

} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

Exception is at the bold line above, inside inner try/catch block.
Any clues, how to fix this...
 
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I added code tags to your client code listing, but the line numbers does not correspond to those in the listing.
Could you re-submit the second listing using code tags and indicate at which row the exception occurs?
Best wishes!
 
forums UseR
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed my original posting, the exception is at the bold line.
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
I suspect the error is not directly related to the web service client. It looks like your application is using some JNDI property that is not correctly configured, or your application is not running in the correct environment (perhaps an environment that does not support JNDI).
In what environment is your web service and your web service client running? Are they deployed on different machines?
Best wishes!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic