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

static initializer of AnalyzerGuru causing hard to detect deployment problems #2027

Open
vladak opened this issue Feb 26, 2018 · 2 comments · May be fixed by #2660
Open

static initializer of AnalyzerGuru causing hard to detect deployment problems #2027

vladak opened this issue Feb 26, 2018 · 2 comments · May be fixed by #2660
Labels
bug webapp web application

Comments

@vladak
Copy link
Member

vladak commented Feb 26, 2018

After not using my mac mini workstation (running macOS 10.13.3) for a while to run OpenGrok, I decided to give it a try and do a mini project in Netbeans. To my dismay, the webapp could not be loaded. It deployed fine however then got an exception when rendering the index page:

26-Feb-2018 16:33:31.202 SEVERE [190] org.apache.catalina.core.StandardHostValve.custom Exception Processing ErrorPage[errorCode=500, location=/error]
 org.apache.jasper.JasperException: An exception occurred processing JSP page /menu.jspf at line 201

198:                 String selection = queryParams.getType();
199:                 %>
200:                 <option value="">Any</option><%
201:                 for (Map.Entry<String, String> d : SearchHelper.getFileTypeDescriptions()) {
202:                     %>
203:                 <option value="<%= Util.formQuoteEscape(d.getKey()) %>"<%
204:                     if (d.getKey().equals(selection)) {


Stacktrace:
	at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:579)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:461)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
	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.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:716)
	at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:468)
	at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:391)
	at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:318)
	at org.apache.catalina.core.StandardHostValve.custom(StandardHostValve.java:442)
	at org.apache.catalina.core.StandardHostValve.status(StandardHostValve.java:301)
	at org.apache.catalina.core.StandardHostValve.throwable(StandardHostValve.java:396)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:176)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
	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: javax.servlet.ServletException: java.lang.NoClassDefFoundError: Could not initialize class org.opensolaris.opengrok.analysis.AnalyzerGuru
	at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:909)
	at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:838)
	at org.apache.jsp.error_jsp._jspService(error_jsp.java:667)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
	at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
	... 25 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.opensolaris.opengrok.analysis.AnalyzerGuru
	at org.opensolaris.opengrok.web.SearchHelper.getFileTypeDescriptions(SearchHelper.java:217)
	at org.apache.jsp.error_jsp._jspService(error_jsp.java:532)
	... 28 more

According to https://stackoverflow.com/questions/7325579/java-lang-noclassdeffounderror-could-not-initialize-class-xxx this is caused by code in the static initializer. Indeed, AnalyzerGuru has lots of stuff that can fail in there. I added try/catch block with logging+rethrow there however could not see it anywhere (like https://stackoverflow.com/questions/19999590/tomcat-6-error-in-static-initialiser-is-hidden-by-noclassdeffounderror?noredirect=1&lq=1).

Next, I constructed trivial test case to call AnalyzerGuru.getfileTypeDescriptions() to see if the problem surfaces there however to no avail.

Next, I commented out most of the stuff in the analyzers array and the problem disappeared however after uncommenting them again I cannot reproduce it anymore so either it is transient or depends on other external factors or there has to be some JVM/Tomcat/Netbeans dance performed to refresh the war file (I dutifuly did full rebuild, restart, redeploy each time).

@vladak vladak added the bug label Feb 26, 2018
vladak pushed a commit to vladak/OpenGrok that referenced this issue Feb 26, 2018
@idodeclare
Copy link
Contributor

I have a PR queued up: "Refactor AnalyzerGuru, HistoryGuru as non-singleton" (370bfa3), that addresses this. It's eighth after the current PR #2017.

@vladak
Copy link
Member Author

vladak commented Feb 26, 2018 via email

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

Successfully merging a pull request may close this issue.

2 participants