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

Test ROBOT with GraalVM #915

Open
jamesaoverton opened this issue Oct 14, 2021 · 6 comments
Open

Test ROBOT with GraalVM #915

jamesaoverton opened this issue Oct 14, 2021 · 6 comments

Comments

@jamesaoverton
Copy link
Member

GraalVM includes a tool called native-image that can convert a Java JAR file to a platform-native binary that can be executed without needing a JVM installed. This could simplify the ROBOT installation instructions to just: download the binary for your platform. However there may be a performance hit.

@beckyjackson
Copy link
Contributor

This is cool! I was able to build an image and it runs fine, but I haven't tested performance against the JAR yet. That said, the image I built is not a standalone image and can only be run from within the ROBOT directory. We can build a standalone image using the --no-fallback option, but when I try to run this image, it fails:

Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError
	at org.apache.log4j.Category.class$(Category.java:118)
	at org.apache.log4j.Category.<clinit>(Category.java:118)
	at java.lang.Class.ensureInitialized(DynamicHub.java:552)
	at java.lang.Class.ensureInitialized(DynamicHub.java:552)
	at org.apache.log4j.LogManager.<clinit>(LogManager.java:82)
	at org.slf4j.impl.Log4jLoggerFactory.<init>(Log4jLoggerFactory.java:66)
	at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:72)
	at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:45)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
	at org.obolibrary.robot.CommandManager.<clinit>(CommandManager.java:19)
	at org.obolibrary.robot.CommandLineInterface.initManager(CommandLineInterface.java:21)
	at org.obolibrary.robot.CommandLineInterface.<clinit>(CommandLineInterface.java:13)
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Category
	at java.lang.Class.forName(DynamicHub.java:1433)
	at java.lang.Class.forName(DynamicHub.java:1408)
	... 16 more

Could somebody else try building an image using --no-fallback to see if this is something weird on my system, or if it's a problem with log4j?

@jamesaoverton
Copy link
Member Author

Thanks! Google has some results for graal slf4j. It seems to be a common problem, but I'm not sure what the right solution is. I guess I'd suggest trying to upgrade slf4j to 1.7.32 first.

@beckyjackson
Copy link
Contributor

beckyjackson commented Oct 21, 2021

Ah, I should have checked that first. Upgrading slf4j-log4j doesn't resolve the problem. It seems like it has something to do with this comment. The doc link that user provided no longer works, I think this is what he was trying to reference.

@beckyjackson
Copy link
Contributor

It looks like this issue was fixed in log4j-2.13.1 (org.apache.log4j.Logger). We're using org.slf4j.Logger. Should I try replacing all our loggers with org.apache.log4j.Logger and then trying native-image again?

@jamesaoverton
Copy link
Member Author

I guess it's worth a try. I think we used slf4j because OWLAPI does: https://github.com/owlcs/owlapi/blob/version5/pom.xml#L115

@beckyjackson
Copy link
Contributor

2.13.1 has another issue where org.apache.log4j.Category cannot be found. Since the original issue seems to have been introduced in 2.8, I tried using 2.7 and ran into the same problem. It looks like Category was deprecated a long time ago according to the docs. I can run ROBOT just fine from the JAR but the native image seems to want this Category class for some reason.

@beckyjackson beckyjackson removed their assignment May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants