embl-cba / fly-reg

BSD 2-Clause "Simplified" License
0 stars 1 forks source link

Tests fail due to incompatible IJ class #6

Open tischi opened 3 years ago

tischi commented 3 years ago

@imagejan

Thanks a lot for the travisification!

After updating the parent pom (not sure I changed anything else that was important), I am now getting below error when running the tests. I also had them issue with some other repositories and it could be that this is specific to something on my computer and I was not able to fix that yet. Do you have an idea how to solve this?

at test.TestFlyEmbryoRegistration.runRegistrationTest(TestFlyEmbryoRegistration.java:64

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.<init>(Context.java:285)
    at org.scijava.Context.<init>(Context.java:234)
    at org.scijava.Context.<init>(Context.java:174)
    at org.scijava.Context.<init>(Context.java:160)
    at net.imagej.ImageJ.<init>(ImageJ.java:77)
    at test.TestFlyEmbryoRegistration.runRegistrationTest(TestFlyEmbryoRegistration.java:64)
    at test.TestFlyEmbryoRegistration.test0(TestFlyEmbryoRegistration.java:52)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: java.lang.ExceptionInInitializerError
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at java.lang.Class.newInstance(Class.java:442)
    at org.scijava.service.ServiceHelper.createServiceRecursively(ServiceHelper.java:300)
    at org.scijava.service.ServiceHelper.createExactService(ServiceHelper.java:267)
    ... 35 more
Caused by: java.lang.RuntimeException: Found incompatible ij.IJ class
    at net.imagej.patcher.LegacyEnvironment.initialize(LegacyEnvironment.java:112)
    at net.imagej.patcher.LegacyEnvironment.applyPatches(LegacyEnvironment.java:494)
    at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:395)
    at net.imagej.patcher.LegacyInjector.preinit(LegacyInjector.java:374)
    at net.imagej.legacy.LegacyService.<clinit>(LegacyService.java:141)
    ... 42 more
imagejan commented 3 years ago

@tischi wrote:

I also had them issue with some other repositories and it could be that this is specific to something on my computer and I was not able to fix that yet.

Yes, it looks like that's your local issue, as the tests pass on CI. Did you try to run mvn clean install from the command line? (Never trust any IDE to run your Maven build completely clean! 😉)

tischi commented 3 years ago

Does that mean that the repo is now available in scijava maven even though the tests failed locally?

It also happens with mvn clean install:

[ERROR] test0(test.TestFlyEmbryoRegistration)  Time elapsed: 1.616 s  <<< ERROR!
java.lang.IllegalArgumentException: Invalid service: net.imagej.legacy.LegacyService
        at test.TestFlyEmbryoRegistration.runRegistrationTest(TestFlyEmbryoRegistration.java:64)
        at test.TestFlyEmbryoRegistration.test0(TestFlyEmbryoRegistration.java:52)
Caused by: java.lang.ExceptionInInitializerError
        at test.TestFlyEmbryoRegistration.runRegistrationTest(TestFlyEmbryoRegistration.java:64)
        at test.TestFlyEmbryoRegistration.test0(TestFlyEmbryoRegistration.java:52)
Caused by: java.lang.RuntimeException: Found incompatibl

Any ideas?

imagejan commented 3 years ago

Does that mean that the repo is now available in scijava maven even though the tests failed locally?

Please check for yourself: https://maven.scijava.org/#nexus-search;quick~fly-reg

You won't be able to run release-version.sh before fixing your local issues though...

Any ideas?

Not currently. There have been a few mentions of Invalid service: net.imagej.legacy.LegacyService in various contexts (on the forum and elsewhere), but I think those were different issues. Please try deleting your maven directory (~/.m2/) and running maven again, I suppose you might have a system with a lot of locally installed Maven artifacts, and if you messed up with the uniqueness of release versions (or have a SNAPSHOT dependency), this might screw up the build...

tischi commented 3 years ago

Please check for yourself: https://maven.scijava.org/#nexus-search;quick~fly-reg

Ok, it only uploaded the SNAPSHOT version, probably because of the failed tests...

Please try deleting your maven directory (~/.m2/) and running maven again

I deleted .m2 but it did not solve the issue. Any other ideas?

imagejan commented 3 years ago

it only uploaded the SNAPSHOT version, probably because of the failed tests...

no, it uploaded SNAPSHOT because that's what your master branch has (and should have). There are no failed tests on the CI build.

The release-version.sh script would create a new tag that's deployed as RELEASE version, but as the script will also run a local mvn build first, you'll have to make sure mvn doesn't fail on your local system.

Sorry, no other ideas at the moment, please ask on the forum.

tischi commented 3 years ago

Solved for now by commenting out the @Test annotations and running the tests manually.

imagejan commented 3 years ago

Solved for now by commenting out the @Test annotations

You can also add an @Ignore annotation in that case.