XPages Console Error: Unable to get document page name for - xpages

Referring to Question:
Unable to get document page name for
I have tried the solution given by Sven, but we still getting same error.
Applications are access via browsers only.
12/14/15 2:30 PM: Exception Thrown
Context Path: /db/common/itrs.nsf
com.ibm.xsp.FacesExceptionEx: Unable to get document page name for C8AF761CF554445D48257CC90007D9AD
at com.ibm.xsp.model.domino.DominoDocumentPageTransformer.transformPageName(DominoDocumentPageTransformer.java:69)
at com.ibm.xsp.application.ViewHandlerExImpl.convertVirtualPage(ViewHandlerExImpl.java:690)
at com.ibm.xsp.application.ViewHandlerExImpl._createViewRoot(ViewHandlerExImpl.java:490)
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: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)
Caused by: com.ibm.xsp.FacesExceptionEx: Error while computing document form
at com.ibm.xsp.model.domino.DominoUtils.getXPagesForDocument(DominoUtils.java:603)
at com.ibm.xsp.model.domino.DominoDocumentPageTransformer.transformPageName(DominoDocumentPageTransformer.java:53)
... 21 more
Caused by: com.ibm.designer.domino.napi.NotesAPIException: Error finding special ID, Database=700 Special database object cannot be located
at com.ibm.designer.domino.napi.NotesDatabase.NGetSpecialNoteID(Native Method)
at com.ibm.designer.domino.napi.NotesDatabase.getSpecialNoteID(NotesDatabase.java:600)
at com.ibm.xsp.model.domino.DominoUtils.getXPagesForDocument(DominoUtils.java:540)
... 22 more
Thank you in anticipation.

The DominoDocumentPageTransformer doesn't fetch some errors, e.g. if the document does not exist or is not readable for the current user. Because the transformation happens during the page convertion (the XPages engine tries to interpret the URL and seeks for the XPage to open), you receive an error.
As far as I know you can overwrite the existing PageTransformer and catch the error for yourself.
package ch.hasselba.factory;
import com.ibm.xsp.model.domino.DominoDocumentPageTransformer;
import com.ibm.xsp.page.VirtualPageTransformer;
import javax.faces.context.FacesContext;
public class PageTransformer implements VirtualPageTransformer {
public boolean isVirtualPage(FacesContext fc, String pageName) {
return "/$$OpenDominoDocument.xsp".equals(pageName);
}
public String transformPageName(FacesContext fc, String pageName) {
String xspPage = "/ErrorPage.xsp";
try {
DominoDocumentPageTransformer transformer = new DominoDocumentPageTransformer();
xspPage = transformer.transformPageName(fc, pageName);
} catch (Exception e) {}
return xspPage;
}
}
This opens the XPages ErrorPage.xsp when the transformation fails.
To activate the Transformer, you have to create the file
/WEB_INF/com.ibm.xsp.factories.properties
and add the line
PageTransformer=ch.hasselba.factory.PageTransformer
see here: http://hasselba.ch/blog/?p=1028

I know that you've probably solved the problem you had by now! But I've had the same issue and was hunting around trying to find the solution, so wanted to add my findings to this thread.
The reason I saw this error was because users were trying to open a document from a doc link within an email and there was no default form specified in that database.

Related

Extend StagedModelDataHandler for Journal Article in Staging

I am working on local live staging in Liferay 7.1, in which I have one custom field in Web content. When I export those web content to local live, I want to check that custom field as result I would be export that web content.
So for that, I am extending doExportStagedModel in BaseStagedModelDataHandler as below.
#Component(immediate = true,service = {StagedModelDataHandler.class})
public class Demo extends BaseStagedModelDataHandler<JournalArticle> {
// All the stuff
#Override
protected void doExportStagedModel(
PortletDataContext portletDataContext, JournalArticle article)
throws Exception {
// overridden stuff
}
// Other stuff
}
When I am deploying this, I got below exception.
2018-11-20 04:04:12.669 ERROR The setJournalCreationStrategy method
has thrown an exception java.lang.IllegalArgumentException: argument
type mismatch
2018-11-20 04:04:12.850 ERROR The
setJournalFeedExportImportContentProcessor method has thrown an
exception java.lang.IllegalArgumentException: argument type mismatch
Does anybody having idea how can I do this proper way on this?

MVCResourceCommand to send binary data inside native journal portlet

I would like to send a binary file via an appended MVCResourceCommand I coded for the native journal portlet. But the program is unable to use the OutputStream provided by the resource request.
IOUtils.copy( input, response.getPortletOutputStream() );
Considering:
The code works perfectly on StrutsActions
In custom portlets, it also works
In StrutsActions:
IOUtils.copy( input, response.getOutputStream() );
However, the code throws an IllegalStateException, saying that the writer is being used when I call response.getOutputStream().
I know we can not mix these two
The code is not attempting to do so
I wonder if Liferay is doing something with that request before it reaches my extension of BaseMVCResourceCommand, this is specifically for that native portlet.
I checked the preview feature for a webcontect item, but its URL is for the view mode.
The URL is created from a portlet:resourceURL tag inserted through a JSP fragment and the command is in its own OSGi module.
For sure, the URL is correct and the command logs that it was hit, but the exception is thrown afterwards.
The portlet I am trying to change is the:
"com_liferay_journal_web_portlet_JournalPortlet"
Any thoughts?
PS: I know about the Servlet and Portlet ResponseUtils. but they also eventually try getting the stream, leadin to the same exception.
#Component( immediate = true,
property = {
"javax.portlet.name=" + JOURNAL, "mvc.command.name=/command"
},
service = MVCResourceCommand.class )
public class Resource extends BaseMVCResourceCommand {
#Override
public void doServeResource( ResourceRequest request, ResourceResponse response ) throws PortletException {
try {
response.getPortletOutputStream();
}
catch ( Exception e ) {
throw new PortletException( e );
}
}
}
Caused by: java.lang.IllegalStateException: Unable to obtain OutputStream because Writer is already in use
at com.liferay.portlet.MimeResponseImpl.getPortletOutputStream(MimeResponseImpl.java:75)
Update:
It seems this is the source of my issues (PortletURLImpl), still looking for a solution though:
if (lifecycle.equals(PortletRequest.RESOURCE_PHASE)) {
_copyCurrentRenderParameters = true;
}
When the URL is created it comes with all sources of garbage from the render phase. Including an MVCPath

Groovy: WSClient throwing JAXBException

I am trying to call a simple public Web Service with WSClient in a Groovy script, but it explodes when initializing ...
TestService.groovy:
#Grab(group='org.codehaus.groovy.modules', module='groovyws', version='0.5.2')
import groovyx.net.ws.WSClient
def proxy = new WSClient("http://www.w3schools.com/webservices/tempconvert.asmx?WSDL", this.class.classLoader)
proxy.initialize();
def result = proxy.CelsiusToFahrenheit(0)
println "You are probably freezing at ${result} degrees Farhenheit"
The error message:
SEVERE: Could not compile java files for http://www.w3schools.com/webservices/tempconvert.asmx?WSDL.
Caught: java.lang.IllegalStateException: Unable to create JAXBContext for generated packages: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "org.tempuri" doesnt contain ObjectFactory.class or jaxb.index
java.lang.IllegalStateException: Unable to create JAXBContext for generated pack
ages: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: jav
ax.xml.bind.JAXBException: "org.tempuri" doesnt contain ObjectFactory.class or j
axb.index
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:343)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:196)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:175)
at groovyx.net.ws.AbstractCXFWSClient.createClient(AbstractCXFWSClient.java:229)
at groovyx.net.ws.WSClient.initialize(WSClient.java:108)
at groovyx.net.ws.IWSClient$initialize.call(Unknown Source)
at TestService.run(TestService.groovy:5)
Caused by: javax.xml.bind.JAXBException: Provider com.sun.xml.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "org.tempuri" doesnt contain ObjectFactory.class or jaxb.index - with linked exception:
[javax.xml.bind.JAXBException: "org.tempuri" doesnt contain ObjectFactory.classor jaxb.index]
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:340)
... 6 more
Caused by: javax.xml.bind.JAXBException: "org.tempuri" doesnt contain ObjectFactory.class or jaxb.index
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:197)
... 7 more
Any hint? Why should I have a jaxb.index?
Just discovered that the problem occurs with Java 1.7 (jdk1.7.0_21)... it's OK when running with Java 6 (jdk1.6.0_31)
Any hint to work with Java 7?
As noted on the GroovyWS page, GroovyWS is currently dormant. You could do the same thing (albeit with a wordier syntax) using the groovy-wslite library:
#Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='0.8.0')
import wslite.soap.*
def client = new SOAPClient('http://www.w3schools.com/webservices/tempconvert.asmx')
def response = client.send(SOAPAction:'http://tempuri.org/CelsiusToFahrenheit') {
body {
CelsiusToFahrenheit('xmlns':'http://tempuri.org/') {
Celsius('0')
}
}
}
def result = response.CelsiusToFahrenheitResponse.CelsiusToFahrenheitResult.text()
println "You are probably freezing at ${result} degrees Farhenheit"
Note that this requires you to look at the WSDL to get the SOAP message namespace, unlike the GroovyWS version of the code. But it works!

JSF sendRedirect() java.lang.IllegalStateException: Committed

I am creating a web page that get an id from a previous page using getSessionMap() in FacesUtils. If the page did not get the id, it should be redirected to other page, in this case draft.jsf. Here is the code:
if ((FacesUtils.getSessionMap().get("id") == null)) {
try {
FacesUtils.getResponse().sendRedirect("draft.jsf");
return;
} catch (Exception e) {
e.printStackTrace();
}
} else {
id = Long.valueOf(String.valueOf(FacesUtils.getSessionMap().get("id")));
}
But I always get java.lang.IllegalStateException: Committed when the id was null, and the page was not redirected to draft.jsf. What is wrong with my code? Any help would be really appreciated.
Here is the stacktrace:
java.lang.IllegalStateException: Committed
at org.mortbay.jetty.Response.resetBuffer(Response.java:1023)
at org.mortbay.jetty.Response.sendRedirect(Response.java:428)
at org.jleaf.erp.inv.controller.EditAssemblyController.init(EditAssemblyController.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:340)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:293)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:130)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:393)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1415)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:518)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
at org.springframework.beans.factory.support.AbstractBeanFactory$2.getObject(AbstractBeanFactory.java:331)
at org.jlego.web.jsf.ViewScope.get(ViewScope.java:20)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:327)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
at org.jlego.baseweb.PieceletELResolver.getValue(PieceletELResolver.java:65)
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.AstIdentifier.getValue(AstIdentifier.java:99)
at com.sun.el.parser.AstValue.getValue(AstValue.java:158)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:219)
at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:109)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:194)
at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:182)
at javax.faces.component.UIOutput.getValue(UIOutput.java:169)
at org.primefaces.util.ComponentUtils.getValueToRender(ComponentUtils.java:69)
at org.primefaces.component.inputtext.InputTextRenderer.encodeMarkup(InputTextRenderer.java:79)
at org.primefaces.component.inputtext.InputTextRenderer.encodeEnd(InputTextRenderer.java:50)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:312)
at com.sun.faces.renderkit.html_basic.GridRenderer.renderRow(GridRenderer.java:185)
at com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:129)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:55)
at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:43)
at org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:191)
at org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:114)
at org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:55)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:875)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1764)
at javax.faces.render.Renderer.encodeChildren(Renderer.java:168)
at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1757)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1760)
at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:401)
at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:131)
at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:121)
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.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1221)
at org.jlego.web.WebLoginSessionFilter.doFilter(WebLoginSessionFilter.java:95)
at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1212)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:399)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:450)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:928)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:549)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
It's likely because you're redirecting by plain servlet HttpServletResponse#sendRedirect() instead of JSF own ExternalContext#redirect() which is implicitly performing a FacesContext#responseComplete() call afterwards which instructs JSF to not perform the render response which would fill the HTTP response with the output of the target view.
E.g.
public void someMethod() throws IOException {
ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
Long id = (Long) ec.getSessionMap().get("id");
if (id == null) {
ec.redirect("draft.jsf");
return;
}
// ... ?
}
(note that I simplified some clumsiness (massaging long<-->string) and carelessness (swallowing exception) in your code as well; using #ManagedProperty("#{id}") to inject the property is after all probably yet easier)
Whenever you import something from javax.servlet inside a JSF artifact, you should stop developing and look around in ExternalContext class and think twice if you're really doing things the right way. Further, JSF utility library OmniFaces has a handy Faces utility class, removing the need to reinvent the FacesUtils wheel.
Update: Given the stack trace, another probable cause is that you're attempting to send a redirect in midst of rendering the response. It's not possible to take the already sent bytes of the rendered response back from the client in order to change the response. You should be performing the redirect job before the first byte of the response is ever sent to the client. E.g. in a pre render view listener method instead of bean's (post)constructor or even getter method.
<f:event type="preRenderView" listener="#{bean.someMethod}" />
I ran into this problem before where somewhere else in my code there was a redirect being sent within the same request.
Double check that you don't have any filters trying to do a redirect as well.

IceFaces Session Expiry causes an exception

My IceFaces application crashes on session expiry. It's not showing the "User Session Expired" or "Network Connection Interrupted" message.
My guess is the same page is loaded again, and since the backing bean code cannot find the session variables, it throws the following exception:
exception
javax.servlet.ServletException: java.lang.Exception: javax.faces.FacesException: Problem in renderResponse: /main-template.jspx: User session has expired or it was invalidated.
root cause
java.lang.Exception: javax.faces.FacesException: Problem in renderResponse: /main-template.jspx: User session has expired or it was invalidated.
root cause
javax.faces.FacesException: Problem in renderResponse: /main-template.jspx: User session has expired or it was invalidated.
root cause
javax.el.ELException: /main-template.jspx: User session has expired or it was invalidated.
root cause
com.icesoft.faces.webapp.http.core.SessionExpiredException: User session has expired or it was invalidated.
root cause
java.lang.IllegalStateException: PWC2778: getAttribute: Session already invalidated
Asynchronous updates are on, and the jsp page has the <ice:outputConnectionStatus /> component.
Any ideas on how to stop this from happening?
Note: I was doing a lot of fancy stuff, like redirecting on session timeout, and displaying error pages for java.lang.Throwable, but I've commented it all out - without luck. When both redirection and error-handling were switched on, on the first time the application would show the error page, then after a while redirect to "session-expiry" page.
Thanks
I had the same problem with RichFaces and this answer saved me :
jsf login times out
For a lot of turn around and stranges things I recommend to see this blog :
http://balusc.blogspot.com/
Here is the code I'm currently using :
package com.spectotechnologies.jsf.viewhandler;
import com.sun.facelets.FaceletViewHandler;
import java.io.IOException;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
/**
* Source : https://stackoverflow.com/questions/231191/jsf-login-times-out
*
* This ViewHandler is used to remove the ViewExpiredException problem at login
* after the session is expired.
*
* #author Alexandre Lavoie
*/
public class AutoRegeneratorViewHandler extends FaceletViewHandler
{
public AutoRegeneratorViewHandler(ViewHandler p_oViewHandler)
{
super(p_oViewHandler);
}
#Override
public UIViewRoot restoreView(FacesContext p_oContext, String p_sViewID)
{
UIViewRoot oViewRoot = super.restoreView(p_oContext,p_sViewID);
if(oViewRoot == null)
{
// Work around Facelet issue
initialize(p_oContext);
oViewRoot = super.createView(p_oContext,p_sViewID);
p_oContext.setViewRoot(oViewRoot);
try
{
buildView(p_oContext,oViewRoot);
}
catch(IOException e)
{
e.printStackTrace();
}
}
return oViewRoot;
}
}
You also have to put this in faces-config.xml :
<application>
<view-handler>com.spectotechnologies.jsf.viewhandler.AutoRegeneratorViewHandler</view-handler>
</application>

Resources