-
-
Notifications
You must be signed in to change notification settings - Fork 305
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
Reopen java.net.MalformedURLException in executable jar with OSGi Connect (Atomos) #6245
Comments
Found the problem and a fix. In aQuite.launcher.Launcher.java in lines 909..911 there is a check for JRT protocol
This check needs to be commented out like above or also allow "jar:" protocol (simple comment seems to work for both embedded and normal eclipse launch). The problem is that in embedded case the internal bundle location is just a path within the executable jar like /jar/bundle.jar without any protocol hence java.net.MalformedURLException: no protocol exception. Correct URL, however, is already generated in lines 905..906 as a resource URL
in the form jar:file:/executable.jar!/jar/bundle.jar, i.e. with correct protocol "jar:file:/". If you pass this as a location into context.installBundle(path) bundle jar is read from executable jar correctly. Now the problem is how to build biz.aQute.launcher-full,jar with modified file. Tried to add modified sources to my maven project, but got a whole bunch of missing dependencies and weird compilation errors (e.g. aQute.lib.collections.SortedList implements both List and SortedSet interfaces which have incompatible reversed() methods). I did not spend much time figuring this out and simply collected all dependencies, compiled modified Launcher.java and patched the existing jar. Everything worked after that. It would be nice if somebody explained how to correctly build biz.aQute.launcher.jar with correct Launcher and including aQute.bnd.build package without resorting to hacks and patches. Thanks in advance |
If I understood everything correctly, you have a customized Launcher and want to know how to use this launcher in your exported jar right? In that case you can simply copy the whole bnd launcher project, rename it a bit, do your fix and let bnd build it. Then you have to put the bundle with your launcher in it on the |
I will close the issue, given my comment above. If you have the feeling, that my answer is not what you wanted feel free to reopen this issue. |
OK, Obviously I was not clear of what I want.
Apparently aQute.bnd.build package must be included in the launcher jar as, apparently, it must be able to build connector before any other bundles are loaded.
In a meanwhile I'd also like you to explain to me how to build launcher jar from sources.
Second I've tried to copy the whole repo and run the same command from within biz.aQute.launcher folder. I've got the following output:
and generated biz.aQute.launcher.jar is empty. |
How do I reopen the issue? It looks like I am not allowed. |
Did you tried co checkout this project, fix as you expect and test if then still everything works, and then do a PR? |
As I've mentioned earlier, I don't know how to build the project. After the build the resulting jar is empty. I can try if you provide instructions on how to build. |
Have you tried the build instructions here? @novos40 |
@juergen-albert since we're talking about releasing, will you fix this or should we close this? |
Sorry, I did not have time to fix this. For my purposes the problem is actually bigger as, apparently, Atomos can't create new module layers unless it was itself loaded via module path. This means it must be specified in command line. This, in turn, makes it impossible to have a single config file where all bundles and modules are specified and discovered/loaded dynamically after JVM is already started. So I need a way to execute my custom config code to add discovered modules before connector (i.e. Atomos instance) is created/initialized. I don't see how it is possible with this implementation (unless you can educate me). I will likely modify EmbeddedLauncher to look for something like "Launcher-Config" to be able to specify a class with custom config logic to be executed before anything else. (Custom logic would include setting/modifying system properties and placing discovered modules into new module layers so they can be processed by Atomos) Thanks! |
You are aware of the experimental code that runs a connect framework? this requires
This is eons ago for me and and have no time to figure it out. Just wanted to be sure you knew that this experiment is still in the code. |
No, this is not the problem. Connector gets created and works just fine as long as launcher bundle exports all required packages (this was one of the problems: missing packages for connector creation in launcher jar). The problem is that I need to run custom code BEFORE connector is created and framework starts. After connector is initialized (obviously before framework start) there is little you can do to add new modules to JVM module path UNLESS connector (i.e. Atomos) was loaded via module path. At least this is the error it gives when you try to add module layers via Atomos API. Using --module-path or related option in command line immediately breaks compatibility with old environments still running java 8. They are not going to be updated any time soon as they are closed systems. I would like to have a fully automated system which can start via standard java -jar <my.jar> command line and then discover and properly initialize its own environment whether it is java 8 or 21+ and whether modules are used or not. It is a developing situation because the main reason to use modules is to be able to run python code in java via graalvm. GraalVm team also makes progress, but currently they seem to only support running guest languages via module system. I think they mark it as a bug after my request, but it's not high priority and I'd like to have this capability anyway as I can't really expect anyone to support both module-bases and legacy-based JVMs. |
Found an old issue (java.net.MalformedURLException in executable jar with OSGi Connect (Atomos)) which was closed without positive solution, I guess. Now I have the same problem in the same situation:
Everything works from eclipse. Executable jar fails with the above exception. Here is the content of .bndrun file:
As you can see I have
so launcher can start framework with connector. I had to repackage biz.aQute.launcher into biz.aQute.launcher-full to include aQute.bnd.build package which seem to be required to build the connector. With default launcher I'm getting the following error at startup:
It does work eventially even with this error due to framework refresh at some point (so bundles get rewired), I guess, but I can't stand having exception as a first thing in the log.
The whole excersise is to allow running python code in OSGi environment via graalvm polyglot. With graal v23.1.1 I used to just build polyglot bundle and disable classpath isolation, but with the latest v24.0.2 polyglot only works from module path hence the necessity to use atomos. It works nicely when run from eclipse.
Now how do I make it work from executable jar? What am I doing wrong here?
The text was updated successfully, but these errors were encountered: