[opencms-dev] Starting CmsShell programatically

Thomas Göttlich guo.tuomi at googlemail.com
Tue Jul 13 20:51:15 CEST 2010


Hi,

I want to call CmsShell from from a custom ant task, like this:

String tArgs[] = new String[3];
tArgs[0] = "-base=" + webInfPath;
tArgs[1] = "-defaultWebApp=opencms";
tArgs[2] = "-servletMapping=opencms";

CmsShell.main( tArgs );


The class path for the task is set to the OpenCMS WEB-INF/lib folder and the
JBoss lib folder (for servlet-api.jar etc.).

The parameters seem to work, since the opencms.properties file is read, for
example.

However, there is a class loading problem:

java.lang.ClassNotFoundException:
org.opencms.configuration.CmsSystemConfiguration
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at
org.apache.commons.digester.ObjectCreateRule.begin(ObjectCreateRule.java:205)
        at org.apache.commons.digester.Rule.begin(Rule.java:175)
        at
org.apache.commons.digester.Digester.startElement(Digester.java:1453)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
        at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
Source)
        at org.apache.xerces.impl.dtd.XMLDTDValidator.emptyElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
Source)
        at org.apache.commons.digester.Digester.parse(Digester.java:1765)
        at
org.opencms.configuration.CmsConfigurationManager.loadXmlConfiguration(CmsConfigurationManager.java:507)
        at
org.opencms.configuration.CmsConfigurationManager.loadXmlConfiguration(CmsConfigurationManager.java:342)
        at
org.opencms.main.OpenCmsCore.initConfiguration(OpenCmsCore.java:970)
        at
org.opencms.main.OpenCmsCore.upgradeRunlevel(OpenCmsCore.java:1699)
        at org.opencms.main.CmsShell.<init>(CmsShell.java:458)


Calling CmsShell from an ant task with the very same classpath works:

<java classname="org.opencms.main.CmsShell" fork="true" input="shell.input">
      <classpath>
        <fileset dir="${opencms.lib.dir}">
          <include name="**/*.jar"/>
        </fileset>
        <fileset dir="${jboss.server.dir}/lib">
          <include name="**/*.jar"/>
        </fileset>
      </classpath>
      <arg value="-base=${opencms.web.dir}" />
      <arg value="-defaultWebApp=opencms" />
      <arg value="-servletMapping=opencms" />
    </java>

Any ideas why it doesn't work from a custom task?

Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20100713/3ce73f68/attachment.htm>


More information about the opencms-dev mailing list