Odd error when redirecting from Java code

Splash Forums PrettyFaces Users Odd error when redirecting from Java code

This topic contains 4 replies, has 3 voices, and was last updated by  Lincoln Baxter III 5 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18096

    clemmonsm
    Participant

    I recently began receiving the error detailed below when attempting to perform a pretty redirect from Java code. The issue started when I upgraded from v3.3.0 to v3.3.2 and attempted to incorporate DynaViews. After backing out the DynaView mapping in pretty-config.xml and reverting back to v3.3.0, I still received this error. I am suspicious that the lingering of this issue is related to a separate issue I detail in this thread: http://ocpsoft.com/support/topic/upgraded-to-332-from-330-failed-to-load-configuration-1

    CODE:

    public void vcMetroAreaRedirect(ValueChangeEvent valueChangeEvent) {

    // Get the select one choice component
    RichSelectOneChoice hsom = (RichSelectOneChoice)valueChangeEvent.getSource();
    // Get the value string
    String hsomValue = (String)hsom.getValue();
    String state = "";

    // get state value
    for (AreaCriteria ac : listOfAreas) {
    if(ac.getArcShortName().equalsIgnoreCase(hsomValue)){
    state = ac.getArcState();
    break;
    }
    }

    Object[] params = new Object[] { state, hsomValue }; // set params in order defined in mappingId
    // prettyFaces redir
    siteTasks st = new siteTasks();
    st.prettyFacesRedirect("city", params); // mappingId, params
    }

    public void prettyFacesRedirect (String mappingId, Object[] params) {
    try {

    // PrettyFaces redirect
    HttpServletRequest request = (HttpServletRequest)FacesContext.getCurrentInstance().getExternalContext().getRequest();
    HttpServletResponse response = (HttpServletResponse)FacesContext.getCurrentInstance().getExternalContext().getResponse();
    PrettyContext context = PrettyContext.getCurrentInstance(request);
    PrettyURLBuilder builder = new PrettyURLBuilder();

    // set PrettyFaces url-mapping id
    UrlMapping mapping = context.getConfig().getMappingById(mappingId);

    // IMPORTANT!!! Persist the _adf.ctrl-state parameter across requests so ADF session is not broken.
    String targetURL = context.getContextPath() + builder.build(mapping, true, params) + "?_adf.ctrl-state=" + request.getParameterValues("_adf.ctrl-state")[0];

    targetURL = response.encodeRedirectURL(targetURL);
    response.sendRedirect(targetURL);
    FacesContext.getCurrentInstance().responseComplete();

    } catch (IOException e) {
    e.printStackTrace(); // Can't redirect
    } catch (Exception e) {
    e.printStackTrace();
    }

    }

    PRETTY-CONFIG:

    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <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="home">
    <pattern value="/" />
    <view-id value="/faces/pages/index.jspx" />
    </url-mapping>

    <url-mapping id="default">
    <pattern value="/default/" />
    <view-id value="/faces/pages/default.jspx" />
    </url-mapping>

    <!-- City -->

    <!-- NOTE: this is the mapping where the error is currently occurring -->
    <url-mapping id="city">
    <pattern value="/new-homes/#{state:siteTasks.state}/#{city:siteTasks.city}/" />
    <view-id value="/faces/pages/city.jspx" />
    </url-mapping>

    <!-- Community / Neighborhood -->

    <url-mapping id="community">
    <pattern value="/new-homes/#{state:siteTasks.state}/#{city:siteTasks.city}/find/communities/#{community:siteTasks.community}/" />
    <view-id value="/faces/pages/community.jspx" />

    <!-- NOTE: the following is commented-out dynaview config -->
    <!--view-id value="#{siteTasks.getCmNbViewPath}" />
    <query-param name="state">#{siteTasks.state}</query-param>
    <query-param name="city">#{siteTasks.city}</query-param>
    <query-param name="community">#{siteTasks.community}</query-param-->

    </url-mapping>

    ...

    <!-- inbound rewrite rules -->
    <!-- append trailing slash, set url to lowercase (not including trailing query params) -->
    <rewrite outbound="false" match="^[^?.]*$" toCase="lowercase" trailingSlash="append" redirect="301" /> <!-- matches strings w/o "?" or "." -->

    <!-- outbound rewrite rules -->
    <!-- process outbound urls via PrettyFacesAdfProcessor -->
    <rewrite inbound="false" match=".*(^/$|/about-drees/|/finance/|/build-on-your-lot/|/new-homes/|/request-info/|/career/)+.*" processor="siteUtils.PrettyFacesAdfProcessor" redirect="301" />

    </pretty-config>

    ERROR:

    <PrettyContext> <<init>> Initialized PrettyContext
    <PrettyContext> <<init>> Initialized PrettyContext
    <PrettyFilter> <doFilter> Sending mapped request [/new-homes/indiana/indianapolis/] to resource [/faces/pages/city.jspx]
    <PrettyContext> <<init>> Initialized PrettyContext
    <PrettyContext> <<init>> Initialized PrettyContext
    <PrettyFilter> <doFilter> Request is not mapped using PrettyFaces. Continue.
    <PrettyContext> <<init>> Initialized PrettyContext
    <PrettyContext> <<init>> Initialized PrettyContext
    <PrettyFilter> <doFilter> Sending mapped request [/new-homes/indiana/indianapolis/] to resource [/faces/pages/city.jspx]
    <PrettyContext> <<init>> Initialized PrettyContext
    <PrettyContext> <<init>> Initialized PrettyContext
    <PrettyFilter> <doFilter> Request is not mapped using PrettyFaces. Continue.
    <Nov 15, 2011 4:30:27 PM EST> <Error> <HTTP> <BEA-101020> <[ServletContext@766598250[app:dreeshomes module:dreeshomes path:/dreeshomes spec-version:2.5]] Servlet failed with Exception
    java.lang.NullPointerException
    at oracle.adf.model.binding.DCBindingContainerReference.getDef(DCBindingContainerReference.java:111)
    at oracle.adf.model.BindingContext.findBindingContainerDefByPath(BindingContext.java:1650)
    at oracle.adf.model.BindingRequestHandler.isPageViewable(BindingRequestHandler.java:371)
    at oracle.adf.model.BindingRequestHandler.beginRequest(BindingRequestHandler.java:246)
    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:203)
    Truncated. see log file for complete stacktrace
    >
    <Nov 15, 2011 4:30:27 PM EST> <Notice> <Diagnostics> <BEA-320068> <Watch 'UncheckedException' with severity 'Notice' on server 'DefaultServer' has triggered at Nov 15, 2011 4:30:27 PM EST. Notification details:
    WatchRuleType: Log
    WatchRule: (SEVERITY = 'Error') AND ((MSGID = 'WL-101020') OR (MSGID = 'WL-101017') OR (MSGID = 'WL-000802') OR (MSGID = 'BEA-101020') OR (MSGID = 'BEA-101017') OR (MSGID = 'BEA-000802'))
    WatchData: DATE = Nov 15, 2011 4:30:27 PM EST SERVER = DefaultServer MESSAGE = [ServletContext@766598250[app:dreeshomes module:dreeshomes path:/dreeshomes spec-version:2.5]] Servlet failed with Exception
    java.lang.NullPointerException
    at oracle.adf.model.binding.DCBindingContainerReference.getDef(DCBindingContainerReference.java:111)
    at oracle.adf.model.BindingContext.findBindingContainerDefByPath(BindingContext.java:1650)
    at oracle.adf.model.BindingRequestHandler.isPageViewable(BindingRequestHandler.java:371)
    at oracle.adf.model.BindingRequestHandler.beginRequest(BindingRequestHandler.java:246)
    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:203)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:175)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:126)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:524)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:253)
    at com.ocpsoft.pretty.PrettyFilter.doFilter(PrettyFilter.java:118)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    SUBSYSTEM = HTTP USERID = <WLS Kernel> SEVERITY = Error THREAD = [ACTIVE] ExecuteThread: '14' for queue: 'weblogic.kernel.Default (self-tuning)' MSGID = BEA-101020 MACHINE = Matthew-Clemmons-MacBook-2.local TXID = CONTEXTID = 9714c4774095e37d:-a2fc49f:133a90d7914:-8000-00000000000000cb TIMESTAMP = 1321392627710
    WatchAlarmType: AutomaticReset
    WatchAlarmResetPeriod: 30000
    >
    <Nov 15, 2011 4:30:32 PM EST> <Warning> <Socket> <BEA-000449> <Closing socket as no data read from it on 127.0.0.1:60,326 during the configured idle timeout of 5 secs>
    <Nov 15, 2011 4:30:32 PM EST> <Warning> <Socket> <BEA-000449> <Closing socket as no data read from it on 127.0.0.1:60,328 during the configured idle timeout of 5 secs>
    <Nov 15, 2011 4:30:32 PM EST> <Warning> <Socket> <BEA-000449> <Closing socket as no data read from it on 127.0.0.1:60,329 during the configured idle timeout of 5 secs>
    <Nov 15, 2011 4:30:32 PM EST> <Warning> <Socket> <BEA-000449> <Closing socket as no data read from it on 127.0.0.1:60,327 during the configured idle timeout of 5 secs>

    #21696

    Hmmm… The NPE is thrown from within the Weblogic code. I don’t have any clue why this happens. Perhaps it is really related to the other issue. Could you try the snapshots like I described in the other post. Perhaps this helps.

    #21697

    clemmonsm
    Participant

    Hello again Christian,

    I re-tried this after using the 3.3.3 snapshot and received the same error. Interestingly, it not only happens when the prettyFacesRedirect method is called, but also when the URL is input directly. It must have something to do with the actual page that is being loaded and not PF…I will continue to research and report back.

    #21698

    clemmonsm
    Participant

    Fixed by rebuilding the jspx page. Not sure what the issue was specifically, but it’s all better now. Must have been something hosed deep in the caverns of ADF…

    #21699

    JSF is a very complex beast. Do enough work and eventually you will find a way to give it a headache :) Glad you got it worked out.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Comments are closed.