You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Daniel Le Berre (JIRA)" <ji...@apache.org> on 2018/11/20 22:58:00 UTC

[jira] [Created] (WW-4984) Static files like css and js files in struts-core not properly served

Daniel Le Berre created WW-4984:
-----------------------------------

             Summary: Static files like css and js files in struts-core not properly served
                 Key: WW-4984
                 URL: https://issues.apache.org/jira/browse/WW-4984
             Project: Struts 2
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.5.18
            Reporter: Daniel Le Berre


While preparing a small demo of struts2 for my students I was annoyed that error messages were not shown in red.

While investigating why, I noticed a lot of errors like this in the console:
{code:java}
GRAVE: "Servlet.service()" pour la servlet [default] a généré une exception
java.lang.NullPointerException
at org.apache.struts2.dispatcher.DefaultStaticContentLoader.findStaticResource(DefaultStaticContentLoader.java:199)
at org.apache.struts2.dispatcher.ExecuteOperations.executeStaticResourceRequest(ExecuteOperations.java:59)
at org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:128)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:844)

{code}
 

While looking at the HTML source of the page and web inspector of my browser, I also noted that three ressources were not found in that page:

 
{code:java}
/struts/utils.js  
/struts/css_xhtml/styles.css
/struts/css_xhtml/validation.js
{code}
 

 

AFAIK, those resources should be served by default from struts-core jar file because 
{code:java}
<constant name="struts.serve.static" value="true" />{code}
by default.

I could check that setting that constant to false prevents the NPE to occur.

I was able to find the three files in struts-core jar file.

I could check that copying those files in my webapp with the constant to false fixed my css issue regarding error messages.

So the NPE is related IMHO to  DefaultStaticContentLoader not being able to locate correctly the resources in the jar. I do not know why.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)