aspose file tools
The moose likes Web Services and the fly likes axis2 SessionContext.getProperty is null!!!??? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "axis2 SessionContext.getProperty is null!!!???" Watch "axis2 SessionContext.getProperty is null!!!???" New topic
Author

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

xin sa
Greenhorn

Joined: May 02, 2007
Posts: 11
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
Marshal

Joined: Mar 22, 2005
Posts: 35436
    
    9
Are you certain that the session contains an object with key "Const.SESSIONCUSTOMER", whatever that is?


Android appsImageJ pluginsJava web charts
xin sa
Greenhorn

Joined: May 02, 2007
Posts: 11
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
Marshal

Joined: Mar 22, 2005
Posts: 35436
    
    9
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?
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: axis2 SessionContext.getProperty is null!!!???
 
Similar Threads
Exception
Getting error on sending chinese text
problem by invoking web service with axis2
org.apache.axis2.AxisFault: A required header representing a Message Addressing Property is not pres
How to get the client's ip address?