zengkid / SmartTomcat

The Tomcat plugin for Intellij IDEA
Apache License 2.0
126 stars 55 forks source link

Doesn't support the root context path (`/`) #93

Closed cheng6563 closed 2 years ago

cheng6563 commented 2 years ago

Describe the bug 4.3.5 open any jsp page error.
error stack:

org.apache.jasper.JasperException: Unable to compile class for JSP
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:675)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:743)
    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
    at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)
    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
    at com.opensymphony.webwork.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:114)
    at com.opensymphony.webwork.dispatcher.WebWorkResultSupport.execute(WebWorkResultSupport.java:143)
    at com.opensymphony.xwork.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:313)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:208)
    at xxxx.PermissionCheckInterceptor.intercept(PermissionCheckInterceptor.java:86)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
    at xxxx.DynamicDataSourceInterceptor.intercept(DynamicDataSourceInterceptor.java:65)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
    at xxxx.ComponentAutowireInterceptor.intercept(ComponentAutowireInterceptor.java:64)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
    at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
    at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
    at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:116)
    at com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(DispatcherUtils.java:274)
    at com.opensymphony.webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at xxxx.WebLogFilter.doFilter(WebLogFilter.java:28)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at xxxx.TraceFilter.doFilter(TraceFilter.java:29)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.springframework.orm.hibernate.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:172)
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at xxxx.EncodingFilter.doFilter(EncodingFilter.java:66)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve.invoke(RedisSessionHandlerValve.java:22)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Negative time
    at java.io.File.setLastModified(File.java:1427)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:377)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:660)
    ... 68 common frames omitted

I am downgurade to 4.3.4 no this error.

Screenshots If applicable, add screenshots to help explain your problem.

Intellij & SmartTomcat Version (Help -> About copy & paste below) IntelliJ IDEA 2022.2.2 (Community Edition) #IC-222.4167.29
SmartTomcat 4.3.5 apache-tomcat-7.0.85

yuezk commented 2 years ago

@cheng6563 Thanks for your feedback. Currently, it works well for me with Tomcat 9. I'm going to check it with Tomcat 7.

yuezk commented 2 years ago

@cheng6563 Still couldn't reproduce it with Tomcat 7.0.85. Can you try the following steps to see if it is still reproducible with 4.3.5?

  1. Remove the .SmartTomcat folder. For Windows: C:\Users\<user>\.SmartTomcat, and for macOS/Linux: ~/.SmartTomcat
  2. Re-run it to see if it is back to normal.

If possible, please provide a demo project. Thanks.

cheng6563 commented 2 years ago

@yuezk Thanks for your feedback. In fact, 4.3.4 also has this problem. I don't know why the project started successfully when switching to 4.3.4 during the test. :(

The problem seems to be that the Context path cannot be set to /, as long as it is not set to / it starts successfully.

When I debug, I found the following code in tomcat, contextPath will be spliced with / to become //, causing problems

//org.apache.naming.resources.DirContextURLConnection
if (contextPath != null) {
    if (!this.path.startsWith(contextPath + "/")) {
        return;
    }

    this.path = this.path.substring(contextPath.length());
}

Can Context path be set to empty?

yuezk commented 2 years ago

@cheng6563 There is a workaround for this. Setting the context path to /ROOT. Then after Tomcat starts, you can visit it at http://localhost:8080/

I will add support for the empty context path later.

yuezk commented 2 years ago

Fixed in 4.3.6