[opencms-dev] Custom widget causes error during startup

Paul-Inge Flakstad flakstad at npolar.no
Tue Sep 1 17:38:52 CEST 2009


Good afternoon list

I've implemented CmsCustomSourceSelectWidget, which is an example custom widget from the book "OpenCms 7 Development" by Dan Liliedahl. I'm sure many of you have also done this. The widget is running fine, but today I discovered an error in my log which I haven't noticed before (but I guess it has been there all along). The error happens during initialization of OpenCms, when the widgets are added. As the log shows, the widget is added anyway after the exception, so there's no real problem other than the annoying presence of this exception.

Details: The NullPointerException is caused when trying to instanciate an object of class null. I only use the custom widget in one XSD, where I set ContentFieldListDS as the DataSource class. This is done in the widget's configuration string. Apparently OpenCms has not read the configuration string at the time the exception is thrown, since the class name string is null when it should be "ContentFieldListDS".

Has anyone else experienced this?

Cheers,
Paul

Attachment; snippet from my log:

01 sep 2009 16:10:47,486  INFO [s.xml.CmsXmlContentTypeManager: 241] . XML content config   : added widget "org.opencms.widgets.CmsTextareaWidgetPlaintext"
01 sep 2009 16:10:47,486  INFO [s.xml.CmsXmlContentTypeManager: 241] . XML content config   : added widget "org.opencms.widgets.CmsUserWidget"
01 sep 2009 16:10:47,486  INFO [s.xml.CmsXmlContentTypeManager: 241] . XML content config   : added widget "org.opencms.widgets.CmsVfsFileWidget"
01 sep 2009 16:10:47,486 ERROR [ts.CmsCustomSourceSelectWidget: 104] Error instantiating DataSource object of class "null" - "null"
java.lang.NullPointerException
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Unknown Source)
 at no.npolar.common.widgets.CmsCustomSourceSelectWidget.setConfiguration(CmsCustomSourceSelectWidget.java:99)
 at org.opencms.widgets.A_CmsWidget.<init>(A_CmsWidget.java:66)
 at org.opencms.widgets.A_CmsSelectWidget.<init>(A_CmsSelectWidget.java:66)
 at org.opencms.widgets.CmsSelectWidget.<init>(CmsSelectWidget.java:67)
 at no.npolar.common.widgets.CmsCustomSourceSelectWidget.<init>(CmsCustomSourceSelectWidget.java:71)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
 at java.lang.reflect.Constructor.newInstance(Unknown Source)
 at java.lang.Class.newInstance0(Unknown Source)
 at java.lang.Class.newInstance(Unknown Source)
 at org.opencms.xml.CmsXmlContentTypeManager.addWidget(CmsXmlContentTypeManager.java:227)
 at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.commons.beanutils.MethodUtils.invokeMethod(MethodUtils.java:216)
 at org.apache.commons.digester.CallMethodRule.end(CallMethodRule.java:626)
 at org.apache.commons.digester.Rule.end(Rule.java:253)
 at org.apache.commons.digester.Digester.endElement(Digester.java:1222)
 at org.apache.xerces.parsers.AbstractSAXParser.endElement(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:348)
 at org.opencms.main.OpenCmsCore.initConfiguration(OpenCmsCore.java:962)
 at org.opencms.main.OpenCmsCore.initContext(OpenCmsCore.java:1306)
 at org.opencms.main.OpenCmsCore.upgradeRunlevel(OpenCmsCore.java:1731)
 at org.opencms.main.OpenCmsListener.contextInitialized(OpenCmsListener.java:87)
 at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3764)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4216)
 at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
 at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
 at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
 at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:831)
 at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:720)
 at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:490)
 at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
 at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
 at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
 at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
 at org.apache.catalina.core.StandardService.start(StandardService.java:448)
 at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
 at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
 at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)
01 sep 2009 16:10:47,502  INFO [s.xml.CmsXmlContentTypeManager: 241] . XML content config   : added widget "no.npolar.common.widgets.CmsCustomSourceSelectWidget"
01 sep 2009 16:10:47,502  INFO [s.xml.CmsXmlContentTypeManager: 208] . XML content config   : added schema type "OpenCmsBoolean" using default widget "org.opencms.widgets.CmsCheckboxWidget"
01 sep 2009 16:10:47,502  INFO [s.xml.CmsXmlContentTypeManager: 208] . XML content config   : added schema type "OpenCmsColor" using default widget "org.opencms.widgets.CmsColorpickerWidget"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090901/74bafd67/attachment.htm>


More information about the opencms-dev mailing list