Skip to content
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

debugger resources are 404 not found #68

Open
wmh opened this issue Jul 30, 2015 · 14 comments
Open

debugger resources are 404 not found #68

wmh opened this issue Jul 30, 2015 · 14 comments

Comments

@wmh
Copy link

wmh commented Jul 30, 2015

I have tool.debugger = true in the configuration and append ?ddl-debug to the url to enable debugger. Resource files are appended to html, but all of them are 404 not found. Any thing I can do with this?

@tduchateau
Copy link
Member

Are you sure to deploy on a Servlet 3.x compatible container?
Is your web.xml file configured for the Servlet 3. API?

<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
         version="3.0">
...
</web-app>

@wmh
Copy link
Author

wmh commented Jul 30, 2015

I'm using the lastest version of spring boot and without web.xml configuration. The embed tomcat is 8.0.2x. I think it's Servlet 3.x.

@tduchateau
Copy link
Member

I think it comes from the Servlet API version. Let me try to reproduce and I get back to you.

@tduchateau
Copy link
Member

I've tested with the spring-boot-sample-tomcat sample app.

I've just added the following configuration class:

@Configuration
public class DandelionConfig {

   @Bean
   public FilterRegistrationBean dandelionFilterRegistrationBean() {
      return new FilterRegistrationBean(new DandelionFilter());
   }

   @Bean
   public FilterRegistrationBean datatableFilterRegistrationBean() {
      return new FilterRegistrationBean(new DatatablesFilter());
   }

   @Bean
   public ServletRegistrationBean dandelionServletRegistrationBean() {
      return new ServletRegistrationBean(new DandelionServlet(), "/dandelion-assets/*");
   }
}

No particular issue with the debugger. Do you know what could differ between your app and the above sample?

Spring Boot: 1.3.0.BUILD
Dandelion: 1.1.0
Tomcat embedded: 8.0.23

@wmh
Copy link
Author

wmh commented Jul 31, 2015

I have the same configuration in my project and I also have some other custom filters and interceptors, I don't know if that will be the problem. How can I debug for this?

@tduchateau
Copy link
Member

Interesting. Could you please try to configure the filter as the first one in the filter chain?

@Bean
public FilterRegistrationBean dandelionFilterRegistrationBean() {
      FilterRegistrationBean registrationBean = new FilterRegistrationBean();
      DandelionFilter dandelionFilter = new DandelionFilter();
      registrationBean.setFilter(dandelionFilter);
      registrationBean.setOrder(0);
      return registrationBean;
}

@wmh
Copy link
Author

wmh commented Aug 4, 2015

I found that my own resource handler cause the problem, how can I adopt the debugger with the resource handler?

This is the resource handler:

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    String verPrefix = myConf.getVersion();
    registry.addResourceHandler(verPrefix + "/**").addResourceLocations("classpath:/public/");
    registry.addResourceHandler("/**").addResourceLocations("classpath:/public/");
}

@tduchateau
Copy link
Member

Try:

registry.addResourceHandler("/ddl-debugger/**").addResourceLocations("/ddl-debugger/");

The above will only work in a Servlet 3.x container. So it should work with Spring Boot.

@wmh
Copy link
Author

wmh commented Aug 4, 2015

It's not working, still 404 not found. 😢

@tduchateau
Copy link
Member

I'm wondering if it's an ordering issue or not..

What happens if you declare the most specific rule in first?

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
    String verPrefix = myConf.getVersion();
    registry.addResourceHandler("/ddl-debugger/**").addResourceLocations("/ddl-debugger/");
    registry.addResourceHandler(verPrefix + "/**").addResourceLocations("classpath:/public/");
    registry.addResourceHandler("/**").addResourceLocations("classpath:/public/");
}

@wmh
Copy link
Author

wmh commented Aug 4, 2015

I have tried but the result is the same.

@tduchateau
Copy link
Member

Some logs would help. Could you please turn on DEBUG logs on org.springframework.web and post what happens while trying to access the debugger?

@wmh
Copy link
Author

wmh commented Aug 5, 2015

one of the resource file:

15:29:22.265 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.DispatcherServlet]: 861 - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/ddl-debugger/js/d3.min.js]
15:29:22.266 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: 294 - Looking up handler method for path /ddl-debugger/js/d3.min.js
15:29:22.268 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: 302 - Did not find handler method for [/ddl-debugger/js/d3.min.js]
15:29:22.269 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping]: 168 - Matching patterns for request [/ddl-debugger/js/d3.min.js] are [/ddl-debugger/**, /**]
15:29:22.269 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping]: 193 - URI Template variables for request [/ddl-debugger/js/d3.min.js] are {}
15:29:22.269 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping]: 123 - Mapping [/ddl-debugger/js/d3.min.js] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/ddl-debugger/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@b16770]]] and 1 interceptor
15:29:22.269 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.DispatcherServlet]: 947 - Last-Modified value for [/ddl-debugger/js/d3.min.js] is: -1
15:29:22.269 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.DispatcherServlet]:1034 - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
15:29:22.269 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.DispatcherServlet]: 997 - Successfully completed request
15:29:22.270 [http-nio-8080-exec-8] DEBUG [org.springframework.web.servlet.DispatcherServlet]: 861 - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
...

@tduchateau
Copy link
Member

Thanks!
I think I got it. Could please try to configure a default servlet handler?

Using JavaConfig:

public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
   configurer.enable(); 
}

Or XML:

<mvc:default-servlet-handler/>

Then the custom resource handler for Dandelion shouldn't be needed.

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

No branches or pull requests

2 participants