Richtext field causing DominoDocument.setValue() error - xpages

Recently while using richtext field and ckeditor I started receiving following error while trying to run any kind of action that submits richtext value:
com.ibm.xsp.FacesExceptionEx: Notes exception thrown while calling DominoDocument.setValue() on field rt
at com.ibm.xsp.model.domino.wrapped.DominoDocument.setValue(DominoDocument.java:1465)
at com.ibm.xsp.el.PropertyResolverImpl.setValue(PropertyResolverImpl.java:206)
at com.sun.faces.el.impl.ArraySuffix.setValue(ArraySuffix.java:201)
at com.sun.faces.el.impl.ComplexValue.setValue(ComplexValue.java:180)
at com.sun.faces.el.ValueBindingImpl.setValue(ValueBindingImpl.java:206)
at com.ibm.xsp.component.UIInputEx.updateModel(UIInputEx.java:573)
at javax.faces.component.UIInput.processUpdates(UIInput.java:484)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at com.ibm.xsp.component.UIDataPanelBase.processUpdates(UIDataPanelBase.java:351)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at com.ibm.xsp.component.UIDataPanelBase.processUpdates(UIDataPanelBase.java:351)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at com.ibm.xsp.component.UIDataPanelBase.processUpdates(UIDataPanelBase.java:351)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at com.ibm.xsp.component.UIDataPanelBase.processUpdates(UIDataPanelBase.java:351)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at com.ibm.xsp.component.UIDataPanelBase.processUpdates(UIDataPanelBase.java:351)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at com.ibm.xsp.component.UIDataPanelBase.processUpdates(UIDataPanelBase.java:351)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at com.ibm.xsp.component.UIDataPanelBase.processUpdates(UIDataPanelBase.java:351)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIForm.processUpdates(UIForm.java:222)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1244)
at javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:406)
at com.ibm.xsp.component.UIViewRootEx._processUpdates(UIViewRootEx.java:1513)
at com.ibm.xsp.component.UIViewRootEx.processUpdates(UIViewRootEx.java:1492)
at com.sun.faces.lifecycle.UpdateModelValuesPhase.execute(UpdateModelValuesPhase.java:98)
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:250)
at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:223)
at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:200)
at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
at com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:137)
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:1267)
at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)
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:1251)
at com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:598)
at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:421)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
Caused by: NotesException: Note item not found
at lotus.domino.local.Document.closeMIMEEntities(Unknown Source)
at com.ibm.xsp.model.domino.wrapped.DominoRichTextItem.closeMIMEEntities(DominoRichTextItem.java:2531)
at com.ibm.xsp.model.domino.wrapped.DominoDocument.getRichTextField(DominoDocument.java:1979)
at com.ibm.xsp.model.domino.wrapped.DominoDocument.createRTFieldWithValue(DominoDocument.java:1998)
at com.ibm.xsp.model.domino.wrapped.DominoDocument.setValue(DominoDocument.java:1382)
... 60 more
Anybody know what could possibly cause this kind of behaviour? I've got quite complex design with excesive use of extension library and this error appeared out of nowhere at some point. I cannot pin point what caused it because it was partially obscured by my logging code which unnecessarly called DominoDocument.getDocument(true).
After removing this call this error started to appear. Adding arbitral call DominoDocument.getDocument(true) to random 'rendered' attribute ssjs code seems to partially solve this problem (this is where the logging code was in the first place).
But still this is hack and I would like to know what went wrong in the begining.
This seems to be somehow connected to state of FieldValueHolder of DominoRichTextItem (its operation fields is set to REPLACE instead to ADD !?)
Can anybody help ?

I have found the root of the problem. I appears that if You remove formName attribute from document data source the side effect is this exception and disappearing attachments.
This regression was introducted to my application while adding some document response functionality (the form was computed in events so somebody threw away formName attribute). And what is worse the problem with attachments was obscured by some getDocument(true) call in debug code.
It would be nice if xsp compiler mentioned that formName is obligatory attribute ...

If your calling REPLACE on a document that doesn't exist you would be getting an error and given it occurs after you removed the code to check whether to rendering it or not, really sounds as though the issue is the document doesn't exist.
Have you checked this out? also the easiest way to use a rich text item is just to bind it to a field
e.g. value="#{dominoDoc.body}"
This might not always be possible but it gets over issues like this where custom code causes errors.

Related

How do I avoid "Exception handling request to" javax.servlet.ServletException when redirecting?

I have logic in my backing bean that redirects if there is a session timeout.
FacesContext.getCurrentInstance().getExternalContext().setResponseStatus(responseCode);
FacesContext.getCurrentInstance().getExternalContext().setResponseHeader("Location", redirectURL);
FacesContext.getCurrentInstance().responseComplete();
However, the page that is being loaded still attempts to render, and throws this error:
2021-11-27 08:02:50,774 ERROR [io.undertow.request] (default task-2) UT005023: Exception handling request to /dashboard/mypage.htm: javax.servlet.ServletException
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:236)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:294)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
Caused by: java.lang.NullPointerException
at javax.el.ELUtil.buildParameters(ELUtil.java:699)
at javax.el.ELUtil.invokeMethod(ELUtil.java:243)
at javax.el.BeanELResolver.invoke(BeanELResolver.java:338)
at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:198)
at com.sun.el.parser.AstValue.getValue(AstValue.java:111)
at com.sun.el.parser.AstValue.getValue(AstValue.java:179)
at com.sun.el.parser.AstDeferredExpression.getValue(AstDeferredExpression.java:39)
at com.sun.el.parser.AstCompositeExpression.getValue(AstCompositeExpression.java:44)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:202)
at org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.getValue(ContextAwareTagValueExpression.java:93)
at javax.faces.component._DeltaStateHelper.eval(_DeltaStateHelper.java:372)
at org.primefaces.component.menuitem.UIMenuItemBase.getUrl(UIMenuItemBase.java:91)
at org.primefaces.renderkit.MenuItemAwareRenderer.encodeOnClick(MenuItemAwareRenderer.java:67)
at org.primefaces.component.menu.BaseMenuRenderer.encodeMenuItem(BaseMenuRenderer.java:111)
at org.primefaces.component.menu.BaseMenuRenderer.encodeMenuItem(BaseMenuRenderer.java:69)
at org.primefaces.component.tieredmenu.TieredMenuRenderer.encodeElements(TieredMenuRenderer.java:124)
at org.primefaces.component.menubutton.MenuButtonRenderer.encodeMenu(MenuButtonRenderer.java:147)
at org.primefaces.component.menubutton.MenuButtonRenderer.encodeMarkup(MenuButtonRenderer.java:68)
at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:50)
How can I get the view to stop loading on this workflow? It's obvious that, since the redirect occurred, the backing bean hasn't loaded everything and therefore EL expressions that depend on such objects being loaded, are failing.
I don't want to generate the error because this causes my admins grief because of the error emails that get generated. They can't tell if it is a real error or not.
Looks like you should have put some value on attribute in the request and that page uses that attribute and displays the nullPointer Exception as an error try to HttpServletRequest.setAttribute("bla", bla) nad check it.

How to fetch distinct record in liferay

I tried to fetch distinct record. But didn't get success. I tried following code
DynamicQuery
dynamicQry=DynamicQueryFactoryUtil.forClass(Clipping.class);
dynamicQry.add(RestrictionsFactoryUtil.isNotNull("news"));
dynamicQry.setProjection(ProjectionFactoryUtil.distinct(ProjectionFactoryUtil.property("news")));
List press =
ClippingLocalServiceUtil.dynamicQuery(dynamicQry);
I got following error
java.lang.ClassCastException: java.lang.String cannot be cast to com.dbservice.model.Clipping
at org.apache.jsp.html.pressClipingReport.view_jsp._jspService(view_jsp.java:924)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
What is the solution?
please help
Thanks in advance

How to localize JSF composite component?

I'm having trouble localizing a composite component (Mojarra 2.2, Glassfish 4.0).
I tried BalusC's solution here to put the properties file in the same directory as the composite component with the same file name as the composite component and a .properties extension -- that works to externalize the strings from the composite component's definition.
But when I want to localize the strings (by adding _en suffix to the property file's filename) I get this error (only thing changed is the name of the properties file):
[2013-08-08T13:49:04.234-0500] [glassfish 4.0] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=24 _ThreadName=http-listener-1(5)] [timeMillis: 1375987744234] [levelValue: 900] [[
StandardWrapperValve[Faces Servlet]: Servlet.service() for servlet Faces Servlet threw exception
java.lang.NullPointerException
at javax.faces.component.UIComponent.findComponentResourceBundleLocaleMatch(UIComponent.java:1204)
at javax.faces.component.UIComponent.getResourceBundleMap(UIComponent.java:1007)
at sun.reflect.GeneratedMethodAccessor1226.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:363)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.el.parser.AstValue.getValue(AstValue.java:140)
at com.sun.el.parser.AstValue.getValue(AstValue.java:204)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
at org.jboss.weld.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
at com.sun.faces.facelets.el.ELText$ELTextVariable.writeText(ELText.java:227)
at com.sun.faces.facelets.compiler.TextInstruction.write(TextInstruction.java:85)
at com.sun.faces.facelets.compiler.UIInstructions.encodeBegin(UIInstructions.java:82)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302)
at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:115)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:894)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856)
...
I read an article (post from 24/Aug/12 03:50 PM) that JSF localizes differently than standard Java and that the properties files would go in resources/en/<library>/<component>.properties, so I put mycomp.properties there and got the error again.
My default locale is actually "en_US" -- I tried that as well with the same results.
So, this works:
resources/lib/mycomp.xhtml, resources/lib/mycomp.properties
These don't work:
resources/lib/mycomp.xhtml, resources/lib/mycomp_en.properties
resources/lib/mycomp.xhtml, resources/en/lib/mycomp.properties
What am I doing wrong?
I can reproduce your problem. This is quite embarrassing. Apparently something changed related to this in a newer Mojarra version. I can't get both the old and new approach to work in 2.2.0.
I peeked in the Mojarra source code again, starting at UIComponent#getResourceBundleMap(), and I learned that the resource bundle is first searched based on the FQN of the component's class. We could easily make use of it.
If not already done, first create a backing component class:
package com.example.composite;
#FacesComponent("myComposite")
public class MyComposite extends UINamingContainer {
// Can be kept empty.
}
And declare it in the composite component definition:
<cc:interface componentType="myComposite">
Then, you can simply put the MyComposite.properties, MyComposite_en.properties, etc in the very same com.example.composite package. It worked for me.

RedirectSignal error upon redirection via Java

