[opencms-dev] CmsObject#readAllProjectResources(id) throws ClassCastException

John Emmer jemmer at avega.com
Sat May 7 02:34:08 CEST 2005





I'm just poking around trying to learn my way around the OpenCMS APIs.
I've deployed the 6.0 beta 2 release and added a simple servlet that
contains the following code:

        PrintWriter out = response.getWriter();

        try {

            CmsObject cms = OpenCms.initCmsObject("Guest");
            cms.loginUser("Admin","admin");
            out.println("Accessible Projects<BR>");
            out.println("<UL>");
            for ( Iterator projIter =
cms.getAllAccessibleProjects().iterator(); projIter.hasNext();) {
                CmsProject project = (CmsProject)projIter.next();
                out.println( "<LI>"+project.toString()+"</LI>" );
                out.println("Project Resources<BR>");
                out.println("<OL>");
                List resources =
cms.readAllProjectResources(project.getId());
                for ( Iterator resIter = resources.iterator();
resIter.hasNext(); ) {
                    CmsResource resource = (CmsResource)resIter.next();
                    I_CmsResourceType type =
OpenCms.getResourceManager().getResourceType(resource.getTypeId());
                    out.println(
"<LI>"+resource.getResourceId().toString()+" : "+type+" : "
                            +resource.getName()+" :
"+resource.getRootPath()+"</LI>" );
                }
                out.println("</OL>");
            }
            out.println("</UL>");
        } catch (CmsException e) {
            e.printStackTrace(out);
        }

When I access my servlet, I get the following:

org.opencms.main.CmsException: Exception during database operation [Code 0
- Unknown exception] Root cause was: java.lang.ClassCastException
at org.opencms.db.CmsDbContext.report(CmsDbContext.java:197)
at
org.opencms.db.CmsSecurityManager.readAllProjectResources(CmsSecurityManager.java:2679)

at org.opencms.file.CmsObject.readAllProjectResources(CmsObject.java:1982)
at com.avega.cms.OpenCMSProbe.examineCmsObject(OpenCMSProbe.java:95)
at com.avega.cms.OpenCMSProbe.service(OpenCMSProbe.java:69)
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:534)
>-----------
>Root cause:
>java.lang.ClassCastException
> at
org.opencms.db.CmsDriverManager.updateContextDates(CmsDriverManager.java:7025)

> at
org.opencms.db.CmsDriverManager.readAllProjectResources(CmsDriverManager.java:4824)

> at
org.opencms.db.CmsSecurityManager.readAllProjectResources(CmsSecurityManager.java:2677)

> at
org.opencms.file.CmsObject.readAllProjectResources(CmsObject.java:1982)
> at com.avega.cms.OpenCMSProbe.examineCmsObject(OpenCMSProbe.java:95)
> at com.avega.cms.OpenCMSProbe.service(OpenCMSProbe.java:69)
> 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:534)

What am I doing wrong?  At this point, I just want to walk the resource
tree to see what everything looks like from the API point of view.

Thanks!

-----------------------------------------------------------------------------

John Emmer
Senior Software Engineer
Avega
200 N. Sepulveda, Suite 600   El Segundo, CA 90245
310-563-3322    jemmer at avega.com





More information about the opencms-dev mailing list