New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrettyFaces + OmniFaces throw RuntimeException #370

Closed
BryanV91 opened this Issue Apr 5, 2017 · 9 comments

Comments

Projects
None yet
2 participants
@BryanV91

BryanV91 commented Apr 5, 2017

We have been working in our projects with PrettyFaces (2.0.9 to 3.4.1) and OmniFaces (2.0). And it works perfectly, no problems at all.

But, when we upgrade OmniFaces to any version greater than (2.0). We are getting this messages in the stack trace:

SEVERE [org.ocpsoft.rewrite.AbstractRewrite] (default task-15) Rewrite rule evaluation for event [InboundRewrite [POST url=http://some-site.test.com:80/test/pages/home.jsf?omnifaces.event=unload&id=cd46923d-ba0a-406d-a687-0a2ab560bf82&javax.faces.ViewState=870923216170130188%3A9135044854697759247, flow=FORWARD, dispatchResource=/pages/home.jsf]]
	Rule 0: .addRule(UrlMappingRuleAdaptor [mapping=UrlMapping [ id=home, pattern=/inicio, parentId=, viewId=/pages/home.jsf, actions=[], outbound=true, parser=com.ocpsoft.pretty.faces.url.URLPatternParser@2bafcd40, pathValidators=[], queryParams=[]]]).withId("UrlMappingRuleAdaptor [mapping=UrlMapping [ id=home, pattern=/inicio, parentId=, viewId=/pages/home.jsf, actions=[], outbound=true, parser=com.ocpsoft.pretty.faces.url.URLPatternParser@2bafcd40, pathValidators=[], queryParams=[]]]") defined at org.ocpsoft.rewrite.prettyfaces.PrettyFacesRewriteConfigurationProvider.getConfiguration(PrettyFacesRewriteConfigurationProvider.java:64)
ERROR [io.undertow.request] (default task-15) UT005023: Exception handling request to /htmc/pages/home.jsf: java.lang.RuntimeException: java.lang.NullPointerException
	at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:184) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler.handleResult(HttpRewriteResultHandler.java:42) [rewrite-servlet-3.4.1.Final.jar:3.4.1.Final]
	at org.ocpsoft.rewrite.servlet.RewriteFilter.rewrite(RewriteFilter.java:297) [rewrite-servlet-3.4.1.Final.jar:3.4.1.Final]
	at org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:198) [rewrite-servlet-3.4.1.Final.jar:3.4.1.Final]
	at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:60) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:56) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:63) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.jrHandle(ServletInitialHandler.java) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at org.zeroturnaround.javarebel.integration.servlet.undertow.cbp.ServletInitialHandlerCBP.handleRequest(ServletInitialHandlerCBP.java:98) [undertow-servlet-jr-plugin-6.5.0.jar:]
	at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:261) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:247) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:76) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:166) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.Connectors.executeRootHandler(Connectors.java:197) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:759) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.8.0_111]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.8.0_111]
	at java.lang.Thread.run(Unknown Source) [rt.jar:1.8.0_111]
Caused by: java.lang.NullPointerException
	at java.util.regex.Matcher.getTextLength(Unknown Source) [rt.jar:1.8.0_111]
	at java.util.regex.Matcher.reset(Unknown Source) [rt.jar:1.8.0_111]
	at java.util.regex.Matcher.<init>(Unknown Source) [rt.jar:1.8.0_111]
	at java.util.regex.Pattern.matcher(Unknown Source) [rt.jar:1.8.0_111]
	at io.undertow.predicate.RegularExpressionPredicate.resolve(RegularExpressionPredicate.java:59) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.handlers.encoding.AllowedContentEncodings.getEncoding(AllowedContentEncodings.java:63) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.handlers.encoding.AllowedContentEncodings.wrap(AllowedContentEncodings.java:92) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.handlers.encoding.AllowedContentEncodings.wrap(AllowedContentEncodings.java:36) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.HttpServerExchange$WrapperStreamSinkConduitFactory.create(HttpServerExchange.java:2148) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.server.HttpServerExchange.getResponseChannel(HttpServerExchange.java:1199) [undertow-core-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.spec.ServletOutputStreamImpl.flushInternal(ServletOutputStreamImpl.java:485) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.spec.ServletOutputStreamImpl.flush(ServletOutputStreamImpl.java:469) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.spec.ServletPrintWriter.flush(ServletPrintWriter.java:72) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.spec.ServletPrintWriterDelegate.flush(ServletPrintWriterDelegate.java:94) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:170) [undertow-servlet-1.1.0.Final.jar:1.1.0.Final]
	... 33 more

Navigation is performed, but we don't know if the problem is related to PrettyFaces or Omnifaces.

@BryanV91 BryanV91 changed the title from PrettyFaces + OmniFaces throws RuntimeException to PrettyFaces + OmniFaces throw RuntimeException Apr 5, 2017

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC May 7, 2017

Member

The ?omnifaces.event=unload in URL tells that it's coming from new @ViewScoped unload feature of OmniFaces which is triggered when enduser unloads/changes/closes its browser window/tab (so OmniFaces @ViewScoped bean will be immediately destroyed).

