Re: Obtaining a request
Re: Obtaining a request
- Subject: Re: Obtaining a request
- From: Ian Coleman <email@hidden>
- Date: Tue, 14 Feb 2006 14:20:41 -0500
Chuck Hill wrote:
On Feb 14, 2006, at 6:56 AM, Ian Coleman wrote:
We are trying to get information from a protal that is hosting the
WO app, this is what I am using to try to do so.
public Main(WOContext context) {
super(context);
WORequest request = context.request();
WOServletContext wosc = new WOServletContext
(request); //this is where I get a java.lang.NullPointerException
What is the stack trace?
java.lang.NullPointerException
at
com.webobjects.jspservlet.WOServletContext.<init>(WOServletContext.java:40)
at Main.<init>(Main.java:44)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at
com.webobjects.foundation._NSUtilities.instantiateObject(_NSUtilities.java:575)
at
com.webobjects.appserver._private.WOComponentDefinition._componentInstanceInContext(WOComponentDefinition.java:463)
at
com.webobjects.appserver._private.WOComponentDefinition.componentInstanceInContext(WOComponentDefinition.java:573)
at
com.webobjects.appserver.WOApplication.pageWithName(WOApplication.java:1954)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedSession(WOComponentRequestHandler.java:273)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedApplication(WOComponentRequestHandler.java:322)
at
com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(WOComponentRequestHandler.java:358)
at
com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WOComponentRequestHandler.java:432)
at
com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1306)
at
com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:173)
at
com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:552)
Isn't context already a WOServletContext (which is a subclass of
WOContext)? Can you just do:
WOServletContext wosc = (WOServletContext) context;
When I tried that it throws java.lang.ClassCastException
at Main.<init>(Main.java:45)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at
com.webobjects.foundation._NSUtilities.instantiateObject(_NSUtilities.java:575)
at
com.webobjects.appserver._private.WOComponentDefinition._componentInstanceInContext(WOComponentDefinition.java:463)
at
com.webobjects.appserver._private.WOComponentDefinition.componentInstanceInContext(WOComponentDefinition.java:573)
at
com.webobjects.appserver.WOApplication.pageWithName(WOApplication.java:1954)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedSession(WOComponentRequestHandler.java:27[2006-02-14
14:19:01 EST] <WorkerThread0>
<com.webobjects.appserver._private.WOComponentRequestHandler>: Exception
occurred while handling request:
com.webobjects.foundation.NSForwardException
[java.lang.ClassCastException] null
3)
at
com.webobjects.appserver._private.WOComponentRequestHandler._dispatchWithPreparedApplication(WOComponentRequestHandler.java:322)
at
com.webobjects.appserver._private.WOComponentRequestHandler._handleRequest(WOComponentRequestHandler.java:358)
at
com.webobjects.appserver._private.WOComponentRequestHandler.handleRequest(WOComponentRequestHandler.java:432)
at
com.webobjects.appserver.WOApplication.dispatchRequest(WOApplication.java:1306)
at
com.webobjects.appserver._private.WOWorkerThread.runOnce(WOWorkerThread.java:173)
at
com.webobjects.appserver._private.WOWorkerThread.run(WOWorkerThread.java:254)
at java.lang.Thread.run(Thread.java:552)
Chuck
IPortletContext newFact =
PortletContextFactory.createPortletContext(wosc.httpServletRequest
(), wosc.httpServletResponse());
IPortletContext newFact =
PortletContextFactory.createPortletContext(wosc.httpServletRequest
(), wosc.httpServletResponse());
IPortletRequest newReq = newFact.getRequest();
IPortletUser portletUser = newFact.getUser();
String uName = portletUser.getUserName();
I thought that the context would have a request. Am I wrong? Do I
need to create a request?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden