[opencms-dev] Calling a java class from OC beta 2
CALI-GARSIA Bruno
bruno.cali-garsia-renexter at renault.com
Mon Nov 25 19:00:56 CET 2002
Hi Kevin,
You should try to put the full package name when you define a class :
------8<--------
<ELEMENTDEF name="testelement">
>>>>>>> <CLASS>com.text.opencms.TestElement</CLASS> <<<<<<
<TEMPLATE>../elements/testelement</TEMPLATE>
</ELEMENTDEF>
regards
Bruno
-----Message d'origine-----
De : owner-opencms-dev at www.opencms.org
[mailto:owner-opencms-dev at www.opencms.org]De la part de Kevin McKenzie
Envoyé : lundi 25 novembre 2002 17:04
À : opencms-dev at www.opencms.org
Objet : Re: [opencms-dev] Calling a java class from OC beta 2
25/11/2002 14:20:14, "Assaf Nehoray" <anehoray at hotmail.com> wrote:
> Hi,
>
> I am trying to integrate between OpenCMS and another application which is
> java based. I am checking out how I can do that using JSPs. I wrote a jsp
> page in the root. In it I am trying to use a class(<jsp:useBean>) and
then
> call it. I have placed the .class in the classes directory as well as in
the
> root directory alas it cannot find it and I get a jsp error.
>
> I am using the new beta 2 version 5.0 where the directory structure is a
> little different. Since the documentation is not yet up to date I am
> clueless. Anyone can give me some simple guidance on how to call a java
> class/ application.
Hi Assaf,
I don't have an answer for you but thought I would share my experience, as
it may help
others to provide an answer.
I have been looking at: 2.3.2. Setting data blocks dynamically.
My templates look like this:
testmaster2
<?xml version="1.0"?>
<XMLTEMPLATE>
<ELEMENTDEF name="contenttemplate">
<CLASS>com.opencms.template.CmsXmlTemplate</CLASS>
<TEMPLATE>testcontent</TEMPLATE>
</ELEMENTDEF>
<ELEMENTDEF name="frametemplate">
<CLASS>com.opencms.template.CmsXmlTemplate</CLASS>
<TEMPLATE>testframe</TEMPLATE>
</ELEMENTDEF>
<TEMPLATE> <ELEMENT name="frametemplate"/> </TEMPLATE>
</XMLTEMPLATE>
testframe
<XMLTEMPLATE>
<TEMPLATE><![CDATA[
<HTML>
<HEAD>
<TITLE>]]><method name="getTitle"/><![CDATA[</TITLE>
</HEAD>
<BODY>
<TABLE border width="100%" height="100%">
<TR height="30%">
<TH colspan=2 width="100%" align="center">
The Head section
</TH>
</TR>
<TR height="70%">
<TD width="20%" align="center" valign="top">
Navigation
</TD>
<TD width="80%" align="center">
]]><ELEMENT name="contenttemplate"/><![CDATA[
</TD>
</TR>
</TABLE>
</BODY>
</HTML>]]>
</TEMPLATE>
</XMLTEMPLATE>
testcontent
<?xml version="1.0" encoding="ISO-8859-1"?>
<XMLTEMPLATE>
<TEMPLATE>
<ELEMENT name="testelement"/>
<ELEMENT name="body"/>
</TEMPLATE>
<ELEMENTDEF name="testelement">
<CLASS>TestElement</CLASS>
<TEMPLATE>../elements/testelement</TEMPLATE>
</ELEMENTDEF>
</XMLTEMPLATE>
My Java class is as follows:
package com.text.opencms;
import com.opencms.template.*;
import com.opencms.file.*;
import com.opencms.core.*;
import java.util.*;
public class TestElement extends CmsXmlTemplate {
public byte[] getContent( CmsObject cms, String templateFile, String
elementName,
Hashtable parameters,String templateSelector )
throws CmsException {
CmsXmlTemplateFile templateDocument = getOwnTemplateFile(cms,
templateFile,
elementName, parameters, templateSelector);
templateDocument.setData("greeting","from KevKiwi!!!");
return startProcessing(cms, templateDocument, elementName,
parameters, templateFile);
}
}
I compiled my Java class and copied it to:
\WEB-INF\classes\com\test\opencms
I created page with the followinf properties:
Title: testpage2
State: new
Owner: (Admin)
Group: Administrators
When I try to display this page, I get the following error:
[CmsException]: 26 Wrong XML template class. Detailed Error: Could not
initialize (sub-)
element for class "TestElement". [CmsException]: 29 OpenCms class loader
error.
Detailed Error: Could not load template class TestElement. TestElement.
Caught
Exception: >java.lang.ClassNotFoundException: TestElement<.
at
com.opencms.template.cache.CmsElementLocator.get(CmsElementLocator.java:166)
at com.opencms.template.cache.A_CmsElement.checkProxySettings
(A_CmsElement.java:347)
at com.opencms.template.cache.A_CmsElement.checkProxySettings
(A_CmsElement.java:350)
at com.opencms.template.cache.CmsUri.callCanonicalRoot(CmsUri.java:129)
at com.opencms.template.cache.CmsElementCache.callCanonicalRoot
(CmsElementCache.java:148)
at
com.opencms.launcher.CmsXmlLauncher.generateOutput(CmsXmlLauncher.java:263)
at com.opencms.launcher.CmsXmlLauncher.launch(CmsXmlLauncher.java:319)
at com.opencms.launcher.A_CmsLauncher.initlaunch(A_CmsLauncher.java:268)
at com.opencms.core.OpenCms.showResource(OpenCms.java:781)
at com.opencms.core.OpenCmsHttpServlet.doGet(OpenCmsHttpServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:243)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:190)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:2
46)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:170)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170
)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
64)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
at
org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5
66)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at
org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:
1012)
at
org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107
)
at java.lang.Thread.run(Thread.java:536)
More information about the opencms-dev
mailing list