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

Invalid service: net.imagej.legacy.LegacyService #104

Open
MurphyHou123 opened this issue Nov 24, 2023 · 1 comment
Open

Invalid service: net.imagej.legacy.LegacyService #104

MurphyHou123 opened this issue Nov 24, 2023 · 1 comment

Comments

@MurphyHou123
Copy link

It can't run with error for all demos:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid service: net.imagej.legacy.LegacyService
at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:278)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:229)
at org.scijava.service.ServiceHelper.loadService(ServiceHelper.java:192)
at org.scijava.service.ServiceHelper.loadServices(ServiceHelper.java:164)
at org.scijava.Context.(Context.java:285)
at org.scijava.Context.(Context.java:234)
at org.scijava.Context.(Context.java:174)
at org.scijava.Context.(Context.java:160)
at net.imagej.ImageJ.(ImageJ.java:75)
at SwingExample.main(SwingExample.java:20)
Caused by: java.lang.ExceptionInInitializerError
at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized0(Native Method)
at java.base/jdk.internal.misc.Unsafe.ensureClassInitialized(Unsafe.java:1160)
at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.ensureClassInitialized(MethodHandleAccessorFactory.java:300)
at java.base/jdk.internal.reflect.MethodHandleAccessorFactory.newConstructorAccessor(MethodHandleAccessorFactory.java:103)
at java.base/jdk.internal.reflect.ReflectionFactory.newConstructorAccessor(ReflectionFactory.java:200)
at java.base/java.lang.reflect.Constructor.acquireConstructorAccessor(Constructor.java:547)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:497)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:304)
at java.base/java.lang.Class.newInstance(Class.java:685)
at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:300)
at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:267)
... 9 more
Caused by: java.lang.RuntimeException: No _hooks field found in ij.IJ
It appears that this class was already defined in the class loader!
Please make sure that you initialize the LegacyService before using
any ImageJ 1.x class. You can do that by adding this static initializer:

static {
	LegacyInjector.preinit();
}

I tried to add LegacyInjector.preinit(); but still failed.

@sean-leichtle
Copy link

@MurphyHou123 Have you tried a 1.8 JDK?

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