Problem with DynaView – Seam 2.2.0

Splash Forums PrettyFaces Users Problem with DynaView – Seam 2.2.0

This topic contains 16 replies, has 3 voices, and was last updated by  Christian Kaltepoth 9 years, 11 months ago.

Viewing 15 posts - 1 through 15 (of 17 total)
  • Author
    Posts
  • #18159

    mausbull
    Participant

    Hi,

    I’m having a problem with DynaView and Seam 2.2.0. I’ve tried different scopes on my bean and changing the order of filters in web.xml.

    Does anybody know what I’m doing wrong?

    Thanks for your help.

    /mb

    Technology:

    – JBoss 4.2.3

    – JSF 1.2

    – Prettyfaces 3.3.2

    web.xml:

    <?xml version=”1.0″ ?>

    <web-app xmlns=”http://java.sun.com/xml/ns/javaee” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”

    xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd

    version=”2.5″>

    <context-param>

    <param-name>org.richfaces.LoadStyleStrategy</param-name>

    <param-value>ALL</param-value>

    </context-param>

    <context-param>

    <param-name>org.richfaces.LoadScriptStrategy</param-name>

    <param-value>ALL</param-value>

    </context-param>

    <!– Richfaces –>

    <filter>

    <display-name>RichFaces Filter</display-name>

    <filter-name>richfaces</filter-name>

    <filter-class>org.ajax4jsf.Filter</filter-class>

    </filter>

    <filter-mapping>

    <filter-name>richfaces</filter-name>

    <servlet-name>Faces Servlet</servlet-name>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>INCLUDE</dispatcher>

    </filter-mapping>

    <!– Prettyfaces –>

    <filter>

    <filter-name>Pretty Filter</filter-name>

    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>

    </filter>

    <filter-mapping>

    <filter-name>Pretty Filter</filter-name>

    <url-pattern>/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    </filter-mapping>

    <!– Seam –>

    <listener>

    <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>

    </listener>

    <filter>

    <filter-name>Seam Filter</filter-name>

    <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>

    </filter>

    <filter-mapping>

    <filter-name>Seam Filter</filter-name>

    <url-pattern>/*</url-pattern>

    </filter-mapping>

    <servlet>

    <servlet-name>Seam Resource Servlet</servlet-name>

    <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>

    </servlet>

    <servlet-mapping>

    <servlet-name>Seam Resource Servlet</servlet-name>

    <url-pattern>/seam/resource/*</url-pattern>

    </servlet-mapping>

    <!– Facelets development mode (disable in production) –>

    <context-param>

    <param-name>facelets.DEVELOPMENT</param-name>

    <param-value>true</param-value>

    </context-param>

    <!– JSF –>

    <context-param>

    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>

    <param-value>.xhtml</param-value>

    </context-param>

    <context-param>

    <param-name>facelets.RECREATE_VALUE_EXPRESSION_ON_BUILD_BEFORE_RESTORE</param-name>

    <param-value>false</param-value>

    </context-param>

    <servlet>

    <servlet-name>Faces Servlet</servlet-name>

    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

    <load-on-startup>1</load-on-startup>

    </servlet>

    <servlet-mapping>

    <servlet-name>Faces Servlet</servlet-name>

    <url-pattern>*.seam</url-pattern>

    </servlet-mapping>

    <security-constraint>

    <display-name>Restrict raw XHTML Documents</display-name>

    <web-resource-collection>

    <web-resource-name>XHTML</web-resource-name>

    <url-pattern>*.xhtml</url-pattern>

    </web-resource-collection>

    <auth-constraint />

    </security-constraint>

    <session-config>

    <!– HTTP Session timeout, in minutes –>

    <session-timeout>25</session-timeout>

    </session-config>

    </web-app>

    pretty-config.xml

    <pretty-config xmlns=”http://ocpsoft.com/prettyfaces/3.3.2″

    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance”

    xsi:schemaLocation=”http://ocpsoft.com/prettyfaces/3.3.2

    http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.2.xsd“>

    <url-mapping id=”reaction”>

    <pattern value=”/reaction/#{reactionId}/” />

    <view-id value=”/reaction/Reaction.seam” />

    </url-mapping>

    <url-mapping id=”kegg”>

    <pattern value=”/kegg” />

    <view-id value=”#{superbean.getViewPath}” />

    <!– <query-param name=”language”>#{superbean.language}</query-param> –>

    </url-mapping>

    </pretty-config>

    Bean:

    @name(“superbean”)

    @Scope(ScopeType.CONVERSATION)

    public class HomeBean {

    @RequestParameter(“language”)

    private String language;

    public String getViewPath() {

    System.out.println(“muh”);

    System.out.println(“language: ” + language);

    return “/faces/login.jsf”;

    }

    public String getLanguage() {

    return language;

    }

    public void setLanguage(String language) {

    this.language = language;

    }

    }

    Exception:

    14 Feb 2012 09:22:49,122 WARN [lifecycle] JSF1053: (Listener: com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(), Phase ID: RESTORE_VIEW 1, View ID: /com.ocpsoft.Dynaview.xhtml) Exception thrown during phase-listener execution: com.ocpsoft.pretty.PrettyException: Could not forward to view: #{superbean.getViewPath}

    14 Feb 2012 09:22:49,123 WARN [lifecycle] com.ocpsoft.pretty.faces.config.dynaview.DynaviewEngine.processDynaView(DynaviewEngine.java:109)

    com.ocpsoft.pretty.faces.event.PrettyPhaseListener.afterPhase(PrettyPhaseListener.java:109)

    com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)

    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:114)

    com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:104)

    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)

    javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)

    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)

    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)

    org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)

    org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)

    org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)

    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:126)

    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)

    org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)

    org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)

    org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:292)

    com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:101)

    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)

    org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)

    org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)

    org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

    org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

    org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)

    org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)

    org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)

    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)

    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

    org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)

    org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)

    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)

    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)

    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

    java.lang.Thread.run(Thread.java:619)

    #22148

    Hi, is there a root cause for this exception stack trace? If so, could you please post it. If not, when you debug, where is this failing in the code?

    Thanks,

    ~Lincoln

    #22149

    mausbull
    Participant

    Hi Lincoln,

    thanks for your quick answer.

    I copied the entire stack trace. When I debug it fails at FacesELUtils line 70

    “return me.invoke(context.getELContext(), argumentValues);”

    coming from “DynaviewEngine”

    Object viewResult = elUtils.invokeMethod(facesContext, viewId);

    I tried to get the source to “MethodExpression” but couldn’t find it. Do you know where I can get it?

    Hope you’ll be able to get a clue out of that.

    Thanks

    /mb

    #22150

    MethodExpression is part of the EL API. Your application server ships with an implementation.

    My guess is that your dynaview method throws some kind of exception. You could use a simple trick to find out what exception is thrown by wrapping the code of your dynaview method in a try catch block. Something like:

    public String getViewPath() {

    try {

    // dynaview code

    } catch(Exception e) {
    e.printStackTrace();
    return null;
    }

    }

    I know this is dirty. But if there is an exception you will see it! :)

    #22151

    mausbull
    Participant

    Hi Christian,

    well, the thing is that it never reaches the method getViewPath because it says “could not forward to view”. I guess there is something wrong with resolving the bean, but I’m pretty clueless.

    Could there be a problem with the web.xml configuration?

    Best

    /mb

    #22152

    The problem is that the exception you have posted definitely wraps the causing exception. I just don’t know why it isn’t logged in your case. I think it has something to do with Mojarra logging exceptions not completely. So your only chance is to set a break point at this point to see what is happening.

    Perhaps the scope of the bean is a problem. Could you set the scope to REQUEST for testing?

    #22153

    mausbull
    Participant

    Hi,

    I finally could debug a little more. The problem occurs at

    org.jboss.el.parser.AstValue – line 37

    private final Target getTarget(EvaluationContext ctx) throws ELException {

    // evaluate expr-a to value-a

    Object base = this.children[0].getValue(ctx);

    if (base == null) {

    throw new PropertyNotFoundException(MessageFactory.get(

    "error.unreachable.base", this.children[0].getImage()));

    }

    ctx is of type com.sun.faces.el.ELContextImpl

    base is set to null and that’s why the exception is thrown

    I tried other scopes (ScopeType.STATELESS, ScopeType.PAGE, there is no scope REQUEST) with the same result.

    Any suggestions?

    Thanks a lot

    /mb

    #22154

    It really looks like there is some weird problem while evaluating the dynaview exception (which is in fact just a standard method expression). Actually I’ve no idea what is going wrong here.

    Could you perhaps provide a minimal sample application that reproduces this? It’s hard to debug this without having access to the code. :(

    #22155

    mausbull
    Participant

    I removed most components in my project and put a compressed version online.

    It’s a seam-gen project – ant build target “explode” copies files to a jboss (specified in build.properties).

    Error occurs when calling

    http://localhost:8080/MEMOSys/kegg

    Files are available at

    memosys_minimal.zip

    Thanks for your support!

    Best

    /mb

    #22156

    Hi Mausbull,

    Thanks for uploading this. We will take a look as soon as possible. I am on vacation for a few days more, but I should be able to look next week. I’m very sorry for the wait. It’s possible that someone else may be able to look before then, but just letting you know.

    Thanks,

    Lincoln

    #22157

    Hey Mausbull,

    thanks for your upload. I’ll try to find some time in the next days to have a deeper look at this.

    Christian

    #22158

    I tried to repackaged this project into a Maven project so it can be deployed and debugged easier. I’ll attach it to the thread.

    I can reproduce this issue wit this project. But I don’t know what is causing this. It seems like the Seam components aren’t available during RESTORE_VIEW phase. But I don’t know much about Seam2 so I don’t know what to do to fix this.

    #22159

    I believe many components of Seam 2 are activated by a PhaseListener which occurs after RESTORE_VIEW. This is unfortunate because DynaView needs to occur during this phase.

    Unfortunately, I believe that it is safe to say that the DynaView feature is mostly incompatible with Seam 2, but if you find a solution, that’s great.

    #22160

    mausbull
    Participant

    Hey Christian & Lincoln,

    thanks for your work and the update on the current status.

    If you think that there is no way to use DynaView with Seam 2, it would be great if you could let me know. I will try then to use a different solution/framework.

    Thanks

    /mb

    #22161

    There are several older posts on how to get Seam 2 to work with PrettyFaces.

    The problem is that you need to be able to access a bean that *IS* available during method execution, for instance a normal JSF (non-Seam) bean. Otherwise because Seam has not yet started itself when DynaView is executed, there is no bean from which to execute the method.

    For instance, the same holds true for injecting parameters into such a bean:

    http://stackoverflow.com/questions/1266733/prettyfaces-with-seam-beans

    The same holds true for Action Methods:

    http://stackoverflow.com/questions/4448656/seam-and-prettyfaces

    Which is also the same problem you are experiencing here with DynaView. Try creating a standard JSF RequestScoped bean from which to execute the method. But most of the time, DynaView is more of a convenient workaround for something that could be accomplished via creative use of templating in the views themselves.

    This is a technical limitation of Seam 2 I am afraid… their contexts really should be started in a Filter, not a PhaseListener.

    ~Lincoln

Viewing 15 posts - 1 through 15 (of 17 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.