Skip to content
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

Use classpath option #943

Closed
ghost opened this issue Jul 2, 2021 · 10 comments · Fixed by #2253
Closed

Use classpath option #943

ghost opened this issue Jul 2, 2021 · 10 comments · Fixed by #2253
Labels
status/stale No recently activity has been seen and will be closed soon.

Comments

@ghost
Copy link

ghost commented Jul 2, 2021

Hello, how can i use the -classpath option? Whenever i pass it to the server using JVM_OPTS, the server complains about the passing of a non existing 'j' option. This is probalby due to -jar getting appended to the end of the command. Is there a solution for this?

@itzg
Copy link
Owner

itzg commented Jul 2, 2021

That worked fine for me:

docker run -it -e EULA=TRUE -e JVM_OPTS="-classpath somewhere/" -e DEBUG_EXEC=true itzg/minecraft-server

from debug output:

+ exec mc-server-runner --stop-duration 60s java -Xms1G -Xmx1G -classpath somewhere/ -jar minecraft_server.1.17.jar

@ghost
Copy link
Author

ghost commented Jul 3, 2021

For the classpath option to work you need to give it the main class of your program, -jar and -classpath at the combined do not work

@itzg
Copy link
Owner

itzg commented Jul 3, 2021

Good point, they usually can't but so far Java 16 might be allowing it.

@itzg
Copy link
Owner

itzg commented Jul 3, 2021

Whenever i pass it to the server using JVM_OPTS, the server complains about the passing of a non existing 'j' option

What you're encountering is different than what used to happen when combining classpath and jar arguments. What exact docker run or compose file are you trying?

Also, I'm curious what why you're needing to add to the classpath. Maybe there's a different way to solve the original use case.

@ghost
Copy link
Author

ghost commented Jul 5, 2021

Hello, i need the classpath option in order to load additional libraries (e.g mongodb and redis drivers) for my plugins. I've solved it now by editing the the start-minecraftFinalSetup. But of course, that isn't ideal. My suggestion would be to add kind of a "RUN_COMMAND" environment variable or something similar so that other people who have a similar problem won't have to create fat jars.

@itzg
Copy link
Owner

itzg commented Jul 5, 2021

What does your modification look like? Also, what plugin(s) are you using? I'm wondering why they're not doing things like shading the client libraries in with their own plugin jar.

@ghost
Copy link
Author

ghost commented Jul 5, 2021

The plugins are our custom-made ones, I didn't shade the libraries because I found this to be a more maintainable way if one library needs an update, otherwise I would have to recompile every plugin. The modification is just a swap of - jar with -cp and the main class that comes after the classpath declaration at the end of the file where the start command is executed.

@itzg
Copy link
Owner

itzg commented Jul 5, 2021

While what you're asking is an easy change, I am not happy about adding it since the usability quickly gets challenging. Someone has to extract the META-INF/MANIFEST.MF to find the appropriate main class since it varies by server type, such as Paper's:

Manifest-Version: 1.0
Main-Class: io.papermc.paperclip.Paperclip
Multi-Release: true
Launcher-Agent-Class: io.papermc.paperclip.Agent
Premain-Class: io.papermc.paperclip.Agent

and even then launching with -cp paper-1.17-75.jar io.papermc.paperclip.Paperclip fails with

Unable to retrieve Instrumentation API to add Paper jar to classpath. If you're running paperclip without -jar then you also need to include the -javaagent:<paperclip_jar> JVM command line option.

Now I have to add the -javaagent arg. All of this is quite familiar to me since I have developed in Java for 25 years, but someone new to Docker/Java will be quickly overwhelmed.

I have never heard of a plugin/mod requiring -classpath customization since I'm guessing they all use URLClassLoader to dynamically load additional jars. Since this is your custom plugin, please investigate that approach.

You're also welcome to build an image that extends from this one.

I'll leave this issue open to think about it some more.

@ghost
Copy link
Author

ghost commented Jul 5, 2021

You're right, adding such an option would certainly drive up complexity, its probably a better option for everyone to just modify the start script as i did for one's own purposes.

@github-actions
Copy link

github-actions bot commented Nov 3, 2021

This issue is stale because it has been open 30 days with no activity. Please add a comment describing the reason to keep this issue open.

@github-actions github-actions bot added the status/stale No recently activity has been seen and will be closed soon. label Nov 3, 2021
@github-actions github-actions bot closed this as completed Nov 8, 2021
@itzg itzg reopened this Jun 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/stale No recently activity has been seen and will be closed soon.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant