[opencms-dev] Accessing OpenCMS from a standalone java application

Jaisy Ann Cheriyan Jaisy_Cheriyan at infosys.com
Wed Jan 10 13:36:24 CET 2007


Dear

             Please have a look at the java files written so as to
access OpenCMS contents



public class FetchData {



            public static void main(String[] args){



                        try{

                                    String loggedUser;

                                    MyCmsShell shell = new MyCmsShell
("C:/ApacheTomcat/Tomcat 5.0/webapps/opencms/WEB-INF", null, null);

                                    CmsObject cms =
shell.getOpenCmsObject();

cms.loginUser("Admin", "admin");

                       }



                        catch(Exception exp){

                                    System.out.println("Exception!!" +
exp);

                                    exp.printStackTrace();



                        }

            }



}



public class MyCmsShell extends CmsShell

{

  public MyCmsShell (String webInfPath, String servletMapping, String
defaultWebAppName)

  {

    super (webInfPath, servletMapping, defaultWebAppName, "", null);

  }



  public CmsObject getOpenCmsObject()

  {

    return m_cms;

  }





And the error that is happening is



C:\OpenCMSenter>java FetchData

log4j:WARN No appenders could be found for logger (org.opencms.init).

log4j:WARN Please initialize the log4j system properly.

OpenCms WEB-INF path:  "C:/ApacheTomcat/Tomcat
5.0/webapps/opencms/WEB-INF".

OpenCms property file: "C:\ApacheTomcat\Tomcat
5.0\webapps\opencms\WEB-INF\confi

g\opencms.properties".





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

The following critical error occured:

Critical error during OpenCms initialization: Unable to read the OpenCms
XML con

figuration.

Giving up, unable to start OpenCms.

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

org.opencms.main.CmsInitException: Critical error during OpenCms
initialization:

 Unable to read the OpenCms XML configuration.

        at
org.opencms.main.OpenCmsCore.initConfiguration(OpenCmsCore.java:812)

        at
org.opencms.main.OpenCmsCore.upgradeRunlevel(OpenCmsCore.java:1490)

        at org.opencms.main.CmsShell.<init>(CmsShell.java:495)

        at MyCmsShell.<init>(MyCmsShell.java:20)

        at FetchData.main(FetchData.java:7)

Caused by: java.lang.ClassNotFoundException:
com.opencms.legacy.CmsXmlTemplateLo

ader

        at
org.apache.commons.digester.Digester.createSAXException(Digester.java

:2919)

        at
org.apache.commons.digester.Digester.createSAXException(Digester.java

:2945)

        at
org.apache.commons.digester.Digester.startElement(Digester.java:1364)



        at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startEle

ment(Unknown Source)

        at
com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.

emptyElement(Unknown Source)

        at
com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElem

ent(Unknown Source)

        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp

l.scanStartElement(Unknown Source)

        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp

l$FragmentContentDispatcher.dispatch(Unknown Source)

        at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImp

l.scanDocument(Unknown Source)

        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U

nknown Source)

        at
com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(U

nknown Source)

        at
com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown So

urce)

        at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Un

known Source)

        at
org.apache.commons.digester.Digester.parse(Digester.java:1666)

        at
org.opencms.configuration.CmsConfigurationManager.loadXmlConfiguratio

n(CmsConfigurationManager.java:499)

        at
org.opencms.configuration.CmsConfigurationManager.loadXmlConfiguratio

n(CmsConfigurationManager.java:342)

        at
org.opencms.main.OpenCmsCore.initConfiguration(OpenCmsCore.java:810)

        ... 4 more

Exception!!java.lang.NullPointerException

java.lang.NullPointerException

        at FetchData.main(FetchData.java:9)





Regards

Jaisy





**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20070110/84979285/attachment.htm>


More information about the opencms-dev mailing list