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

Osgi-Version #36

Closed
JanLoebel opened this issue May 28, 2013 · 8 comments
Closed

Osgi-Version #36

JanLoebel opened this issue May 28, 2013 · 8 comments

Comments

@JanLoebel
Copy link

Hey there,

i tried to use wiremock in my osgi-runtime wit pax-exam. But i was not able to get it running. At many tries i got this exception:

java.lang.IllegalAccessError: tried to access method org.apache.commons.logging.LogFactory.<init>()V from class org.apache.commons.logging.impl.SLF4JLogFactory
    at org.apache.commons.logging.impl.SLF4JLogFactory.<init>(SLF4JLogFactory.java:66)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at java.lang.Class.newInstance0(Unknown Source)
    at java.lang.Class.newInstance(Unknown Source)
    at wiremock.org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:1160)
    at wiremock.org.apache.commons.logging.LogFactory$2.run(LogFactory.java:1065)
    at java.security.AccessController.doPrivileged(Native Method)
    at wiremock.org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:1062)
    at wiremock.org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:569)
    at wiremock.org.apache.commons.logging.LogFactory.getLog(LogFactory.java:685)
    at wiremock.org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:73)
    at wiremock.org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:99)
    at wiremock.org.apache.http.impl.conn.PoolingClientConnectionManager.<init>(PoolingClientConnectionManager.java:85)
    at com.github.tomakehurst.wiremock.http.HttpClientFactory.createClientConnectionManagerWithSSLSettings(HttpClientFactory.java:85)
    at com.github.tomakehurst.wiremock.http.HttpClientFactory.createClient(HttpClientFactory.java:53)
    at com.github.tomakehurst.wiremock.http.HttpClientFactory.createClient(HttpClientFactory.java:69)
    at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.<init>(ProxyResponseRenderer.java:50)
    at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:80)
    at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:129)
    at com.bosch.sh.devicedriver.itest.WireMockSampleTest.testThis(WireMockSampleTest.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    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.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunner.runChild(ContainerTestRunner.java:67)
    at org.ops4j.pax.exam.invoker.junit.internal.ContainerTestRunner.runChild(ContainerTestRunner.java:37)
    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.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:138)
    at org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.invokeViaJUnit(JUnitProbeInvoker.java:111)
    at org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.findAndInvoke(JUnitProbeInvoker.java:84)
    at org.ops4j.pax.exam.invoker.junit.internal.JUnitProbeInvoker.call(JUnitProbeInvoker.java:72)
    at org.ops4j.pax.exam.nat.internal.NativeTestContainer.call(NativeTestContainer.java:106)
    at org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactor.invoke(AllConfinedStagedReactor.java:84)
    at org.ops4j.pax.exam.junit.PaxExam$2.evaluate(PaxExam.java:294)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.ops4j.pax.exam.junit.PaxExam.run(PaxExam.java:111)
    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.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

or

javax.servlet.UnavailableException: Servlet class com.github.tomakehurst.wiremock.servlet.HandlerDispatchingServlet is not a javax.servlet.Servlet

Has anyone tried to get WireMock running in an OSGi-Environment?

@tomakehurst
Copy link
Member

This is the first time I've heard of anyone trying to run it inside an OSGi container.

Are you using the standalone JAR (via the standalone classifier in the dependency) or the standard one?

@JanLoebel
Copy link
Author

I've tried both, but couldn't find a difference between the exceptions.

@tomakehurst
Copy link
Member

My best suggestion would be to try and match the commons-logging version you're deploying with your container with the version used by Apache HTTP Client 4, which I believe is version 1.1.1.

@bmuskalla
Copy link

Jan, Tom, I'm currently running Wiremock in an OSGi environment but included as a lib on the bundles classpath and not as a bundle on its own. The error you're getting might be related to the isolated classloaders. How do you deploy wiremock within pax exam right now?

Tom, I'd like to actually consume Wiremock as an OSGi bundle. Happy to provide a pull request to generate the necessary bits (MANIFEST.MF) as part of the gradle build.

@tomakehurst
Copy link
Member

I'd be happy to receive a pull request for this. I barely used OSGi, so it be good to get a patch from someone with some experience with it.

@JanLoebel
Copy link
Author

I tried different ways to bundle and deploy it to OSGi via PaxExam.

Verison 1:

public Option[] config() {
    return options( systemProperty( "pax.exam.osgi.unresolved.fail" ).value( "true" ),
         systemProperty( "org.ops4j.pax.logging.DefaultServiceLog.level" ).value( "DEBUG" ),
         junitBundles(),
         wrappedBundle( maven( "com.github.tomakehurst", "wiremock" ).version( "1.30" ))
         // All other dependencies from wiremock... 
    );
}

Version 2:
In Version 2 i used the bundle-plugin from maven to inline all dependencies and export the needed packages. But it also failed with the same error.

I would also appreciate a pull-request!

@ChristophSchaal
Copy link

Hi, I have the same issue that @JanLoebel describes.

@bmuskalla: Can you post your solution (the MANIFEST.MF) in this issue or provide the pull request?

@tomakehurst
Copy link
Member

Closing due to inactivity.

shrutikumar15 pushed a commit to shrutikumar15/wiremock that referenced this issue Aug 13, 2023
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

4 participants