wood burning stoves 2.0*
The moose likes Web Services and the fly likes javax.naming.NoInitialContextException: Need to specify class name in environment or system property Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Web Services
Bookmark "javax.naming.NoInitialContextException: Need to specify class name in environment or system property" Watch "javax.naming.NoInitialContextException: Need to specify class name in environment or system property" New topic
Author

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

forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
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

Joined: Oct 04, 2006
Posts: 2198
    
    1
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!


My free books and tutorials: http://www.slideshare.net/krizsan
forums UseR
Ranch Hand

Joined: Feb 24, 2009
Posts: 169
I changed my original posting, the exception is at the bold line.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
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!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javax.naming.NoInitialContextException: Need to specify class name in environment or system property