ops4j / org.ops4j.pax.exam

Pax Exam is an in-container testing framework for OSGi
https://ops4j1.jira.com/wiki/spaces/PAXEXAM4/
Apache License 2.0
84 stars 99 forks source link

Forked container "no security manager: RMI class loader disabled" when remote container can not inject a service [PAXEXAM-493] #617

Open ops4j-issues opened 11 years ago

ops4j-issues commented 11 years ago

Christoph Läubrich created PAXEXAM-493

Consider the following test case:

@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class RemoteFailingTest {

    @Inject
    Runnable runnable;

    @Configuration
    public Option[] config() throws IOException {
        return options(junitBundles());
    }

    @Test
    public void myTest() {
        System.out.println("Called!");
    }
}

This fails with a "service not found in time" in the native container (as intended here) but fails with

java.lang.ClassNotFoundException: org.ops4j.pax.swissbox.framework.ServiceLookupException (no security manager: RMI class loader disabled)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:375)
    at sun.rmi.server.LoaderHandler.loadClass(LoaderHandler.java:165)
    at java.rmi.server.RMIClassLoader$2.loadClass(RMIClassLoader.java:620)
    at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247)
    at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197)
    at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1574)
    at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1495)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1731)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
    at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:225)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:142)
    at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:178)
    at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
    at $Proxy9.callService(Unknown Source)
    at org.ops4j.pax.exam.forked.ForkedTestContainer.call(ForkedTestContainer.java:97)
    at org.ops4j.pax.exam.spi.reactors.EagerSingleStagedReactor.invoke(EagerSingleStagedReactor.java:111)
    at org.ops4j.pax.exam.junit.JUnit4TestRunner$2.evaluate(JUnit4TestRunner.java:323)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
    at org.ops4j.pax.exam.junit.JUnit4TestRunner.run(JUnit4TestRunner.java:120)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
    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)

in the forked container (if the service is present it runs fine).

When searching for this the policy file is mentioned, but it does not seem to help tp specify one. I have tested this on a 3.1.0 but maybe other versions are affected as well.


Affects: 3.1.0 Fixed in: unscheduled Votes: 0, Watches: 3

ops4j-issues commented 11 years ago

Harald Wellmann commented

Can't reproduce on 3.0.x branch, see new test
itest/osgi/src/it/regression-multi/src/test/java/org/ops4j/pax/exam/regression/multi/depend/MissingServiceInvokerTest.java

Rescheduled to 3.1.0, needs to be tested on master.

ops4j-issues commented 11 years ago

G commented

Cristoph,

I am curious - Are you using Equinox? I ask because I am seeing "no security manager: RMI class loader disabled" errors with Equinox that I don't see with Felix. I am seeing them in a different product though (activemq web console).

ops4j-issues commented 11 years ago

Christoph Läubrich commented

Yes, I'm using equinox (3.7) and running the test directly from within eclipse without using maven.

ops4j-issues commented 11 years ago

G commented

How are you testing in Eclipse (PDE or Bndtools)? Can you drop back to equinox 3.6 (I didn't have a problem with Equinox 3.6) or try Felix instead? If you have the same experience as me, then it is some change in Equinox 3.7 and onwards causing the problem.

If it is an equinox problem I am surprised that I haven't seen more people reporting the same issue.

ops4j-issues commented 11 years ago

Christoph Läubrich commented

I'm using PDE, I might try this next time the error occurs.
> if it is an equinox problem I am surprised that I haven't
> seen more people reporting the same issue
it might because

I know another (not exam related) project also has issues when it comes to RMI and they are using a special policy file to circuvent this together with eclipse. I personally try to avoid the RMI stuff whenever possible :smile:

ops4j-issues commented 11 years ago

Raman Gupta commented

> Can you drop back to equinox 3.6 (I didn't have a problem with Equinox 3.6) or try Felix instead?

I had the same issue on Equinox 3.6 (using the Karaf Pax Exam container).

ops4j-issues commented 11 years ago

Harald Wellmann commented

Moving to "unscheduled" - don't see how to progress unless someone comes up with a minimal self-contained test to reproduce the problem.