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

ClassNotFoundException in rdf4j-server using Docker image #4742

Closed
hugovanversendaal opened this issue Aug 9, 2023 · 9 comments · Fixed by #4814
Closed

ClassNotFoundException in rdf4j-server using Docker image #4742

hugovanversendaal opened this issue Aug 9, 2023 · 9 comments · Fixed by #4814
Assignees
Labels
🐞 bug issue is a bug
Milestone

Comments

@hugovanversendaal
Copy link

Current Behavior

Requests to /rdf4j-server result in an internal server error (500) when using the Docker image eclipse/rdf4j-workbench. The root cause is "java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config". Below is the server log:

localhost.2023-08-09.log

09-Aug-2023 09:09:51.634 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
09-Aug-2023 09:09:51.746 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: status display disabled
09-Aug-2023 09:09:51.766 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: loaded (conf ok)
09-Aug-2023 09:09:51.867 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring DispatcherServlet 'rdf4j-http-server'
09-Aug-2023 09:10:03.082 SEVERE [http-nio-8080-exec-3] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [rdf4j-http-server] in context with path [/rdf4j-server] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config] with root cause
	java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
		at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1420)
		at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1228)
		at org.springframework.web.servlet.support.JstlUtils.exposeLocalizationContext(JstlUtils.java:103)
		at org.springframework.web.servlet.view.JstlView.exposeHelpers(JstlView.java:137)
		at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:145)
		at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316)
		at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1405)
		at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1149)
		at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1088)
		at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964)
		at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
		at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
		at javax.servlet.http.HttpServlet.service(HttpServlet.java:489)
		at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
		at javax.servlet.http.HttpServlet.service(HttpServlet.java:583)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:212)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:156)
		at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:181)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:156)
		at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:115)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:181)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:156)
		at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
		at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
		at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
		at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:181)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:156)
		at com.github.ziplet.filter.compression.CompressingFilter.doFilter(CompressingFilter.java:263)
		at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:181)
		at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:156)
		at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
		at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
		at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:483)
		at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
		at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
		at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:682)
		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:617)
		at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
		at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:932)
		at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1694)
		at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
		at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
		at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
		at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
		at java.base/java.lang.Thread.run(Unknown Source)

Expected Behavior

Requests to /rdf4j-server do not result in an error.

Steps To Reproduce

  1. docker pull eclipse/rdf4j-workbench:4.3.5
  2. docker run -d -p 8080:8080 -e JAVA_OPTS="-Xms1g -Xmx4g" -v data:/var/rdf4j -v logs:/usr/local/tomcat/logs eclipse/rdf4j-workbench:4.3.5
  3. Open a webbrowser and go to http://localhost:8080/rdf4j-server or run curl -L http://localhost:8080/rdf4j-server

Version

4.3.5

Are you interested in contributing a solution yourself?

None

Anything else?

No response

@hugovanversendaal hugovanversendaal added the 🐞 bug issue is a bug label Aug 9, 2023
@github-project-automation github-project-automation bot moved this to 🆕 Triage in RDF4J Planning Aug 9, 2023
@abrokenjester
Copy link
Contributor

I have noticed this same problem affects RDF4J Server when deployed directly in Tomcat 9. The server starts, but its rendered pages do not work.

@abrokenjester
Copy link
Contributor

Possibly related to/caused by fixes for #4446 , which marked the javax.servlet jstl dependency as "provided".

@adamretter
Copy link

I just tested, and I can add that this affects the War files of all 4.3.x versions of rdf4j-server. I tested the following Docker images:

  • 4.3.7 - Error when opening localhost:8080/rdf4j-server: java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
  • 4.3.6 - Error when opening localhost:8080/rdf4j-server: java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
  • 4.3.5 - Error when opening localhost:8080/rdf4j-server: java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
  • 4.3.4 - Error when opening localhost:8080/rdf4j-server: java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
  • 4.3.2 - Startup error in catalina.log - Caused by: java.lang.NoClassDefFoundError: Lorg/apache/commons/logging/Log
  • 4.3.1 - No such docker image
  • 4.3.0 - No such docker image

I don't think this is a docker related issue, as I also confirmed that 4.3.7 has the same problem outside of Docker on Tomcat versions 8.5.95 and 9.0.82.

In summary, the latest working rdf4j-server appears to be: 4.2.3.

@hmottestad
Copy link
Contributor

Could be relevant:

I assume that the docker images don't add the jstl jar file.

@adamretter It should be possible to add the jstl jar file yourself to your own tomcat. Have you tried that?

@hmottestad
Copy link
Contributor

Adding the jstl jar file seems to have resolved the issue: #4814

@erikgb Could you give us some insight int0 why the jstl dependency in the pom.xml file is marked as provided? I know that tomcat with jakarta 10 should provide a tag lib implementation, but under a different uri. Since we are using the old sun uri then I'm not sure what we achieve by having the maven dependency marked as provided. I've only ever touched dedicated application servers while I was a student, and ever since then I've just used the integrated approach of spring-boot. Would the solution to the jstl issue be to have the maven dependency marked as compile? Or is it better to add the jstl jar file directly to the WEB-INF/lib directory as I've done in the PR above?

@erikgb
Copy link
Contributor

erikgb commented Oct 17, 2023

Adding the jstl jar file seems to have resolved the issue: #4814

@erikgb Could you give us some insight int0 why the jstl dependency in the pom.xml file is marked as provided? I know that tomcat with jakarta 10 should provide a tag lib implementation, but under a different uri. Since we are using the old sun uri then I'm not sure what we achieve by having the maven dependency marked as provided. I've only ever touched dedicated application servers while I was a student, and ever since then I've just used the integrated approach of spring-boot. Would the solution to the jstl issue be to have the maven dependency marked as compile? Or is it better to add the jstl jar file directly to the WEB-INF/lib directory as I've done in the PR above?

@hmottestad Thanks for the ping. The idea here is that all Java/Jakarta EE dependencies should be provided by the Java/Jakarta EE runtime. That's why I think it's correct to set the dependencies to scope=provided. That will avoid potential duplicate classes in the runtime classpath that could cause issues. But there might be some exceptions to this, especially in the "not commonly used" Java/Jakarta EE artifacts like JSTL. Anyway, I think it's correct to declare the dependencies as provided and add missing jar's to the application server runtime - if required to. Hope this clarifies my stand a bit.

@hmottestad
Copy link
Contributor

Thanks for the quick reply. I'll add the jar file then, like in the PR.

@hmottestad hmottestad mentioned this issue Oct 17, 2023
5 tasks
@hmottestad hmottestad added this to the 4.3.8 milestone Oct 17, 2023
@hmottestad hmottestad self-assigned this Oct 17, 2023
@adamretter
Copy link

@adamretter It should be possible to add the jstl jar file yourself to your own tomcat. Have you tried that?

I haven't tried that, and likely won't just yet as I switched down to using version 4.2.3. If there is a new release of rdf4j that fixes the issue, I would be happy to test it though.

@hugovanversendaal
Copy link
Author

hugovanversendaal commented Oct 18, 2023

I've added the jstl jar to my own Tomcat image in order to test the solution by inserting the following line to my Dockerfile:

ADD https://repo1.maven.org/maven2/javax/servlet/jstl/1.2/jstl-1.2.jar ${CATALINA_HOME}/webapps/rdf4j-server/WEB-INF/lib

I can confirm that this solves the issue (using version 4.3.7 now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants