Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
forums UseR
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • 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...
 
Ivan Krizsan
Ranch Hand
Posts: 2198
1
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic