This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Web Services and the fly likes problem by invoking web service with axis2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "problem by invoking web service with axis2" Watch "problem by invoking web service with axis2" New topic

problem by invoking web service with axis2

xin sa

Joined: May 02, 2007
Posts: 11
Hello, everybody, i have a erorr by the Invoking web service with axis2, plese help me!

the service code:
public void estConnection(String user, String passwd) throws AxisFault
String connString = Const.getCONNECTIONSTRING();
if(connString == null)
throw new AxisFault("Unknown server defined in web.xml.");

SessionContext session = MessageContext.getCurrentMessageContext().getSessionContext();
Connection conn;
catch(ClassNotFoundException cnfe)
throw new AxisFault("Oracle Driver-class not found.");
conn = DriverManager.getConnection(connString, user, passwd);
catch(SQLException sqle)
throw new AxisFault("Connection as admin could not be established.\n" + connString + " User: " + user);
DBHandler dbHandler = new DBHandler();

the client side code:
private static EndpointReference targetEPR = new EndpointReference("http://"+endpoint()+"/axis2/services/SolverAdminService");

public void estConnection(String user, String passwd)throws RemoteException{

RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
QName opSet = new QName("", "estConncetion");
Object response = serviceClient.invokeBlocking(opSet,new Object[] {user,passwd });
if(response instanceof RemoteException)
throw (RemoteException)response;

and if i run the client side package,there is always a erorr the compile is already passed.)

2007-05-29 12:25:24,180 ERROR org.apache.axis2.rpc.receivers.RPCMessageReceiver - Exception occurred while trying to invoke service method estConnection
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(
at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(
at org.apache.axis2.engine.AxisEngine.receive(
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(
at org.apache.axis2.transport.http.AxisServlet.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(
at org.apache.tomcat.util.threads.ThreadPool$
at Source)
Caused by: java.lang.NullPointerException
the line 65 is "session.getProperties().remove(Const.SESSIONUSER);" in the above service-side code.

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 41599
Is "session" null, or "session.getProperties()" ?

Ping & DNS - my free Android networking tools app
xin sa

Joined: May 02, 2007
Posts: 11
i think, that session is null.
have you any idears?
xin sa

Joined: May 02, 2007
Posts: 11
Hi, I have found, that Session is null, and i added the following codes:

public static SessionContext createSessionContext(MessageContext messageContext) {

HttpServletRequest request = (HttpServletRequest) messageContext.getProperty(
SessionContext sessionContext = null;

HttpSession httpSession = request.getSession(true);
if (httpSession != null) {
sessionContext =
(SessionContext) httpSession.getAttribute(Constants.SESSION_CONTEXT_PROPERTY);
if (sessionContext == null && httpSession.isNew()) {
String cookieValueString = httpSession.getId();
sessionContext = new SessionContext(null);
httpSession.setAttribute(Constants.SESSION_CONTEXT_PROPERTY, sessionContext);
messageContext.setProperty("SessionId", cookieValueString);
return sessionContext;


SessionContext session = createSessionContext(MessageContext.getCurrentMessageContext());

So this time the session(or SessionContext) is not null, ha, that's good, buuuuut~~, the "session.getProperties()" is null, oooohhhhh.....
has anyone idears? help me
I agree. Here's the link:
subject: problem by invoking web service with axis2