Exception suggests that PrettyFaces tried to forward it but it really shouldn't need to do. First thing which you should check is whether the action attribute of the generated HTML <form> contains the correct URL (exactly the one as you see in browser's address bar). If that doesn't give clues, then you could try reconfiguring PrettyFaces to ignore URLs having omnifaces.event=unload query parameter.

By the way, in OmniFaces 2.6.3-SNAPSHOT I have changed the unload to send a POST instead of a GET. I recommend to try 2.6.3-SNAPSHOT to see if PrettyFaces is more happy with it.

Member

BalusC commented May 7, 2017

The ?omnifaces.event=unload in URL tells that it's coming from new @ViewScoped unload feature of OmniFaces which is triggered when enduser unloads/changes/closes its browser window/tab (so OmniFaces @ViewScoped bean will be immediately destroyed).

Exception suggests that PrettyFaces tried to forward it but it really shouldn't need to do. First thing which you should check is whether the action attribute of the generated HTML <form> contains the correct URL (exactly the one as you see in browser's address bar). If that doesn't give clues, then you could try reconfiguring PrettyFaces to ignore URLs having omnifaces.event=unload query parameter.

By the way, in OmniFaces 2.6.3-SNAPSHOT I have changed the unload to send a POST instead of a GET. I recommend to try 2.6.3-SNAPSHOT to see if PrettyFaces is more happy with it.

@BryanV91

This comment has been minimized.

Show comment
Hide comment
@BryanV91

BryanV91 May 8, 2017

I can't ignore URLs with ?omnifaces.event=unload, almost 90% of the pages are developed with OmniFaces @ViewScoped.

I want to give it a try with the 2.6.3-SNAPSHOT. Where can I find the JAR? Unfortunately I'm not using Maven, so I need the JAR.

BryanV91 commented May 8, 2017

I can't ignore URLs with ?omnifaces.event=unload, almost 90% of the pages are developed with OmniFaces @ViewScoped.

I want to give it a try with the 2.6.3-SNAPSHOT. Where can I find the JAR? Unfortunately I'm not using Maven, so I need the JAR.

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC May 9, 2017

Member

I can't ignore URLs with ?omnifaces.event=unload, almost 90% of the pages are developed with OmniFaces @ViewScoped.

I mean, you need to instruct/reconfigure PrettyFaces to not take any action on URLs with ?omnifaces.event=unload. I.e. it should not attempt to forward or redirect them, but just let them go as originally.

I want to give it a try with the 2.6.3-SNAPSHOT. Where can I find the JAR? Unfortunately I'm not using Maven, so I need the JAR.

You can find it here: https://oss.sonatype.org/content/repositories/snapshots/org/omnifaces/omnifaces/2.6.3-SNAPSHOT/

Member

BalusC commented May 9, 2017

I can't ignore URLs with ?omnifaces.event=unload, almost 90% of the pages are developed with OmniFaces @ViewScoped.

I mean, you need to instruct/reconfigure PrettyFaces to not take any action on URLs with ?omnifaces.event=unload. I.e. it should not attempt to forward or redirect them, but just let them go as originally.

I want to give it a try with the 2.6.3-SNAPSHOT. Where can I find the JAR? Unfortunately I'm not using Maven, so I need the JAR.

You can find it here: https://oss.sonatype.org/content/repositories/snapshots/org/omnifaces/omnifaces/2.6.3-SNAPSHOT/

@BryanV91

This comment has been minimized.

Show comment
Hide comment
@BryanV91

BryanV91 May 9, 2017

Now I get your point.

image

OmniFaces is appending the unload event at the end of the PrettyURL. When the PrettyFaces's parser is trying to get the perfect match for the requested URL it fails, thus the NullPointerException.

An unknown source sends a new request, the same URL without the parameter. Navigation is performed, but now the ?omnifaces.event=unload is missing. And the unload feature is not triggered anymore.

Unfortunately PrettyFaces's extensions are limited, so I'm not able to overwrite the behaviour for URLs that contain ?omnifaces.event=unload.

By the way, in OmniFaces 2.6.3-SNAPSHOT I have changed the unload to send a POST instead of a GET. I recommend to try 2.6.3-SNAPSHOT to see if PrettyFaces is more happy with it.

10:08:13,279 INFO [org.omnifaces.ApplicationInitializer] (MSC service thread 1-3) Using OmniFaces version 2.6.3-SNAPSHOT

I'm using OmniFaces 2.6.3-SNAPSHOT, the event is indeed sent by POST, but unload parameter is still present (like a GET request). PrettyFaces would be the happiest JAR on Earth, if the unload parameter is not appended at the end of the URL.

Is there any way that parameters used by OmniFaces are not sent along with the URL?

BryanV91 commented May 9, 2017

Now I get your point.

image

OmniFaces is appending the unload event at the end of the PrettyURL. When the PrettyFaces's parser is trying to get the perfect match for the requested URL it fails, thus the NullPointerException.

An unknown source sends a new request, the same URL without the parameter. Navigation is performed, but now the ?omnifaces.event=unload is missing. And the unload feature is not triggered anymore.

Unfortunately PrettyFaces's extensions are limited, so I'm not able to overwrite the behaviour for URLs that contain ?omnifaces.event=unload.

By the way, in OmniFaces 2.6.3-SNAPSHOT I have changed the unload to send a POST instead of a GET. I recommend to try 2.6.3-SNAPSHOT to see if PrettyFaces is more happy with it.

10:08:13,279 INFO [org.omnifaces.ApplicationInitializer] (MSC service thread 1-3) Using OmniFaces version 2.6.3-SNAPSHOT

I'm using OmniFaces 2.6.3-SNAPSHOT, the event is indeed sent by POST, but unload parameter is still present (like a GET request). PrettyFaces would be the happiest JAR on Earth, if the unload parameter is not appended at the end of the URL.

Is there any way that parameters used by OmniFaces are not sent along with the URL?

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC May 20, 2017

Member

Can you retry with today's 2.6.3 snapshot?

Member

BalusC commented May 20, 2017

Can you retry with today's 2.6.3 snapshot?

@BryanV91

This comment has been minimized.

Show comment
Hide comment
@BryanV91

BryanV91 May 21, 2017

Neither omnifaces-2.6.3-20170503.130407-1.jar nor omnifaces-2.6.3-20170509.060310-2.jar have Move omnifaces.event=unload from URL into body

BryanV91 commented May 21, 2017

Neither omnifaces-2.6.3-20170503.130407-1.jar nor omnifaces-2.6.3-20170509.060310-2.jar have Move omnifaces.event=unload from URL into body

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC May 21, 2017

Member

Sorry, I forgot that automatic snapshot releases are only enabled in development branch. I've manually pushed it. Pick omnifaces-2.6.3-20170521.083809-3.jar

Member

BalusC commented May 21, 2017

Sorry, I forgot that automatic snapshot releases are only enabled in development branch. I've manually pushed it. Pick omnifaces-2.6.3-20170521.083809-3.jar

@BryanV91

This comment has been minimized.

Show comment
Hide comment
@BryanV91

BryanV91 May 22, 2017

Just tested with omnifaces-2.6.3-20170521.083809-3.jar, problem solved when I manually add faces-redirect=true.

  • File pretty-config.xml with faces-redirect=true:
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                      http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">

	<url-mapping id="from">
		<pattern value="/pretty/faces/from" />
		<view-id value="/from.jsf?faces-redirect=true" />
	</url-mapping>

	<url-mapping id="to">
		<pattern value="/pretty/faces/to" />
		<view-id value="/to.jsf?faces-redirect=true" />
	</url-mapping>

</pretty-config>

Performing navigation with faces-redirect=true:

image

Unload event working properly, navigations is performed and no exception throwed.

  • File pretty-config.xml without faces-redirect=true:
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                      http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">

	<url-mapping id="from">
		<pattern value="/pretty/faces/from" />
		<view-id value="/from.jsf" />
	</url-mapping>

	<url-mapping id="to">
		<pattern value="/pretty/faces/to" />
		<view-id value="/to.jsf" />
	</url-mapping>

</pretty-config>

Performing navigation without faces-redirect=true:

image

Unload event pending, navigations is performed and no exception throwed.

Refreshing same page without faces-redirect=true:

image

Unload event failed, navigations is performed and exception is throwed.

Looks like a forward issue. But at least problem is solved.

BryanV91 commented May 22, 2017

Just tested with omnifaces-2.6.3-20170521.083809-3.jar, problem solved when I manually add faces-redirect=true.

  • File pretty-config.xml with faces-redirect=true:
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                      http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">

	<url-mapping id="from">
		<pattern value="/pretty/faces/from" />
		<view-id value="/from.jsf?faces-redirect=true" />
	</url-mapping>

	<url-mapping id="to">
		<pattern value="/pretty/faces/to" />
		<view-id value="/to.jsf?faces-redirect=true" />
	</url-mapping>

</pretty-config>

Performing navigation with faces-redirect=true:

image

Unload event working properly, navigations is performed and no exception throwed.

  • File pretty-config.xml without faces-redirect=true:
<pretty-config xmlns="http://ocpsoft.org/schema/rewrite-config-prettyfaces"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://ocpsoft.org/schema/rewrite-config-prettyfaces
                      http://ocpsoft.org/xml/ns/prettyfaces/rewrite-config-prettyfaces.xsd">

	<url-mapping id="from">
		<pattern value="/pretty/faces/from" />
		<view-id value="/from.jsf" />
	</url-mapping>

	<url-mapping id="to">
		<pattern value="/pretty/faces/to" />
		<view-id value="/to.jsf" />
	</url-mapping>

</pretty-config>

Performing navigation without faces-redirect=true:

image

Unload event pending, navigations is performed and no exception throwed.

Refreshing same page without faces-redirect=true:

image

Unload event failed, navigations is performed and exception is throwed.

Looks like a forward issue. But at least problem is solved.

@BalusC

This comment has been minimized.

Show comment
Hide comment
@BalusC

BalusC May 22, 2017

Member

Thank you for reporting back!

Member

BalusC commented May 22, 2017

Thank you for reporting back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment