I have an application running on Java 11 in Windows 10, and I have tried to turn it into a Windows service using yajsw 13.10.
My application attempts to load various plugins at startup using java.util.ServiceLoader.load(MyInterface.class)
. It also uses JPMS, so the services are defined in the module-info.java
files using uses MyInterface
and provides MyInterface with MyInterfaceImpl
.
When I run the application via yajsw (using runConsole.bat
), the application is started ok, but the service loader returns no implementations, hence the application ends up with no plugins.
The modules are defined in the wrapper.conf
file as
wrapper.java.app.module-path.1 = ./lib
wrapper.java.app.module-path.2 = ./plugins
...
I have debugged essentially the whole lifecycle, and can see that the modules are correctly found and are passed through to WrapperJVMMain9
, but somehow this isn't correctly flowing through to my application.
Just as extra information, I use an iterator to find the loaded services, and ServiceLoader.iterator()
creates an internal ModuleServicesLookupIterator
. In hasNext()
, this ends up calling ServicesCatalog.getServicesCatalogOrNull(ClassLoader)
, and this returns null. This seems to be the crux of the problem.
Hopefully this all makes sense!
Hello,
thanks for reporting the issue.
Could you pls provide some more details on how your application is built, or better a reproducer.
In the mean time I will try to reproduce the issue.
I assume that this may be a classloader issue.
-- ron
Hi Ron,
I've included a small maven-built application that reproduces the problem. You should be able to just run
mvn compile
in theexample-application
directory, then run it using the following command:If the application finds a plugin, which it should using the above command, it will output the plugin's name, then sleep for 60 seconds, simulating it doing something.
If no plugin is found (just remove the
plugin-impl
path), it'll indicate that, then exit immediately.I've included a
wrapper.conf
file in the root directory. Just replace the paths indicated, and userunConsole.bat
. It should print that no plugins were found, and exit immediately.Hope that helps.
Tim
thanks a ton for providing the reproducer.
i am currently very busy with other work.
i will get to it asap.
-- Ron
pls try the following:
remove:
add:
it works for me with the example.
-- Ron