Projects tigase _server tigase-http-api Issues #135
Setup not working (NPE because of missing JTE compiler) (#135)
Closed
wojciech.kapcia@tigase.net opened 5 months ago
[2024-04-12 18:02:06:930] [WARNING ] [    http-server-pool-3 ] JaxRsRequestHandler.execute()    : Exception while processing request
tigase.http.api.HttpException: java.lang.reflect.InvocationTargetException
	at tigase.http.jaxrs.JaxRsRequestHandler.execute(JaxRsRequestHandler.java:379)
	at tigase.http.jaxrs.JaxRsServlet.service(JaxRsServlet.java:100)
	at tigase.http.modules.setup.SetupServlet.service(SetupServlet.java:44)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
	at tigase.http.java.filters.DummyFilterChain.doFilter(DummyFilterChain.java:48)
	at tigase.http.java.filters.ProtocolRedirectFilter.doFilter(ProtocolRedirectFilter.java:69)
	at tigase.http.java.filters.DummyFilterChain.doFilter(DummyFilterChain.java:46)
	at tigase.http.java.RequestHandler.handle(RequestHandler.java:168)
	at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
	at jdk.httpserver/sun.net.httpserver.AuthFilter.doFilter(Unknown Source)
	at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
	at jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source)
	at jdk.httpserver/com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
	at jdk.httpserver/sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source)
	at tigase.http.java.JavaStandaloneHttpServer$ExecutorWithTimeout.lambda$0(JavaStandaloneHttpServer.java:208)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at tigase.http.jaxrs.JaxRsRequestHandler.execute(JaxRsRequestHandler.java:364)
	... 17 more
Caused by: java.lang.NullPointerException: Cannot invoke "javax.tools.JavaCompiler.run(java.io.InputStream, java.io.OutputStream, java.io.OutputStream, String[])" because "compiler" is null
	at gg.jte.compiler.java.JavaClassCompiler.runCompiler(JavaClassCompiler.java:46)
	at gg.jte.compiler.java.JavaClassCompiler.compile(JavaClassCompiler.java:38)
	at gg.jte.compiler.TemplateCompiler.precompileClasses(TemplateCompiler.java:114)
	at gg.jte.compiler.TemplateCompiler.precompile(TemplateCompiler.java:94)
	at gg.jte.compiler.TemplateCompiler.load(TemplateCompiler.java:50)
	at gg.jte.TemplateEngine.lambda$resolveTemplateOnDemand$0(TemplateEngine.java:354)
	at java.base/java.util.concurrent.ConcurrentHashMap.compute(Unknown Source)
	at gg.jte.TemplateEngine.resolveTemplateOnDemand(TemplateEngine.java:347)
	at gg.jte.TemplateEngine.resolveTemplate(TemplateEngine.java:337)
	at gg.jte.TemplateEngine.render(TemplateEngine.java:228)
	at tigase.http.modules.setup.pages.AboutSoftwarePage.displayAboutSoftware(AboutSoftwarePage.java:46)
	... 22 more

Version:

Loading component: http :: componentInfo{Title=Tigase HTTP API component, Version=2.4.0-SNAPSHOT-b450/d715168f-8.4.0-SNAPSHOT-b6347/2e4a6854, Class=tigase.http.HttpMessageReceiver}
Andrzej Wójcik (Tigase) commented 5 months ago

What version did you use? I've tested this and it worked fine for me... maybe there is some missing dependency in distribution package?

wojciech.kapcia@tigase.net commented 5 months ago

Latest nightly docker image

Andrzej Wójcik (Tigase) commented 5 months ago

I think I found the cause of the issue. Locally, for testing, I've used distribution package but with locally installed Java (that is JDK). In our container image we are installing JRE (not JDK) and due to that gg.jte is unable to find JavaCompiler using javax.tools.ToolProvider.

Just for reference - https://stackoverflow.com/questions/15513330/toolprovider-getsystemjavacompiler-returns-null-usable-with-only-jre-install

We have 2 solutions here:

  1. Use JDK in our image - simple to apply and rather easy to do, but I would prefer to not include full JDK if possible.
  2. Precompile JTE templates to Java classes during maven build - there is a maven plugin for that, and I think this would be good to distribution builds (not for development though)

I'll work on fixing the issue with precompiled JTE templates.

Referenced from commit 5 months ago
Andrzej Wójcik (Tigase) commented 5 months ago

This should fix the issue. Waiting for container image rebuild to verify the fix.

Andrzej Wójcik (Tigase) changed state to 'In Progress' 5 months ago
Previous Value Current Value
Open
In Progress
Andrzej Wójcik (Tigase) changed state to 'In QA' 5 months ago
Previous Value Current Value
In Progress
In QA
Andrzej Wójcik (Tigase) changed state to 'Closed' 5 months ago
Previous Value Current Value
In QA
Closed
Andrzej Wójcik (Tigase) commented 5 months ago

The issue is now fixed. I've verified it using new container image.

wojciech.kapcia@tigase.net changed fields 3 months ago
Name Previous Value Current Value
Version
empty
tigase-server-8.4.0
wojciech.kapcia@tigase.net added to iteration "tigase-server-8.4.0" 3 months ago
issue 1 of 1
Type
Bug
Priority
Normal
Assignee
Version
tigase-server-8.4.0
Target Release
1.0
Sprints
n/a
Customer
n/a
Iterations
Issue Votes (0)
Watchers (3)
Reference
tigase/_server/tigase-http-api#135
Please wait...
Page is in error, reload to recover