Trying to open document in xPages - xpages

I have an ordering system in xPages. In the main order form I accept the customer information as document1 and save those fields as fOrderForm (Form). On the same page I have a view control with all the items ordered which are stored as separate documents than the Customer data. I can save these as new documents with no issues. When I go to open one of the orders which would need code to set a viewScope variable to the order number so the view control can display the order items, it gives me the following error. I have Anonymous set at Editor. I'm new to xPages. Can someone shed some light?
com.ibm.xsp.FacesExceptionEx: Could not open the document
com.ibm.xsp.model.domino.DominoDocumentData.doOpenDocument(Unknown Source)
com.ibm.xsp.model.AbstractDocumentDataSource.openDocument(Unknown Source)
com.ibm.xsp.model.AbstractDocumentDataSource.load(Unknown Source)
com.ibm.xsp.model.AbstractDataSource.getDataContainer(Unknown Source)
com.ibm.xsp.model.domino.DominoDocumentData.getDataObject(Unknown Source)
com.ibm.xsp.model.AbstractDataSource.pushData(Unknown Source)
com.ibm.xsp.util.DataPublisher.publishControlData(Unknown Source)
com.ibm.xsp.component.UIViewRootEx.publishControlData(Unknown Source)
com.ibm.xsp.component.UIViewRootEx.initBeforeContents(Unknown Source)
com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(Unknown Source)
com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(Unknown Source)
com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(Unknown Source)
com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(Unknown Source)
com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(Unknown Source)
com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(Unknown Source)
com.ibm.xsp.application.ViewHandlerEx.createView(Unknown Source)
com.ibm.xsp.webapp.FacesServlet.serviceView(Unknown Source)
com.ibm.xsp.webapp.FacesServletEx.serviceView(Unknown Source)
com.ibm.xsp.webapp.FacesServlet.service(Unknown Source)
com.ibm.xsp.webapp.FacesServletEx.service(Unknown Source)
com.ibm.xsp.webapp.DesignerFacesServlet.service(Unknown Source)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(Unknown Source)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(Unknown Source)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(Unknown Source)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService.access$0(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceThread.run(Unknown Source)
NotesException: Invalid universal id
lotus.domino.local.Database.NgetDocumentByUNID(Native Method)
lotus.domino.local.Database.getDocumentByUNID(Unknown Source)
com.ibm.xsp.model.domino.DominoUtils.getDocumentById(Unknown Source)
com.ibm.xsp.model.domino.DominoUtils.getDocumentById(Unknown Source)
com.ibm.xsp.model.domino.DominoDocumentData.doOpenDocument(Unknown Source)
com.ibm.xsp.model.AbstractDocumentDataSource.openDocument(Unknown Source)
com.ibm.xsp.model.AbstractDocumentDataSource.load(Unknown Source)
com.ibm.xsp.model.AbstractDataSource.getDataContainer(Unknown Source)
com.ibm.xsp.model.domino.DominoDocumentData.getDataObject(Unknown Source)
com.ibm.xsp.model.AbstractDataSource.pushData(Unknown Source)
com.ibm.xsp.util.DataPublisher.publishControlData(Unknown Source)
com.ibm.xsp.component.UIViewRootEx.publishControlData(Unknown Source)
com.ibm.xsp.component.UIViewRootEx.initBeforeContents(Unknown Source)
com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(Unknown Source)
com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(Unknown Source)
com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(Unknown Source)
com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(Unknown Source)
com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(Unknown Source)
com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(Unknown Source)
com.ibm.xsp.application.ViewHandlerEx.createView(Unknown Source)
com.ibm.xsp.webapp.FacesServlet.serviceView(Unknown Source)
com.ibm.xsp.webapp.FacesServletEx.serviceView(Unknown Source)
com.ibm.xsp.webapp.FacesServlet.service(Unknown Source)
com.ibm.xsp.webapp.FacesServletEx.service(Unknown Source)
com.ibm.xsp.webapp.DesignerFacesServlet.service(Unknown Source)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(Unknown Source)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(Unknown Source)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(Unknown Source)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService.access$0(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceRequest.call(Unknown Source)
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
com.ibm.domino.xsp.module.nsf.NSFService$NsfServiceThread.run(Unknown Source)

viewScope variables can't be used in some dominoDocument datasource properties, for example documentId, if it's attached to the XPage or Custom Control. I covered this in my recent session at IBM Connect and I'll be covering it again at Engage next week.
Move it to a Panel and you'll be fine.

Related

Exception on Save when using Frostillic.us XPages Scaffolding

I have created an application that uses the Frostillic.us XPages scaffolding. When executing a save on a document I get an exception thrown when using the following on the page...
<xp:button id="save" value="Save" style='float:right;'>
<xp:eventHandler
event="onclick" submit="true"
refreshMode="complete"
immediate="false" save="true"/>
</xp:button>
The exception is...
java.lang.ClassCastException: lotus.domino.local.Document incompatible with org.openntf.domino.Document at
frostillicus.xsp.model.domino.AbstractDominoModel$DocumentHolder.getDocument(AbstractDominoModel.java:539) at
frostillicus.xsp.model.domino.AbstractDominoModel.document(AbstractDominoModel.java:435) at
frostillicus.xsp.model.domino.AbstractDominoModel.save(AbstractDominoModel.java:322) at
frostillicus.xsp.model.component.ModelDataSource.save(ModelDataSource.java:139) at
com.ibm.xsp.model.AbstractDataSource._saveData(AbstractDataSource.java:553) at
com.ibm.xsp.model.AbstractDataSource.save(AbstractDataSource.java:534) at
com.ibm.xsp.util.FacesUtil.save(FacesUtil.java:578) at
com.ibm.xsp.util.FacesUtil.save(FacesUtil.java:553) at
com.ibm.xsp.component.UIViewRootEx.save(UIViewRootEx.java:1197) at
com.ibm.xsp.component.UIViewRootEx.save(UIViewRootEx.java:1186) at
com.ibm.xsp.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78) at
javax.faces.component.UICommand.broadcast(UICommand.java:324) at
com.ibm.xsp.component.UIEventHandler.broadcast(UIEventHandler.java:366) at
com.ibm.xsp.component.UIViewRootEx.broadcast(UIViewRootEx.java:1535) at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:307) at
javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:428) at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:94) at
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210) at
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96) at
com.ibm.xsp.controller.FacesControllerImpl.execute(FacesControllerImpl.java:256) at
com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:228) at
com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:157) at
com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160) at
com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138) at
com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103) at
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576) at
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1335) at
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:853) at
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796) at
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565) at
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1319) at
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:662) at
com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:482) at
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:357) at
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:313) at
com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
If I take all of my code, Custom Controls xpages etc and put them inside the scaffolding NTF that is used for the example on the site, it all works fine. This led me to think that my database wasn't set-up properly but I can't see where this may be. I have definitely got both required libraries ticked.
Check xsp.propertites in your nsf and compare it with the scaffolding NTF. I bet that org.openntf.domino.xsp is set to "godmode" in the scaffolding NTF and not in yours. So make sure that you add this:
org.openntf.domino.xsp=godmode
You can see the complete xsp.properties from the XPages scaffolding project on Github.

