I'm working on a java 8 backend providing a rest api that is built with its dependency (another project required for the first projects execution - let us call it Project B) in a war file which is deployed on a tomcat 8. This Project B uses the invokedynamic package that can be found here.
The execution of multiple methods throws an NoClassDefFoundError. A excerpt of the stack trace looks like this:
java.lang.NoClassDefFoundError: es/uniovi/reflection/invokedynamic/interfaces/Callable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
at es.uniovi.reflection.invokedynamic.codegen.InvokedynamicClassLoader.register(InvokedynamicClassLoader.java:36)
at es.uniovi.reflection.invokedynamic.codegen.ClassGenerator.getInstance(ClassGenerator.java:107)
at es.uniovi.reflection.invokedynamic.MemberBSClass.getInstance(MemberBSClass.java:83)
at es.uniovi.reflection.invokedynamic.MemberBSClass.getCallable(MemberBSClass.java:44)
at es.uniovi.reflection.invokedynamic.ProxyFactory.getInvokedynamicCallable(ProxyFactory.java:773)
at es.uniovi.reflection.invokedynamic.ProxyFactory.generateInvokeDynamicCallable(ProxyFactory.java:91)
The error causing class can be found here.
It is important to know that another project, using this Project B as a dependency too, runs locally without any trouble (not a web application and contains a simple main call). That is the reason why i think that the deployment or execution does not work properly or missed something but i couldn't figure out the actual problem.
My war file contains the "missing" class:
WEB-INF/classes/es/uniovi/reflection/invokedynamic/interfaces/Callable.class
Its overall structure of this file looks like the following:
- error
- some error files
- META-INF
- MANIFEST.MF
- WEB-INF
- classes
- de. ... -> the backend project
- es / uniovi ... -> dependency of Project B
- net. ... -> the dependent project
- lib
- spring
- web-dev.xml
- web.xml
Is it possible that the InvokedynamicClassLoader causes the problem and is not executable running inside a tomcat? The method is called in this way:
Class<T> c = (Class<T>) InvokedynamicClassLoader.getClassLoader().register(className, code);
where className outputs something like
es/uniovi/reflection/invokedynamic/Callable1
Thanks for any suggestion due to the fact that i'm pretty new to java.