Closed rider87 closed 2 years ago
Thanks for the issue.
Yeah, we really need to retire those forums. The SPAM got too bad and now they are basically taken over. I'll remind the team.
This is odd.
Could you post a sample app that reproduces it, and provide a link to the exact version of Wildfly? I'd like to take a look.
Thanks again, ~Lincoln
Thanks Lincoln. Could you try it in one of your project with just to change the versions as above and use WildFly 21?
Link from Wildfly is this one: https://download.jboss.org/wildfly/21.0.0.Final/wildfly-21.0.0.Final.zip
Thanks for the WildFly link.
Unfortunately no. I will not be able to look into this without a minimal reproduction of the issue in a sample application.
Let me know when you have something small uploaded that reproduces the issue and I'll check it out.
Also, a full stack trace would be helpful, too!
Currently I have not that time to setup this very quick.
Here is the full strack trace:
Main part is this: Caused by: java.lang.NullPointerException at deployment.myapp.war//org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener.afterInboundLifecycle(DefaultRewriteLifecycleListener.java:56)
21:14:33,694 ERROR [io.undertow.request] (default task-26) UT005023: Exception handling request to /test.jsf: javax.servlet.ServletException: java.lang.NullPointerException at deployment.myapp.war//org.apache.shiro.web.servlet.AdviceFilter.cleanup(AdviceFilter.java:196) at deployment.myapp.war//org.apache.shiro.web.filter.authc.AuthenticatingFilter.cleanup(AuthenticatingFilter.java:155) at deployment.myapp.war//org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:148) at deployment.myapp.war//org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at deployment.myapp.war//org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66) at deployment.myapp.war//org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449) at deployment.myapp.war//org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365) at deployment.myapp.war//org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90) at deployment.myapp.war//org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) at deployment.myapp.war//org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387) at deployment.myapp.war//org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362) at deployment.myapp.war//org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at deployment.myapp.war//org.omnifaces.filter.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:123) at deployment.myapp.war//org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:108) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36) at org.wildfly.extension.undertow@21.0.0.Final//org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78) at io.undertow.core@2.2.2.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.RedirectDirHandler.handleRequest(RedirectDirHandler.java:68) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57) at io.undertow.core@2.2.2.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.core@2.2.2.Final//io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64) at io.undertow.core@2.2.2.Final//io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77) at io.undertow.core@2.2.2.Final//io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50) at io.undertow.core@2.2.2.Final//io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43) at io.undertow.core@2.2.2.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at org.wildfly.extension.undertow@21.0.0.Final//org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61) at io.undertow.core@2.2.2.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at org.wildfly.extension.undertow@21.0.0.Final//org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.SendErrorPageHandler.handleRequest(SendErrorPageHandler.java:52) at io.undertow.core@2.2.2.Final//io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:269) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43) at org.wildfly.extension.undertow@21.0.0.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105) at org.wildfly.extension.undertow@21.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530) at org.wildfly.extension.undertow@21.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530) at org.wildfly.extension.undertow@21.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530) at org.wildfly.extension.undertow@21.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530) at org.wildfly.extension.undertow@21.0.0.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99) at io.undertow.core@2.2.2.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:387) at io.undertow.core@2.2.2.Final//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:841) at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35) at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990) at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486) at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377) at org.jboss.xnio@3.8.2.Final//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1280) at java.base/java.lang.Thread.run(Thread.java:834) Caused by: java.lang.NullPointerException at deployment.myapp.war//org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener.afterInboundLifecycle(DefaultRewriteLifecycleListener.java:56) at deployment.myapp.war//org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener.afterInboundLifecycle(DefaultRewriteLifecycleListener.java:28) at deployment.myapp.war//org.ocpsoft.rewrite.servlet.RewriteFilter.doFilter(RewriteFilter.java:235) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61) at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131) at deployment.myapp.war//org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61) at deployment.myapp.war//org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108) at deployment.myapp.war//org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137) ... 60 more
Hm. Without being able to debug an application, the only thing that comes to mind is that it looks like you have some other servlet filters in the application that could be either intentionally or erroneously wiping state information on the response object.
Try changing filter priority/order in your web.xml or web-fragment.xml, or remove filters until you figure out which one is clearing the Response context.
The fact that it fails after these filters seems suspect:
at deployment.myapp.war//org.apache.shiro.web.servlet.AdviceFilter.cleanup(AdviceFilter.java:196)
at deployment.myapp.war//org.apache.shiro.web.filter.authc.AuthenticatingFilter.cleanup(AuthenticatingFilter.java:155)
at deployment.myapp.war//org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:148)
at deployment.myapp.war//org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at deployment.myapp.war//org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
And of course, again, if you can provide a sample application that reproduces this issue. We'll be happy to fix bugs in Rewrite (if there are any.)
I´m using Apache Shiro. In my web.xml is also this:
<filter>
<filter-name>ShiroFilter</filter-name>
<filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
After that is the Rewrite Filter:
<filter>
<filter-name>OCPsoft Rewrite Filter</filter-name>
<filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>OCPsoft Rewrite Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ASYNC</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
Is there something which I have to adjust? Any idea?
Any idea? Do I have to change the ordering or something?
Hello,
I have the same issue. Any solution for this?
Hello,
As I mentioned to the original poster. If you provide a sample application that reproduces the problem, we can look at what may be going wrong and hopefully provide a fix.
Without a reproduction of the issue, there is very little we can do to help.
Please provide the following:
Thank you.
I cannot really replicate it to say when and why it´s happening... Is there anything which I have to consider for the ordering? I´m pretty sure the problem is causing with Shiro and PrettyFaces. Currently my web.xml is looking like this:
`
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Rewrite after that -->
<filter>
<filter-name>OCPsoft Rewrite Filter</filter-name>
<filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>OCPsoft Rewrite Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ASYNC</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>`
Any ideas?
@testing138 This may be related to https://issues.redhat.com/browse/WFLY-13666
I stopped being able to reproduce it in Wildfly 22.0.0.Beta1
@codylerum codylerum Thanks... So you had the same issue?
@lincolnthree Is there any logic how I should add the different filter if I´m using Apache Shiro and Rewrite?
@testing138 A few notes:
dispatcher
to FORWARD
. That's because Rewrite forwards the request internally and only filters configured for dispatcher type FORWARD
will be applied for such forwarded requests.I hope this helps.
Thanks. Currently I have this... Do you think that´s fine?
`
<filter-mapping>
<filter-name>ShiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Rewrite after that -->
<filter>
<filter-name>OCPsoft Rewrite Filter</filter-name>
<filter-class>org.ocpsoft.rewrite.servlet.RewriteFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>OCPsoft Rewrite Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>INCLUDE</dispatcher>
<dispatcher>ASYNC</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
`
Looks good to me.
You could also try to add an empty <absolute-ordering />
element to your web.xml. This will disable processing of web-fragment.xml
files in your dependencies and will therefore prevent that Rewrite is registered twice by accident.
So just add:
<absolute-ordering />
and than my code which I´ve posted above?
The code posted above is fine. I just think it MAY be possible that the Rewrite filter is registered via your web.xml
AND additionally by the web-fragment.xml
which is included in the Rewrite JAR. In this case you would have the Rewrite filter twice which could cause issues. At least I saw such behavior in some situations. And adding an empty <absolute-ordering />
will disable processing of web-fragment.xml
and therefor ensure that the Rewrite filter is registered only once (via your web.xml
).
If I add this, I got other errors like:
java.lang.IllegalStateException: o:socket endpoint is not enabled. You need to set web.xml context param 'org.omnifaces.SOCKET_ENDPOINT_ENABLED' with value 'true'.
I´ve added this at the beginning of the web.xml:
<absolute-ordering />
Ok. Looks like OmniFaces also automatically registers servlets/listeners via web-fragment.xml
. And as you disabled processing of these fragments via <absolute-ordering />
, OmniFaces breaks. Unfortunately, if you disable fragments, you will have to set up everything via web.xml
yourself. Which requires some work, as you have to check all your dependencies for fragments. However, the positive effect is, that you have full control over filter/listener ordering. Not sure if this is worth the effort in your case.
It is very hard to help you with this without having access to an app which reproduces the problem. If you need further help with this issue, I strongly recommend trying to reproduce this in a minimal app that you can share.
Thanks again for reporting this. I am closing this issue as out of date / could not reproduce. Please feel free to open again if you can provide a minimal sample application that we can use to reproduce the error!
Seems like the ocpsoft rewrite forum is not really active - a lot of SPAM, therefore I will try it here.
After migration to Jakarta EE 8 I have issues during the navigation in my app. The issue is not appearing every time, but I also couldn´t find the root cause.
Caused by: java.lang.NullPointerException at deployment.myapp.war//org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener.afterInboundLifecycle(DefaultRewriteLifecycleListener.java:56)
I´m using Wildfly 21 and here my dependencies: