[opencms-dev] Re: NullPointerException thrown when attempting CmsObject.readAllProjectResources()
Thomas Joseph Olaes
thomas.olaes at gmail.com
Sat Jul 31 00:53:01 CEST 2004
I finally figured out what I was doing wrong, I wasn't properly
acquiring the correct CmsObject object. I had to do the following:
//CmsObject cmsobject = new CmsObject();
CmsObject cmsobject = CmsFlexController.getCmsObject(request);
Instead of making a new instance of CmsObject, I have to get one from
the request.
-TJ
On Fri, 30 Jul 2004 14:33:09 -0700, Thomas Joseph Olaes
<thomas.olaes at gmail.com> wrote:
> I should add that I'm using OpenCMS 5.0.1
>
>
>
> On Fri, 30 Jul 2004 14:32:23 -0700, Thomas Joseph Olaes
> <thomas.olaes at gmail.com> wrote:
> > Hi list!
> >
> > I'm having a problem with CmsObject.readAllProjectResources() at the
> > moment. Here's my code:
> >
> > <%@ page session="false"
> > import="com.opencms.core.*,
> > com.opencms.file.CmsObject,
> > com.opencms.file.CmsFile,
> > java.util.Vector,
> > java.util.Iterator"
> > %>
> > <%
> > CmsObject cmsobject = new CmsObject();
> >
> > Vector vecProjectResources = new Vector();
> >
> > int iProjectID = 7;
> >
> > try{
> > vecProjectResources = cmsobject.readAllProjectResources(iProjectID);
> > }
> > catch(CmsException my_cmsexception){
> > out.println("I shat myself because: " + my_cmsexception.getMessage());
> > return;
> > }
> > catch(Throwable tt){
> > out.println("I shat myself because: " + tt.toString());
> > tt.printStackTrace();
> > return;
> > }
> > %>
> >
> > This is being done from within a JSP. I'm getting the catch at the
> > catch(Throwable tt) clause, and it returns:
> >
> > I shat myself because: java.lang.NullPointerException
> >
> > further the stack trace looks like this (from tt.printStackTrace()):
> >
> > java.lang.NullPointerException
> > at com.opencms.file.CmsObject.readAllProjectResources(CmsObject.java:2669)
> > at org.apache.jsp.testCmsObject_jsp_jsp._jspService(testCmsObject_jsp_jsp.java:53)
> > at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
> > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> > ...
> >
> > I looked at the source code and see that the readAllProjectResources()
> > method is 1 line, making a return of the results of another function
> > readAllProjectResources from an interface...
> >
> > without going to the extreme case of inserting stuff into the OpenCMS
> > source that i have here, I was wondering if anyone could help me out
> > with this problem. I have no idea why a java.lang.NullPointerException
> > would be thrown in this case, since I supplied an integer value to the
> > function when I called it, and that integer is a valid project ID (I
> > checked the data tables, my project ID number is 7.
> >
> > Any help is appreciated on this issue, thank you for your time,
> > patience, and assistance in advance.
> >
> > -TJ
> >
>
More information about the opencms-dev
mailing list