I have designed the following method and using that within managed beans:
public static void redirectToPrevious() {
FacesContext context = FacesContext.getCurrentInstance();
XSPContext xContext=XSPContext.getXSPContext(context);
xContext.redirectToPrevious();
}
It works as expected. It redirects to the previous page (or home page if there is not any).
However, everytime it works, it throws RedirectSignal error:
com.ibm.xsp.FacesExceptionEx: javax.faces.el.EvaluationException: com.ibm.xsp.acl.RedirectSignal
at com.ibm.xsp.util.DataPublisher.publishControlData(DataPublisher.java:204)
at com.ibm.xsp.component.UIDataPanelBase.publishControlData(UIDataPanelBase.java:310)
at com.ibm.xsp.component.UIDataPanelBase.initBeforeContents(UIDataPanelBase.java:451)
at com.ibm.xsp.component.UIIncludeComposite.initBeforePageContents(UIIncludeComposite.java:668)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:339)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.addComponent(AbstractCompiledPage.java:389)
at com.ibm.xsp.component.UIIncludeComposite.buildContents(UIIncludeComposite.java:453)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildFacet(CompiledComponentBuilder.java:205)
at com.ibm.xsp.component.UICallback.buildContents(UICallback.java:180)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:123)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
at com.ibm.xsp.extlib.component.layout.UIVarPublisherBase.buildContents(UIVarPublisherBase.java:97)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:123)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
at com.ibm.xsp.component.UIIncludeComposite.buildPageContents(UIIncludeComposite.java:692)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:340)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.addComponent(AbstractCompiledPage.java:389)
at com.ibm.xsp.component.UIIncludeComposite.buildContents(UIIncludeComposite.java:453)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildChildren(CompiledComponentBuilder.java:123)
at com.ibm.xsp.page.compiled.CompiledComponentBuilder.buildAll(CompiledComponentBuilder.java:84)
at com.ibm.xsp.component.UIViewRootEx.buildContents(UIViewRootEx.java:1649)
at com.ibm.xsp.component.UIViewRootEx2.buildContents(UIViewRootEx2.java:247)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.initComponent(AbstractCompiledPage.java:334)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createTree(AbstractCompiledPage.java:256)
at com.ibm.xsp.page.compiled.AbstractCompiledPage.createViewRoot(AbstractCompiledPage.java:167)
at com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(ViewHandlerExImpl.java:521)
at com.ibm.xsp.application.ViewHandlerExImpl.createViewRoot(ViewHandlerExImpl.java:567)
at com.ibm.xsp.application.ViewHandlerExImpl.doCreateView(ViewHandlerExImpl.java:142)
at com.ibm.xsp.application.ViewHandlerEx.createView(ViewHandlerEx.java:90)
at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:251)
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:1315)
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:1299)
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:350)
at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:306)
at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
Caused by: javax.faces.el.EvaluationException: com.ibm.xsp.acl.RedirectSignal
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:142)
at com.ibm.xsp.actions.ExecuteScriptAction.invoke(ExecuteScriptAction.java:78)
at com.ibm.xsp.actions.ActionGroup.invoke(ActionGroup.java:135)
at com.ibm.xsp.model.AbstractDocumentDataSource.invoke(AbstractDocumentDataSource.java:299)
at com.ibm.xsp.model.AbstractDocumentDataSource.newDocument(AbstractDocumentDataSource.java:126)
at com.ibm.xsp.model.AbstractDocumentDataSource.load(AbstractDocumentDataSource.java:97)
at com.ibm.xsp.model.AbstractDataSource.getDataContainer(AbstractDataSource.java:474)
at com.ibm.xsp.model.domino.DominoDocumentData.getDataObject(DominoDocumentData.java:145)
at com.ibm.xsp.model.AbstractDataSource.pushData(AbstractDataSource.java:576)
at com.ibm.xsp.util.DataPublisher.publishControlData(DataPublisher.java:181)
... 50 more
Caused by: com.ibm.xsp.acl.RedirectSignal
at com.ibm.xsp.designer.context.XSPContext.renderPage(XSPContext.java:194)
at com.ibm.xsp.designer.context.XSPContext.redirectToPage(XSPContext.java:917)
at com.ibm.xsp.designer.context.XSPContext.redirectToPage(XSPContext.java:929)
at com.ibm.xsp.designer.context.XSPContext.redirectToPrevious(XSPContext.java:939)
at com.developi.toolbox.BeanUtils.redirectToPrevious(BeanUtils.java:57)
at com.hillside.flowng.beans.JobManager.postNewJob(JobManager.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:138)
... 59 more
I can use try-catch and ignore the error but I'm not sure why this is happenning inside a managed bean but not in SSJS.
Any idea?
The RedirectSignal is not a java.lang.Exception, it is a java.lang.Error. That's why it is not catched with a default try/catch block. There are some other signals f.e. the NoAccessSignal or the ResponseCompleteSignal which are handled internally to stop processing requests and/or code execution, but are not "real" errors for the XPages servlet.
When redirecting to another page, the RedirectSignal is required to stop processing "useless" code and is catched in SSJS Interpreter. A button with this code...
print("BEFORE!");
context.redirectToPrevious();
print("AFTER");
will just send the BEFORE! to the console, the rest of the SSJS will not be executed.
You have to handle the RedirectSignal by your own (in the method of your bean) to prevent the printing to the console / the log.
XSPContext.getXSPContext(FacesContext) just uses the variable resolver to resolve the context variable, so this method should return a handle on the same object that context evaluates to within SSJS. So I'm not sure why you would see different behavior in different languages.
However, a RedirectSignal is only shown when recursion has been detected during a redirect. If I'm interpreting your stack trace correctly, refreshMode is set to partial on your event. All redirects must be performed from within a full refresh event.

Can't get Apache POI to work in SSJS

I'm trying to import an excel sheet of any kind (xls/xslx) into my database via an Xpage and the following code returns with an error:
importPackage(org.apache.poi.ss.usermodel);
var tempFile:java.io.File = fileData.getServerFile();
var wb:WorkBook = WorkbookFactory.create(tempFile);
var sheet:Sheet = wb.getSheetAt(0);
var rows = sheet.getPhysicalNumberOfRows();
"WorkbookFactory not found"
I have put the API in buld path: /tradesec(9).nsf/WebContent/WEB-INF/lib/poi-3.9-20121203.jar
I have tried this without the importPackage but without luck. 'org' not found
Please advice!
/M
update:
I have now copied all jars from POI to jvm/lib/ext, added a grant for everything in java.policy, created a java class as a bean.
Still getting exceptions:
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
java.lang.reflect.Constructor.newInstance(Constructor.java:527)
com.ibm.jscript.types.JavaAccessObject.construct(JavaAccessObject.java:260)
com.ibm.jscript.types.JavaWrapperObject.construct(JavaWrapperObject.java:1)
com.ibm.jscript.ASTTree.ASTNew.interpret(ASTNew.java:109)
com.ibm.jscript.ASTTree.ASTMember.interpret(ASTMember.java:106)
com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:88)
com.ibm.jscript.ASTTree.ASTVariableDecl.interpret(ASTVariableDecl.java:82)
com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
com.ibm.jscript.ASTTree.ASTTry.interpret(ASTTry.java:109)
com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
com.ibm.jscript.ASTTree.ASTTry.interpret(ASTTry.java:109)
com.ibm.jscript.ASTTree.ASTIf.interpret(ASTIf.java:85)
com.ibm.jscript.ASTTree.ASTBlock.interpret(ASTBlock.java:100)
com.ibm.jscript.ASTTree.ASTTry.interpret(ASTTry.java:109)
com.ibm.jscript.ASTTree.ASTProgram.interpret(ASTProgram.java:119)
com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:139)
com.ibm.jscript.JSExpression._interpretExpression(JSExpression.java:435)
com.ibm.jscript.JSExpression.access$1(JSExpression.java:424)
com.ibm.jscript.JSExpression$2.run(JSExpression.java:414)
java.security.AccessController.doPrivileged(AccessController.java:310)
com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:410)
com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:251)
com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:221)
com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:111)
com.ibm.xsp.actions.ActionGroup.invoke(ActionGroup.java:135)
com.ibm.xsp.component.UIViewRootEx.invokePhaseMethodBinding(UIViewRootEx.java:1735)
com.ibm.xsp.controller.FacesControllerImpl.invokePhaseMethodBinding(FacesControllerImpl.java:444)
com.ibm.xsp.controller.FacesControllerImpl.access$0(FacesControllerImpl.java:438)
com.ibm.xsp.controller.FacesControllerImpl$ViewPhaseListener.beforePhase(FacesControllerImpl.java:527)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:197)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:120)
com.ibm.xsp.controller.FacesControllerImpl.render(FacesControllerImpl.java:264)
com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:248)
com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:204)
com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:583)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1281)
com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:860)
com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:803)
com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:572)
com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1265)
com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:658)
com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:481)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
My knowledge in this section is quite limited I must say.
Currently I'm considering moving away from this and start implementing a plain old text file instead. Too much overhead and dependencies for my tight project schedule to handle, I'm afraid.
If someone out there finds a solution I'm happy to explore it
Make sure that You added poi-ooxml-3.9-20121203.jar to the build path also. The poi-3.9-20121203.jar jar does not contain WorkbookFactory class.
There are class loader related problems with dom4j (used by the POI XLSX parser) when loading from the Domino database. Try adding the needed jars to the filesystem in the jvm/lib/ext directory (both Domino and Notes) and opening up the java.security a bit (see http://www.wissel.net/blog/d6plinks/SHWL-8JYAT5).
I'm having success with the unrestricted grant { permission java.security.AllPermission; };. It would be better to be a bit more restricted, but I have not yet found the time to investigate the issue any further.
You can also try loading the jars by loading the POI 4 XPages OSGi library: http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=POI%204%20XPages
Try adding the full path to the WorkbookFactory that is what I have done before when referencing classes within jars.

Resources