Details
Description
While building a project with many sub-modules, the maven-ipojo-plugin fails and gives me this error:
[ERROR] Failed to execute goal org.apache.felix:maven-ipojo-plugin:1.12.1:ipojo-bundle (default) on project roboconf-dm-rest-services: Execution default of goal org.apache.felix:maven-ipojo-plugin:1.12.1:ipojo-bundle failed: java.lang.SecurityException: Prohibited package name: java.io -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.felix:maven-ipojo-plugin:1.12.1:ipojo-bundle (default) on project roboconf-dm-rest-services: Execution default of goal org.apache.felix:maven-ipojo-plugin:1.12.1:ipojo-bundle failed: java.lang.SecurityException: Prohibited package name: java.io at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286) at org.apache.maven.cli.MavenCli.main(MavenCli.java:197) 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:497) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.apache.felix:maven-ipojo-plugin:1.12.1:ipojo-bundle failed: java.lang.SecurityException: Prohibited package name: java.io at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 20 more Caused by: java.lang.RuntimeException: java.lang.SecurityException: Prohibited package name: java.io at org.apache.felix.ipojo.manipulation.ClassLoaderAwareClassWriter.getCommonSuperClass(ClassLoaderAwareClassWriter.java:74) at org.objectweb.asm.ClassWriter.a(Unknown Source) at org.objectweb.asm.Frame.a(Unknown Source) at org.objectweb.asm.Frame.a(Unknown Source) at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source) at org.objectweb.asm.MethodVisitor.visitMaxs(Unknown Source) at org.objectweb.asm.util.CheckMethodAdapter.visitMaxs(Unknown Source) at org.objectweb.asm.commons.LocalVariablesSorter.visitMaxs(Unknown Source) at org.objectweb.asm.ClassReader.a(Unknown Source) at org.objectweb.asm.ClassReader.b(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at org.objectweb.asm.ClassReader.accept(Unknown Source) at org.apache.felix.ipojo.manipulation.Manipulator.manipulate(Manipulator.java:135) at org.apache.felix.ipojo.manipulator.ManipulationEngine.generate(ManipulationEngine.java:142) at org.apache.felix.ipojo.manipulator.Pojoization.pojoization(Pojoization.java:381) at org.apache.felix.ipojo.manipulator.Pojoization.pojoization(Pojoization.java:243) at org.apache.felix.ipojo.plugin.ManipulatorMojo.execute(ManipulatorMojo.java:267) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) ... 21 more
The org.apache.felix.ipojo.manipulator.util.IsolatedClassLoader.loadClass(String) method seems to be the source of all my trouble. More precisely:
- findLoadedClass("java.io.IOException") (IsolatedClassLoader.java:61) returns null. So far so good
- findClass("java.io.IOException") (IsolatedClassLoader.java:67) throws a SecurityException: Prohibited package name: java.io
- This exception is not caught, and propagated until maven scrams...
Expected behaviour would rather be:
- findLoadedClass("java.io.IOException") (IsolatedClassLoader.java:61) returns null
- findClass("java.io.IOException") (IsolatedClassLoader.java:67) throws a ClassNotFoundException
- parent.loadClass("java.io.IOException") gets the class, which is then returned.
So the IsolatedClassLoader object tries to define the java.io.IOException, because the class is defined in an indirect dependency (in this case, org.apache.felix:org.osgi.foundation:1.2.0, brought by org.apache.felix:org.osgi.compendium:1.4.0).
While removing the faulty dependency should be effortless, shouldn't the manipulator be more user-error-friendly and delegate to the parent the loading of java.* classes?
The fix seems quick and painless. WDYT?