Hi Darren,

On 6 Jan 2014, at 14:10, Darren Jones wrote:

> Hello,
> 
> I've been trying to get Apache Wookie working on WildFly. After raising a
> few defects against WildFly's new web server component called UnderTow
> (which are now fixed), I think there may be a remaining issue in Wookie:
> 
> In LocalizedResourceFilter, there is code that looks for a localized copy
> of a resource. Here is an example snippet (around line 185):
> 
>      String filePath = filterConfig.getServletContext().getRealPath(path);
>      if (new File(filePath).exists())
>        return context + path;
> 
> According to the javadoc for ServletContext.getRealPath(), it is allowed to
> return null if the file does not exist. As my widgets are not localized,
> this is the case, and a NullPointerException occurs because null is then
> passed to new File(filePath).
> 
> I'm not sure why this has not been found before - perhaps other web servers
> have not been returning null if a resource does not exist.

You're right, it is odd. Most of the test widgets aren't localized either, so 
if it was purely an issue with that then we should have seen the error before. 
I wonder if its something to do with WildFly's implementation of Filter and/or 
ServletContext?  Whatever the cause, we need to make sure we catch this case 
and handle it properly.

> 
> I've fixed it temporarily with a local patch that does an extra null check
> before calling new File():
> 
>      String filePath = filterConfig.getServletContext().getRealPath(path);
>      if (filePath != null && new File(filePath).exists())
>        return context + path;
> 
> There are 3 places in LocalizedResourceFilter that needed this fix - and
> may there be more in other Wookie classes?
> 
> Should I raise a Jira ticket for this?

Yes please. Can you attach your patch to the ticket as well? If it fixes the 
problem I'd be happy to review and apply it.

Cheers,

S

> 
> Thanks,
> 
> Darren.
> 
> (Full exception from WildFly log is given below)
> 
>     [exec] 13:58:02,558 ERROR [io.undertow.request] (default task-2)
> UT005023: Exception handling request to /wookie/wservices/
> abc.com/widgets/abc-tag-cloud/index.html: java.lang.RuntimeException:
> Exception caught for transaction: java.lang.NullPointerException
>     [exec] at
> org.apache.wookie.server.MainFilter.doFilter(MainFilter.java:85) [classes:]
>     [exec] at
> io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:70)
>     [exec] at
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> io.undertow.security.handlers.AuthenticationConstraintHandler.handleRequest(AuthenticationConstraintHandler.java:51)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.servlet.handlers.security.ServletSecurityConstraintHandler.handleRequest(ServletSecurityConstraintHandler.java:56)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:67)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:70)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
>     [exec] at
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.server.Connectors.executeRootHandler(Connectors.java:164)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:654)
> [undertow-core-1.0.0.Beta31-SNAPSHOT.jar:1.0.0.Beta31-SNAPSHOT]
>     [exec] at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
> [rt.jar:1.7.0_21]
>     [exec] at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
> [rt.jar:1.7.0_21]
>     [exec] at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
>     [exec] Caused by: java.lang.NullPointerException
>     [exec] at java.io.File.<init>(File.java:251) [rt.jar:1.7.0_21]
>     [exec] at
> org.apache.wookie.server.LocalizedResourceFilter.getLocalizedResource(LocalizedResourceFilter.java:186)
> [classes:]
>     [exec] at
> org.apache.wookie.server.LocalizedResourceFilter.doFilter(LocalizedResourceFilter.java:92)
> [classes:]
>     [exec] at
> io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
> [undertow-servlet-1.0.0.Beta30.jar:1.0.0.Beta30]
>     [exec] at
> org.apache.wookie.server.MainFilter.doFilter(MainFilter.java:63) [classes:]
>     [exec] ... 29 more

Attachment: PGP.sig
Description: This is a digitally signed message part

Reply via email to