Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

SoftAssertions don't work in OSGi environment #32

Closed
nickstolwijk opened this issue Mar 15, 2016 · 4 comments
Closed

SoftAssertions don't work in OSGi environment #32

nickstolwijk opened this issue Mar 15, 2016 · 4 comments

Comments

@nickstolwijk
Copy link

We are trying to add SoftAssertions to our code, but when we run with Maven Tycho Plugin we have a problem with the OSGi MANIFEST of AssertJ Core (2.x.x). We are not ready yet to try out AssertJ 3.x, so I don't know if the problem exists there too.

I am missing access to at least the following classes:

org.assertj.core.internal.cglib.proxy.Factory
org.assertj.core.internal.cglib.core.ReflectUtils

My stacktrace:
org.assertj.core.internal.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
at org.assertj.core.internal.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:237)
at org.assertj.core.internal.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
at org.assertj.core.internal.cglib.proxy.Enhancer.create(Enhancer.java:304)
at org.assertj.core.api.SoftProxies.create(SoftProxies.java:38)
at org.assertj.core.api.AbstractSoftAssertions.proxy(AbstractSoftAssertions.java:24)
...
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
at org.eclipse.pde.internal.junit.runtime.CoreTestApplication.run(CoreTestApplication.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.internal.app.EclipseAppContainer.callMethodWithException(EclipseAppContainer.java:587)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:198)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.assertj.core.internal.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:384)
at org.assertj.core.internal.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:219)
... 49 more
Caused by: java.lang.NoClassDefFoundError: org/assertj/core/internal/cglib/proxy/Factory
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
... 55 more
Caused by: java.lang.ClassNotFoundException: org.assertj.core.internal.cglib.proxy.Factory
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:513)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:429)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:417)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 57 more

@joel-costigliola
Copy link
Member

It's due to the repackaging of cglib in assertj-core (to avoid having dependencies) but the maven bnd plugin is not smart enough (or simply not configured) to export these.

@joel-costigliola
Copy link
Member

I have changed the way assertj-core manfifest is generated and it now exports the cglib repackaged classes. Hopefully that will solve this issue ( you will need to use assertj-core 2.4.0 or 3.4.0 when released).

@nickstolwijk If you could come with a way to reproduce this bug, I would be able to ensure it is indeed fixed.

@joel-costigliola
Copy link
Member

@nickstolwijk can you try again with assertj-core 2.4.0 or 3.4.0 that were released few days ago ?

@joel-costigliola
Copy link
Member

I'll gladly reopen this issue if it was not addressed in assertj-core 2/3.4.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants