[Solved] Hello worlds fails.

Splash Forums Rewrite Users [Solved] Hello worlds fails.

This topic contains 7 replies, has 2 voices, and was last updated by  hcubyc 2 years, 8 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #25430

    hcubyc
    Participant

    //Solution at the bottom of the post.
    Hello,
    today I’ve decided to migrate from PrettyFaces to Rewrite. I’ve followed: http://ocpsoft.org/rewrite/docs/migration/prettyfaces3 (the JSF integration module section) and first of all:
    there’s an error in maven’s dependencies: AFAIK there’s not such artifactId as rewrite-integration-jsf, but there’s rewrite-integration-faces. So I’ve changed my pom – commented old prettyfaces’ dependencies and pasted new. I didn’t do anything with pretty-config.xml, because it’s said that rewrite doesn’t support xml anymore so I guess it’s presence won’t change anything. Then I’ve created following class:

    import javax.servlet.ServletContext;
    
    import org.ocpsoft.rewrite.annotation.RewriteConfiguration;
    import org.ocpsoft.rewrite.config.Configuration;
    import org.ocpsoft.rewrite.config.ConfigurationBuilder;
    import org.ocpsoft.rewrite.servlet.config.HttpConfigurationProvider;
    import org.ocpsoft.rewrite.servlet.config.rule.Join;
    
    @RewriteConfiguration
    public class RewriteConfigurationProvider extends HttpConfigurationProvider {
    
    	  @Override
    	  public Configuration getConfiguration(ServletContext context) {
    
    	     return ConfigurationBuilder.begin()
    
    	    		 .addRule(Join.path("/login").to("/pages/login.jsf"))
    
    	               ;
    	  }
    
    	  @Override
    	  public int priority() {
    	     return 10;
    	  }
    
    	}

    with the @RewriteConfiguration annotation, which can’t be found in the tutorial I’ve posted above (tried without it as well). I’ve set just one rule to test if it works, my previous login mapping looks like:

    <url-mapping id="login">
    		<pattern value="/login" />
    		<view-id value="/pages/login.jsf" />
    	</url-mapping>

    and it didn’t work. I didn’t change anything in the web.xml, because it worked before so I guess it’s ok. I use servlet 3.0-alpha1, myfaces 2.1.13, spring, primefaces and glassfish 4.0, my error looks like:
    `2013-11-26T18:24:48.275+0100|INFO: 2013-11-26 18:24:48,255 [http-listener-1(2)] ERROR org.dietmanager.jsf.util.CustomExceptionHandler – Critical Exception!
    java.lang.NullPointerException
    at org.primefaces.renderkit.OutcomeTargetRenderer.getTargetURL(OutcomeTargetRenderer.java:80)
    at org.primefaces.component.menu.BaseMenuRenderer.encodeMenuItem(BaseMenuRenderer.java:148)
    at org.primefaces.component.menu.MenuRenderer.encodeElements(MenuRenderer.java:84)
    at org.primefaces.component.menu.MenuRenderer.encodeSubmenu(MenuRenderer.java:119)
    at org.primefaces.component.menu.MenuRenderer.encodeElements(MenuRenderer.java:88)
    at org.primefaces.component.menu.MenuRenderer.encodeMarkup(MenuRenderer.java:68)
    at org.primefaces.component.menu.BaseMenuRenderer.encodeEnd(BaseMenuRenderer.java:105)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:74)
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57)
    at org.primefaces.renderkit.CoreRenderer.renderChild(CoreRenderer.java:72)
    at org.primefaces.renderkit.CoreRenderer.renderChildren(CoreRenderer.java:57)
    at org.primefaces.component.panel.PanelRenderer.encodeContent(PanelRenderer.java:204)
    at org.primefaces.component.panel.PanelRenderer.encodeMarkup(PanelRenderer.java:121)
    at org.primefaces.component.panel.PanelRenderer.encodeEnd(PanelRenderer.java:58)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:545)
    at org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:370)
    at org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:194)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:545)
    at org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase.renderChildren(HtmlGridRendererBase.java:370)
    at org.apache.myfaces.shared.renderkit.html.HtmlGridRendererBase.encodeEnd(HtmlGridRendererBase.java:194)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:665)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:545)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541)
    at javax.faces.component.UIComponentBase.encodeAll(UIComponentBase.java:541)
    at org.apache.myfaces.view.facelets.FaceletViewDeclarationLanguage.renderView(FaceletViewDeclarationLanguage.java:1981)
    at org.apache.myfaces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:305)
    at org.ocpsoft.rewrite.faces.RewriteViewHandler.renderView(RewriteViewHandler.java:186)
    at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:116)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:200)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:873)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:739)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:575)
    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:546)
    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:428)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:378)
    at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:38)
    at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:263)
    at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:188)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:180)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:330)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:118)
    at org.springframework.security.web.access.intercept.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:84)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.access.ExceptionTranslationFilter.doFilter(ExceptionTranslationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.session.SessionManagementFilter.doFilter(SessionManagementFilter.java:103)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.AnonymousAuthenticationFilter.doFilter(AnonymousAuthenticationFilter.java:113)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter.doFilter(RememberMeAuthenticationFilter.java:139)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter.doFilter(SecurityContextHolderAwareRequestFilter.java:54)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.savedrequest.RequestCacheAwareFilter.doFilter(RequestCacheAwareFilter.java:45)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.www.BasicAuthenticationFilter.doFilter(BasicAuthenticationFilter.java:150)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:183)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:105)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
    at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
    at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainPro
    2013-11-26T18:24:48.283+0100|INFO: xy.java:192)
    at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
    at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
    at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:357)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:260)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:188)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:191)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:168)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:189)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:288)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:206)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:136)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:114)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:838)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:113)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:115)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:55)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:135)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:564)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:544)
    at java.lang.Thread.run(Thread.java:744)’

    Edit: I’ve realized that there’s metadata-complete=”true” in my web.xml so I’ve added the RewriteFilter and still doesn’t work.
    Any ideas?

    SOLUTION:
    Remove all PrettyFaces’ leftovers – in my case: remove pretty outcomes like pretty:login from template.
    http://ocpsoft.org/java/migrating-from-prettyfaces-to-rewrite-simplicity-meets-power/ -> Read!.

    • This topic was modified 2 years, 8 months ago by  hcubyc.
    • This topic was modified 2 years, 8 months ago by  hcubyc.
    • This topic was modified 2 years, 8 months ago by  hcubyc.
    • This topic was modified 2 years, 8 months ago by  hcubyc.
    • This topic was modified 2 years, 8 months ago by  hcubyc.
    #25443

    Nice to hear you solved this issue. 🙂

    #25444

    And thanks for pointing us to the typo in the maven artifact name. I already fixed that. 🙂

    #25445

    hcubyc
    Participant

    @up
    The pleasure is mine. I think that you could combine these two migration tutorials or just mention in the first about fixing navigation cases, maybe it will save one’s time ; )

    #25447

    Isn’t there a section regarding on “programmatic navigation” in the migration guide? I remember I wrote something about this. 🙂

    #25450

    hcubyc
    Participant

    @up
    Indeed, there is 😉 However I’ve got following problem:
    I can’t (using NavigationHandler or your Nagivate) redirect/forward to any page from my exception factory class and from one of my managed beans – it doesn’t work from @PostConstruct init(). Any ideas? Everything else works great.
    There’s no error in console, e.g. my init method:

    @PostConstruct
    	public void init() {
    		user = Users.findByUsername(username);
    		if (user == null) {
    			navigator.forward("pretty:404"); // tried to put everything here.
    		}
    	}
    • This reply was modified 2 years, 8 months ago by  hcubyc.
    #25453

    What is navigator in your example?

    One possible reason why you are having problems in a @PostConstruct method is, that Rewrite by default does injection of parameters very early in request processing. Actually before the JSF lifecycle starts. So it is possible that your bean is created outside of the JSF lifecycle and therefore using a NavigationHandler won’t work. You can work around that by deferring the parameter injection (see “Path Parameters” in the migration guide).

    In your ExceptionHandler you could use the standard Servlet API for your redirect instead. This is IMHO even simpler than using a NavigatonHandler.

    #25460

    hcubyc
    Participant

    Well – everything works, used RequestDispatcher to forward from PostConstruct. I think that it would be nice to notice, that one hasn’t got to add navigation rules to faces-config when using primefaces. Chaning outcome attribute to url does the work.

    Anyways, thanks for your help I hope that everything will go smooth now 😉

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

You must be logged in to reply to this topic.

Comments are closed.