JavaMemoryCompiler.Compilation.Exception: "package xxx does not exist" #31
-
Hi, I am using your library (v12.63.0) to generate class at runtime in a Maven project. I followed your example generating classes at runtime and invoking their methods with and without the use of reflection. I am using spring-boot 2.7.15 and a bunch of libraries. The main goal is to run on WebSphere web server but, I met a problem with compile the runtime generate d’s class when execute the fatjar application or exec the docker container. Code :
Exception:
The package it.x.y.z is the application itself. Then I divided the main module in 2 modules, one contains the business logic and the other one contains classes that are used in the previous one. In the main module, which there is burning wave core, have a dependency with the second module, so that when package the application, classes are under /WEB-INF. In this case burningwave can found the classes. I tried to do that :
But nothing, same problems, JavaMemoryCompiler can’t found all ClassPath. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Could you try to use the |
Beta Was this translation helpful? Give feedback.
-
Hi, these classes are inside the classpath of the application (websphere) , there is any chance that i can import classes without add these in literal way? These classes are not external, I made it external trying to solve the problem and added to classPath of buringwave compiler. |
Beta Was this translation helpful? Give feedback.
-
It is not possible to detect all classpaths of all classloaders in the world. However, if you only need these classes of dependency for compilation and your classloader detects them you don't have to worry: after compilation when loading the compiled class, already loaded classes will not be loaded twice by your classloader. Remeber also that the ... Also the method If you don't want to use absolute path to load the classpaths you can use relative paths and let the PathHelper resolve them: take a look here the using of the method getAbsolutePathOfResource. |
Beta Was this translation helpful? Give feedback.
It is not possible to detect all classpaths of all classloaders in the world. However, if you only need these classes of dependency for compilation and your classloader detects them you don't have to worry: after compilation when loading the compiled class, already loaded classes will not be loaded twice by your classloader.
Remeber also that the
addClassRepository
method works also on.war
and.ear
archive and will automatically detect classpaths, so you just need to pass it the paths to these files.... Also the method
addClassPaths
works on.war
and.ear
files but you must indicate the base folder of your classes in the.war
and.ear
files, e.g.: "../../your-war-application.war/WEB-INF…