XPages "home made" custom control not recognized

I have added the rich text custom control from the book Mastering Xpages 2nd edition to one of my application, but I keep on getting the following:
2016-02-19T15:20:30.546-05:00 SEVERE CLFAD0095E: Format error reading the class mxpd2.component.InputRichText
2016-02-19T15:20:30.547-05:00 WARNING CLFAD0090W: The component-class (mxpd2.component.InputRichText) could not be resolved for the component with component-type com.ibm.xsp.InputRichText.
The application used to be able to compile when I did a "clean" on the project, but now I get the error all the time.
Here is my mxpd2.xsp-config file:
<faces-config>
<faces-config-extension>
<namespace-uri>http://www.ibm.com/xsp/mxpd2</namespace-uri>
<default-prefix>mxpd2</default-prefix>
</faces-config-extension>
<component>
<description>A specialized Rich Text Editor control for Intact Financial Corp</description>
<display-name>In‌tact Rich Text</display-name>
<component-type>com.ibm.xsp.InputRichText</component-type>
<component-class>mxpd2.component.InputRichText</component-class>
<group-type-ref>com.ibm.xsp.group.core.prop.styleClass</group-type-ref>
<group-type-ref>com.ibm.xsp.group.core.prop.title</group-type-ref>
<group-type-ref>com.ibm.xsp.group.events.prop.onclick</group-type-ref>
<group-type-ref>com.ibm.xsp.group.events.onkey</group-type-ref>
<group-type-ref>com.ibm.xsp.group.focus</group-type-ref>
<group-type-ref>com.ibm.xsp.group.i18n</group-type-ref>
<group-type-ref>com.ibm.xsp.group.input.prop.disabled</group-type-ref>
<group-type-ref>com.ibm.xsp.group.input.prop.onchange</group-type-ref>
<group-type-ref>com.ibm.xsp.group.input.prop.readonly</group-type-ref>
<group-type-ref>com.ibm.xsp.group.outerStyleClass</group-type-ref>
<group-type-ref>com.ibm.xsp.group.filter</group-type-ref>
<group-type-ref>com.ibm.xsp.group.dojoUsage.deprecated</group-type-ref>
<group-type-ref>com.ibm.xsp.group.aria.role</group-type-ref>
<property>
<display-name>CSS Style</display-name>
<property-name>style</property-name>
<property-class>java.lang.String</property-class>
<property-extension>
<pass-through>true</pass-through>
<designer-extension>
<category>styling</category>
<editor>
com.ibm.workplace.designer.property.editors.StylesEditor
</editor>
<styles-excluded>background, font</styles-excluded>
</designer-extension>
</property-extension>
</property>
<component-extension>
<javadoc-description>
<p>Rich Text Control</p>providing rich text editing functionality
</javadoc-description>
<base-component-type>com.ibm.xsp.UIInputRichText</base-component-type>
<renderer-type>com.ibm.xsp.InputRichText</renderer-type>
<tag-name>inputRichText</tag-name>
<designer-extension>
<category>Intact FC</category>
</designer-extension>
</component-extension>
</component>
</faces-config>
It is an almost exact copy of the source code from the book's sample file (Chapter 11b). The java files have been copied into my app(same package), the faces-config.xml shas been modified to the following:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
<converter>
<converter-id>InputRichTextConverter</converter-id>
<converter-class>mxpd2.converter.InputRichTextConverter</converter-class>
</converter>
<managed-bean>
<managed-bean-name>rteBean</managed-bean-name>
<managed-bean-class>mxpd2.bean.InputRichTextBean</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
<managed-property>
<property-name>debug</property-name>
<value>false</value>
</managed-property>
</managed-bean>
<managed-bean id="Appconfig">
<managed-bean-name>AppConfig</managed-bean-name>
<managed-bean-class>com.intact.xpages.utils.AppConfig</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
</managed-bean>
<managed-bean id="SessionConfig">
<managed-bean-name>SessionConfig</managed-bean-name>
<managed-bean-class>com.intact.xpages.utils.SessionConfig</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>EmailBeanV2</managed-bean-name>
<managed-bean-class>com.intact.xpages.utils.EmailBeanV2</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
<managed-property>
<property-name>debugMode</property-name>
<value>false</value>
</managed-property>
</managed-bean>
<!-- required for the lang switch
<lifecycle>
<phase-listener>ch.hasselba.xpages.jsf.core.LocalizationSetter</phase-listener>
</lifecycle>
-->
<!--AUTOGEN-START-BUILDER: Automatically generated by IBM Domino Designer. Do not modify.-->
<application>
<locale-config>
<default-locale>fr</default-locale>
<supported-locale>en</supported-locale>
<supported-locale>fr</supported-locale>
</locale-config>
</application>
<!--AUTOGEN-END-BUILDER: End of automatically generated section-->
</faces-config>
I copied everyhting twice to make sure, but still get the error.
In the original file, I don't have any errors in source mode, but when looking in design mode though, I get a warning that the tag mxpd2 is not recognized and the control is yellow instead of blue.
Can somebody pinpoint the issue?
Here is what I found in the trace log:
09:32:37.429 7 SEVERE com.ibm.xsp.registry.parse.ParseUtil
getClassForName CLFAD0095E: Format error reading the class mxpd2.component.InputRichText
java.lang.ClassFormatError: JVMCFRE113 EOF inattendu; classe=mxpd2/component/InputRichText, décalage=0
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at com.ibm.designer.runtime.server.util.DynamicClassLoaderVFS.doDefineClass(Unknown Source)
at com.ibm.designer.runtime.server.util.DynamicClassLoaderVFS.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at com.ibm.designer.runtime.Application.loadClass(Unknown Source)
at com.ibm.xsp.library.ApplicationFacesClassLoader.loadClass(Unknown Source)
at com.ibm.xsp.registry.parse.ParseUtil.getClassForName(Unknown Source)
at com.ibm.xsp.registry.parse.ParseUtil.loadClass(Unknown Source)
at com.ibm.xsp.registry.parse.definition.ComponentParser.getJavaClass(Unknown Source)
at com.ibm.xsp.registry.parse.definition.ComponentParser.createDefinition(Unknown Source)
at com.ibm.xsp.registry.parse.definition.AbstractDefinitionParser.parse(Unknown Source)
at com.ibm.xsp.registry.parse.ConfigParserImpl.createDefinition(Unknown Source)
at com.ibm.xsp.registry.parse.FacesConfigParserImpl.processChildElements(Unknown Source)
at com.ibm.xsp.registry.parse.FacesConfigParserImpl.parse(Unknown Source)
at com.ibm.xsp.registry.parse.ConfigParserImpl.createFacesLibraryFragment(Unknown Source)
at com.ibm.xsp.registry.parse.ConfigParserImpl.createFacesLibraryFragment(Unknown Source)
at com.ibm.xsp.registry.config.ConfigRegisterer.register(Unknown Source)
at com.ibm.xsp.registry.config.ConfigRegisterer.registerProjectConfig(Unknown Source)
at com.ibm.xsp.registry.config.ConfigRegisterer.registerProjectConfig(Unknown Source)
at com.ibm.xsp.library.ConfigFileMaintainerImpl.reloadAllConfigFiles(Unknown Source)
at com.ibm.designer.domino.ide.resources.project.FacesRegistryMaintainer.changedClassFile(Unknown Source)
at com.ibm.designer.domino.ide.resources.project.DesignerProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.getAffectedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.notifyChangedOrAddedDesignerProject(Unknown Source)
at com.ibm.designer.prj.resources.commons.CommonProjectSynchronizer.resourceChanged(Unknown Source)
at org.eclipse.core.internal.events.NotificationManager$2.run(Unknown Source)
at org.eclipse.core.runtime.SafeRunner.run(Unknown Source)
at org.eclipse.core.internal.events.NotificationManager.notify(Unknown Source)
at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(Unknown Source)
at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Unknown Source)
at org.eclipse.core.internal.resources.Workspace.endOperation(Unknown Source)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(Unknown Source)
at org.eclipse.core.internal.jobs.Worker.run(Unknown Source)
09:32:37.430 7 WARNING com.ibm.xsp.registry.parse.definition.ComponentParser
getJavaClass CLFAD0090W: The component-class (mxpd2.component.InputRichText) could not be resolved for the component with component-type com.ibm.xsp.InputRichText.
some things to check:
can you see any relevant errors under help -> support -> show log
help -> support -> show trace
(sorry if not exact I am not at my computer)
some times you will find errors in here related to invalid xsp config
I can't see your Java source for component, but can
you double check the class name under is exact? if you have renamed the package or class name then it won't find it.
is your namespace (mxpd ) included at the top of your xpages source? if it is not referenced at the top, then it won't know to find the component under that namespace.
also I find that sometimes when developed a uicomponent within an NSF, I have to clean 2 times in a row. designer just gets confused sometimes.
edit
from the trace, it looks like your . java file might not be compiled to a .class file properly. when the registry is trying to parse the class file it is getting an unexpected EOF.
try making a small change to the Java file to trigger another build (add a comment or white space)
make sure there are no compilation errors

Troubleshooting java.lang.IllegalStateException: Context is already active

In a JSF 2.1 Project I am using Primefaces 5.2.
It is deployed on a Glasfish 3.1.2.2
Problem:
I´ve got the problem, that I am getting a
java.lang.IllegalStateException: Context is already active
sometimes, when I am doing a refresh page or a page redirect.
I do know, that sometimes is not a very good definition of software behaviour, but i can not really reproduce the error, it seems to appear random, to me.
Question:
Hence, I have not really found too much on the web about the cause of that kind of Exception im wondering what circumstances can produce it?
Full Trace:
[#|2015-11-10T12:51:30.246+0100|WARNING|oracle-glassfish3.1.2|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=141;_ThreadName=Thread-8;|StandardWrapperValve[Faces Servlet]: PWC1406: Servlet.service() for servlet Faces Servlet threw exception
java.lang.IllegalStateException: Context is already active
at org.jboss.weld.context.AbstractConversationContext.activate(AbstractConversationContext.java:227)
at org.jboss.weld.jsf.WeldPhaseListener.activateConversations(WeldPhaseListener.java:108)
at org.jboss.weld.jsf.WeldPhaseListener.beforePhase(WeldPhaseListener.java:85)
at com.sun.faces.lifecycle.Phase.handleBeforePhase(Phase.java:228)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:99)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:100)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
at org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
at org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:161)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Thread.java:745)
|#]
Solving the concrete problem you're facing is difficult based on the limited information available, but I believe I can answer your actual stated question.
The exception you're getting is triggered when your application attempts to activate a context before deactivating the previously activated one. Based on your stacktrace it seems you are activating a new conversation before the previous one. Depending on your implementation it could simply be a timing issue but it's difficult to say for sure without reviewing the codebase.
To clarify why activating a second context is a problem, it's against the CDI spec. You can have zero or one active contexts per scope per thread, any more and you end up with ambiguity between contextual instances.
As a non-technical analogue, a scope is a shelf with boxes (contexts) on it. You can only have box open (active) at any time, otherwise your little brother (CDI container / Weld) won't know which box you meant when you said to get the action figure (contextual instance) from the open box on the top shelf (Or #Inject MyBeanInterface bean; where the bean has an assigned scope).

