Closed liucongvg closed 5 years ago
Huh, I thought java.nio.file.Paths
is part of core Java so it should be always present. And it seems you're running Java 8 so any modularization issues are not relevant.
When exactly does this happen ?
Possibly related to #2719. repository.tag
contains:
<%@ tag import="java.nio.file.Paths" %>
Huh, I thought
java.nio.file.Paths
is part of core Java so it should be always present. And it seems you're running Java 8 so any modularization issues are not relevant.When exactly does this happen ?
sudo cp source.war /var/lib/tomcat8/webapps/other_name.war
Maybe this have something to do with the war rename. and maybe I should try the rename with opengrok tools, but I encountered another problem #2810
I don't think the way the web app is deployed matters in this case. opengrok-deploy
just performs a copy of the file, modulo modification of configuration path within.
Is the exception is thrown on every page or just some ?
The problem might be in the parameters. The exception is 'method not found' rather than 'class not found'. Java 8 defines 2 get()
methods in https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html:
get(String first, String... more)
get(URI uri)
The first method signature is valid however - the elipsis can be omitted. That said, maybe you can try the suggestion from https://stackoverflow.com/questions/32202068/jmeter-static-method-get-java-lang-string-not-found-in-classjava-nio-file and manually edit repositories.tag
to call the Paths.get()
with varagrs parameter on the affected line (note there are 2 calls there actually):
https://github.com/oracle/opengrok/blob/86491e77f078708356b66a05cd1f7cfdd4e7dde9/opengrok-web/src/main/webapp/WEB-INF/tags/repository.tag#L45
The problem might be in the parameters. The exception is 'method not found' rather than 'class not found'. Java 8 defines 2
get()
methods in https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html:
get(String first, String... more)
get(URI uri)
The first method signature is valid however - the elipsis can be omitted. That said, maybe you can try the suggestion from https://stackoverflow.com/questions/32202068/jmeter-static-method-get-java-lang-string-not-found-in-classjava-nio-file and manually edit
repositories.tag
to call thePaths.get()
with varagrs parameter on the affected line (note there are 2 calls there actually): https://github.com/oracle/opengrok/blob/86491e77f078708356b66a05cd1f7cfdd4e7dde9/opengrok-web/src/main/webapp/WEB-INF/tags/repository.tag#L45
I tried before commit this issue, but failed, my solution is:
value="${Paths.get(URI.create(pageConfig.sourceRootPath)).relativize(Paths.get(URI.create(repositoryInfo.directoryName)))}"/>
but the new exception is:
There was an error!
org.apache.jasper.el.JspELException: /WEB-INF/tags/repository.tag(44,4) '${Paths.get(URI.create(pageConfig.sourceRootPath)).relativize(Paths.get(URI.create(repositoryInfo.directoryName)))}' java.lang.NullPointerException
javax.servlet.jsp.JspException: org.apache.jasper.el.JspELException: /WEB-INF/tags/repository.tag(44,4) '${Paths.get(URI.create(pageConfig.sourceRootPath)).relativize(Paths.get(URI.create(repositoryInfo.directoryName)))}' java.lang.NullPointerException
at org.apache.jsp.tag.web.repository_tag.doTag(repository_tag.java:270)
at org.apache.jsp.tag.web.repositories_tag._jspx_meth_opengrok_005frepository_005f0(repositories_tag.java:364)
at org.apache.jsp.tag.web.repositories_tag._jspx_meth_c_005fif_005f2(repositories_tag.java:331)
at org.apache.jsp.tag.web.repositories_tag._jspx_meth_c_005fforEach_005f1(repositories_tag.java:294)
at org.apache.jsp.tag.web.repositories_tag._jspx_meth_c_005fif_005f1(repositories_tag.java:257)
at org.apache.jsp.tag.web.repositories_tag._jspx_meth_c_005fforEach_005f0(repositories_tag.java:220)
at org.apache.jsp.tag.web.repositories_tag._jspx_meth_c_005fif_005f0(repositories_tag.java:185)
at org.apache.jsp.tag.web.repositories_tag.doTag(repositories_tag.java:144)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:843)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
......
@vladak This may have something to do with the project size which will be indexed. If I just index one of the subdirectory of my project, there is no exception. But if I index the whole project, the exception occurs, do you have any idea about this?
Seems unlikely to me. Either the method works or does not. Also, how do you index just a subdirectory ?
Can you try replacing the Paths.get()
calls with the second signature, i.e.:
value="${Paths.get(pageConfig.sourceRootPath, new String[0]).relativize(Paths.get(repositoryInfo.directoryName, new String[0]))}"/>
@vladak I'm encountering the same problem (using v1.2.13) and I did your substitution and now I have this error:
/WEB-INF/tags/repository.tag (line: 44, column: 4) "${Paths.get(pageConfig.sourceRootPath, new String[0]).relativize(Paths.get(repositoryInfo.directoryName, new String[0]))}" contains invalid expression(s): javax.el.ELException: Failed to parse the expression [${Paths.get(pageConfig.sourceRootPath, new String[0]).relativize(Paths.get(repositoryInfo.directoryName, new String[0]))}]
org.apache.jasper.JasperException: /WEB-INF/tags/repository.tag (line: 44, column: 4) "${Paths.get(pageConfig.sourceRootPath, new String[0]).relativize(Paths.get(repositoryInfo.directoryName, new String[0]))}" contains invalid expression(s): javax.el.ELException: Failed to parse the expression [${Paths.get(pageConfig.sourceRootPath, new String[0]).relativize(Paths.get(repositoryInfo.directoryName, new String[0]))}]
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:275)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:91)
at org.apache.jasper.compiler.Validator$ValidateVisitor.getJspAttribute(Validator.java:1422)
at org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:1231)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:879)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:898)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1853)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:217)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
at org.apache.jasper.servlet.JspServletWrapper.loadTagFile(JspServletWrapper.java:246)
at org.apache.jasper.compiler.TagFileProcessor.loadTagFile(TagFileProcessor.java:587)
at org.apache.jasper.compiler.TagFileProcessor.access$000(TagFileProcessor.java:50)
at org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:674)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:678)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:678)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:678)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:678)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:678)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.TagFileProcessor.loadTagFiles(TagFileProcessor.java:692)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:229)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
at org.apache.jasper.servlet.JspServletWrapper.loadTagFile(JspServletWrapper.java:246)
at org.apache.jasper.compiler.TagFileProcessor.loadTagFile(TagFileProcessor.java:587)
at org.apache.jasper.compiler.TagFileProcessor.access$000(TagFileProcessor.java:50)
at org.apache.jasper.compiler.TagFileProcessor$TagFileLoaderVisitor.visit(TagFileProcessor.java:674)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1536)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2452)
at org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:635)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
at org.apache.jasper.compiler.TagFileProcessor.loadTagFiles(TagFileProcessor.java:692)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:229)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:356)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:336)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:363)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:401)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:345)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.opengrok.web.StatisticsFilter.doFilter(StatisticsFilter.java:59)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.opengrok.web.AuthorizationFilter.doFilter(AuthorizationFilter.java:98)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
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)
Oh, the new String[0]
probably cannot be used in JSTL. Maybe we should just move the whole line to a static method in one of the already included classes.
Good job! You can make a static method of pageconfig - this class is always imported in the tags.
There seems to be some Tomcat configuration that makes such problems to be hidden, at least in my case - instead of reporting an exception, the resulting value is blank. I tried on a simple JSTL test code. Even totally non-existent methods within c:set
value are converted to blank. Once I moved the same code to a class, it worked just fine, so there is something about Paths
(or other Java core classes/methods) that makes them not directly usable in JSTL.
My exception is:
I run the following command to show my tomcat process
ps -aux | grep tomcat
the output is:And my os information is: Linux ubuntu 4.15.0-51-generic #55~16.04.1-Ubuntu SMP Thu May 16 09:24:37 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
And my opengrok version is: 1.2.9