• Post Reply Bookmark Topic Watch Topic
  • New Topic

axis2 SessionContext.getProperty is null!!!???  RSS feed

 
xin sa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hallo everybody. I have the following code:

----------------------------------------------------
...............
private SessionContext session(){
MessageContext mctx = MessageContext.getCurrentMessageContext();
TransportListener listener = mctx.getTransportIn().getReceiver();
SessionContext session = listener.getSessionContext(mctx);
return session;
}
... ...

public Customer getCustomer() throws AxisFault
{
int custId = ((Integer)session().getProperty(Const.SESSIONCUSTOMER)).intValue(); //getProperty is null!
CustomerInfoServer customerServer = CustomerInfoServer.getCustomerServer();
Customer al = (Customer)customerServer.getCustomer(custId);
System.out.println("Found customer:" + al.getName());
return (Customer)customerServer.getCustomer(custId);
}

----------------------------------------------------------
and i got the erorrs:
---------------------------------------------------------
20.06.2007 10:34:21 org.apache.axis2.rpc.receivers.RPCMessageReceiver invokeBusinessLogic
SCHWERWIEGEND: Exception occurred while trying to invoke service method getCustomer
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:91)
at org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver.receive(AbstractInOutSyncMessageReceiver.java:39)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:144)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:279)
at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:116)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.NullPointerException
at com.bala.getCustomer(SolverCustomerService.java:153)
... 25 more
---------------------------------------------------
can anyone tell me, how can i write my "session()" function, so that i get the "none-null" property of the session?
Thanks a lot!!
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you certain that the session contains an object with key "Const.SESSIONCUSTOMER", whatever that is?
 
xin sa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
first thank you for your antwort.

Yes, i'm sure. I found the Problem can be soluted with
"session().setProperty(Const.SESSIONCUSTOMER,2)" before "getproperty(...)".
because a SessionContext must be filled with somthing first.

but, this number "2" is not, what i want. I want, that it can get the currently Date itself, not a static constance. So, have you idear for this?

thanks
xin
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, i'm sure.

But if I understand correctly what you wrote, you shouldn't have been sure, because there wasn't in fact anything in the session; correct?

this number "2" is not, what i want. I want, that it can get the currently Date itself, not a static constance.

Well, if you want to retrieve the current date from the session (why?) instead of a number, then you will first have to put the date into the session, like "session().setProperty(Const.SESSIONCUSTOMER, new Date())". Am I misunderstanding what you are trying to do?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!