java.io.NotSerializableException: org.omnifaces.taghandler.ImportConstants$ConstantsMap, when using OmniFaces o:importConstants

We use,
JSF 2.1
RichFaces 4
OmniFaces 1.5.
We are getting the following exception:
java.io.NotSerializableException: org.omnifaces.taghandler.ImportConstants$ConstantsMap
This when using <o:importConstants> and javax.faces.STATE_SAVING_METHOD as client.
Has anyone seen this before? What would be the fix?
Thanks for any assistance in resolving this issue.
The fix is simple, just let org.omnifaces.util.MapWrapper implement Serializable as well. I've committed it and it's available in today's latest 1.8 snapshot. However, the cause is just weird. I didn't expect it to be saved into JSF state as it's an EL expression. So I looked a bit further, just to learn.
For sake of completeness, here's the stacktrace I encountered with Mojarra 2.1.28 on Tomcat 7.0.47 with client side state saving and a <f:event> whereby a constant is being passed as method argument like so:
<o:importConstants type="com.example.Constants" />
<f:event type="preRenderView" listener="#{bean.method(Constants.SOME)}" />
The exception already occurs when just opening the page, no postback was necessary.
java.io.NotSerializableException: org.omnifaces.taghandler.ImportConstants$ConstantsMap
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1181)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at org.apache.el.ValueExpressionLiteral.writeExternal(ValueExpressionLiteral.java:109)
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1456)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1427)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at java.util.HashMap.writeObject(HashMap.java:1100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at org.apache.el.lang.VariableMapperImpl.writeExternal(VariableMapperImpl.java:59)
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1456)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1427)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at org.apache.el.MethodExpressionImpl.writeExternal(MethodExpressionImpl.java:308)
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1456)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1427)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at com.sun.faces.facelets.el.TagMethodExpression.writeExternal(TagMethodExpression.java:152)
at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1456)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1427)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1541)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1506)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1541)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1506)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1171)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1171)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1541)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1506)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at java.util.ArrayList.writeObject(ArrayList.java:710)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1171)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1171)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1171)
at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1375)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1171)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at java.util.HashMap.writeObject(HashMap.java:1100)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:988)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1429)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1175)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:347)
at com.sun.faces.renderkit.ClientSideStateHelper.doWriteState(ClientSideStateHelper.java:424)
at com.sun.faces.renderkit.ClientSideStateHelper.writeState(ClientSideStateHelper.java:210)
at com.sun.faces.renderkit.ResponseStateManagerImpl.writeState(ResponseStateManagerImpl.java:122)
at com.sun.faces.application.StateManagerImpl.writeState(StateManagerImpl.java:113)
at com.sun.faces.application.view.WriteBehindStateWriter.flushToWriter(WriteBehindStateWriter.java:225)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:464)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:125)
at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:286)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:594)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)
And riiight .. The ValueExpressionLiteral comes into the picture. Enum values are resolved as EL literals. The ValueExpressionLiteral will serialize the literal value (the evaluated value itself) for state saving instead of the concrete expression #{Constants.SOME}. This makes after all sense, enums are constants anyway.

