• XPages and classloading

    By Olle Thalén 1 decade ago

    We have a recurring problem when refreshing our test environment with applications which uses xpages and our own java classes.

    We implement most backend code with java managed beans, and it seems like sometimes some java classes are not visible for the current class loader.

    Here is a log document after updating test environment:

     

     

        java.lang.NoClassDefFoundError: company.Test.PropertyTypeComparator</div>
    
        &nbsp;</div>
    
        at company.Test.SystemPropertiesComparatorFactory.getPropertyTypeComparator(SystemPropertiesComparatorFactory.java:14)</div>
    
        &nbsp;</div>
    
        at company.Test.PropertiesSort.sortDefaultColumn(PropertiesSort.java:63)</div>
    
        &nbsp;</div>
    
        at company.Test.SystemProperties.getSystemProperties(SystemProperties.java:124)</div>
    
        &nbsp;</div>
    
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</div>
    
        &nbsp;</div>
    
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)</div>
    
        &nbsp;</div>
    
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)</div>
    
        &nbsp;</div>
    
        at java.lang.reflect.Method.invoke(Method.java:611)</div>
    
        &nbsp;</div>
    
        at com.sun.faces.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:96)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.el.PropertyResolverImpl.getValue(PropertyResolverImpl.java:144)</div>
    
        &nbsp;</div>
    
        at com.sun.faces.el.impl.ArraySuffix.evaluate(ArraySuffix.java:182)</div>
    
        &nbsp;</div>
    
        at com.sun.faces.el.impl.ComplexValue.evaluate(ComplexValue.java:163)</div>
    
        &nbsp;</div>
    
        at com.sun.faces.el.impl.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:257)</div>
    
        &nbsp;</div>
    
        at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:150)</div>
    
        &nbsp;</div>
    
        at com.sun.faces.el.ValueBindingImpl.getValue(ValueBindingImpl.java:134)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.component.UIDataIterator.getValue(UIDataIterator.java:422)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.component.UIDataIterator.createDataModel(UIDataIterator.java:206)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.component.UIDataIterator.getDataModel(UIDataIterator.java:160)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.component.UIDataIterator.setRowIndex(UIDataIterator.java:456)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.renderkit.html_extended.IteratorRenderer.encodeRows(IteratorRenderer.java:62)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.renderkit.html_extended.IteratorRenderer.encodeChildren(IteratorRenderer.java:55)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.renderkit.ReadOnlyAdapterRenderer.encodeChildren(ReadOnlyAdapterRenderer.java:162)</div>
    
        &nbsp;</div>
    
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:979)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.component.UIDataIterator.encodeChildren(UIDataIterator.java:725)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:842)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.util.FacesUtil.renderComponent(FacesUtil.java:851)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.component.UIViewRootEx._renderView(UIViewRootEx.java:1317)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.component.UIViewRootEx.renderView(UIViewRootEx.java:1255)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.application.ViewHandlerExImpl.doRender(ViewHandlerExImpl.java:641)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.application.ViewHandlerExImpl._renderView(ViewHandlerExImpl.java:320)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.application.ViewHandlerExImpl.renderView(ViewHandlerExImpl.java:335)</div>
    
        &nbsp;</div>
    
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:103)</div>
    
        &nbsp;</div>
    
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)</div>
    
        &nbsp;</div>
    
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:264)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:248)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:200)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:137)</div>
    
        &nbsp;</div>
    
        at com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)</div>
    
        &nbsp;</div>
    
        at com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)</div>
    
        &nbsp;</div>
    
        at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1267)</div>
    
        &nbsp;</div>
    
        at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)</div>
    
        &nbsp;</div>
    
        at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)</div>
    
        &nbsp;</div>
    
        at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)</div>
    
        &nbsp;</div>
    
        at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1251)</div>
    
        &nbsp;</div>
    
        at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:598)</div>
    
        &nbsp;</div>
    
        at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:421)</div>
    
        &nbsp;</div>
    
        at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)</div>
    
        &nbsp;</div>
    
        at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)</div>
    
        &nbsp;</div>
    
        at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)</div>
    
        &nbsp;</div>
    
        Caused by: java.lang.ClassNotFoundException: Cannot find class company.Test.PropertyTypeComparator in NSF</div>
    
        &nbsp;</div>
    
        at java.lang.ClassNotFoundException.&lt;init&gt;(ClassNotFoundException.java:89)</div>
    
        &nbsp;</div>
    
        at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.findClass(ModuleClassLoader.java:355)</div>
    
        &nbsp;</div>
    
        at java.lang.ClassLoader.loadClass(ClassLoader.java:653)</div>
    
        &nbsp;</div>
    
        at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.loadClass(ModuleClassLoader.java:341)</div>
    
        &nbsp;</div>
    
        at java.lang.ClassLoader.loadClass(ClassLoader.java:619)</div>
    
        &nbsp;</div>
    
        ... 57 more</div>
    
        &nbsp;</div>
    
        Caused by: java.lang.ClassNotFoundException: company.Test.PropertyTypeComparator</div>
    
        &nbsp;</div>
    
        at java.lang.ClassNotFoundException.&lt;init&gt;(ClassNotFoundException.java:76)</div>
    
        &nbsp;</div>
    
        at java.net.URLClassLoader.findClass(URLClassLoader.java:396)</div>
    
        &nbsp;</div>
    
        at com.ibm.domino.xsp.module.nsf.ModuleClassLoader$DynamicClassLoader.findClass(ModuleClassLoader.java:405)</div>
    
        &nbsp;</div>
    
        ... 60 more</div>
    
        &nbsp;</div>
    
        However, if I compile PropertyTypeComparator in a separate eclipse instance and create a jar and put that jar into WebContent\WEB-INF\lib the classloader finds the classes each time.</div>
    <p>
        But now we have used the new java design element (domino designer 8.5.3), our servers is also on 8.5.3. Anyone knows what might be causing these problems? Our solution at the moment is to put all our java classes in jars and put them in the lib directory. But it would be nice if we could do all development in domino designer instead of having two development environments (e.g domino designer and eclipse for j2ee developers).</p>
    <p>
        My theory so far is that the problems occur because xpages runtime uses multiple classloaders (I think), each nsf has its own classloader. But that is just a theory, I don&#39;t know much about classloading tbh.</p>
    <p>
        I&#39;ve also noticed that this exception only occurs for enums, but I don&#39;t know what could be special about enums.</p>
    <p>
        Any help/advices will be appreciated!</p>
    <p>
        Regards,</p>
    <p>
        Olle Thal&eacute;n</p>
    
        &nbsp;</div>
    

    &nbsp;
    
    &nbsp;