java.lang.ClassCastException: javax.faces.component.StateHolderSaver cannot be cast to [Ljava.lang.Object;

I am displaying a list of items with links in my xhtml page. When I click my "back to previous page" button from that link, I basically reset the flags in my bean to indicate to the xhtml which page to display, and reload the list of links from my database.
When I click the same link (or any other link for that matter) in this new page, I get this error:
javax.portlet.faces.BridgeException: javax.portlet.faces.BridgeException: javax.faces.FacesException:
Unexpected error restoring state for component with id A8351:j_idt7:j_idt10:j_idt59.
Cause: java.lang.ClassCastException: javax.faces.component.StateHolderSaver cannot be cast to [Ljava.lang.Object;.
at com.liferay.faces.bridge.BridgePhaseActionImpl.execute(BridgePhaseActionImpl.java:105)
at com.liferay.faces.bridge.BridgeImpl.doFacesRequest(BridgeImpl.java:81)
at javax.portlet.faces.GenericFacesPortlet.processAction(GenericFacesPortlet.java:152)
at com.ncs.portalcity.lfe.faces.bridge.FacesPortlet.processAction(FacesPortlet.java:47)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:70)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
...
...
Caused by: javax.faces.FacesException: Unexpected error restoring state for component
with id A8351:j_idt7:j_idt10:j_idt59. Cause: java.lang.ClassCastException: javax.faces.component.StateHolderSaver cannot be cast to [Ljava.lang.Object;.
at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:284)
at com.sun.faces.component.visit.FullVisitContext.invokeVisitCallback(FullVisitContext.java:151)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1589)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIForm.visitTree(UIForm.java:344)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at javax.faces.component.UIComponent.visitTree(UIComponent.java:1600)
at com.sun.faces.application.view.StateManagementStrategyImpl.restoreView(StateManagementStrategyImpl.java:263)
at com.sun.faces.application.StateManagerImpl.restoreView(StateManagerImpl.java:188)
at com.sun.faces.application.view.ViewHandlingStrategy.restoreView(ViewHandlingStrategy.java:123)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:452)
at com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:148)
at javax.faces.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:303)
at com.liferay.faces.bridge.application.ViewHandlerImpl.restoreView(ViewHandlerImpl.java:88)
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:192)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at com.liferay.faces.bridge.lifecycle.LifecycleWrapper.execute(LifecycleWrapper.java:35)
at com.liferay.faces.bridge.BridgePhaseActionImpl.execute(BridgePhaseActionImpl.java:77)
... 142 more
Caused by: java.lang.ClassCastException: javax.faces.component.StateHolderSaver cannot be cast to [Ljava.lang.Object;
at javax.faces.component.behavior.AjaxBehavior.restoreState(AjaxBehavior.java:459)
at javax.faces.component.UIComponentBase.restoreBehaviors(UIComponentBase.java:2184)
at javax.faces.component.UIComponentBase.restoreBehaviorsState(UIComponentBase.java:2151)
at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1571)
at com.sun.faces.application.view.StateManagementStrategyImpl$2.visit(StateManagementStrategyImpl.java:276)
... 162 more
If I refresh the page and try again, there are no issues. Does anyone have any idea what I'm doing wrong?
---- Edit ----
Just in case anyone else using liferay has this problem, I just added these lines in my pom.xml and it's ok now :) Thanks so much BaluC!
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.21</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.21</version>
<scope>compile</scope>
</dependency>
This is a known Mojarra issue and already reported as issue 2041 which is fixed in Mojarra 2.1.12.
So, just upgrading your JSF libraries to at least Mojarra 2.1.12 should do. It's currently already at 2.1.26, with many more fixes related to state management and likes as compared to 2.1.12.

Resources