Pierre Bourret created FELIX-5007:
-------------------------------------

             Summary: Manipulator error : "Prohibited package name: java.io" 
when a maven dependency defines java.io.IOException
                 Key: FELIX-5007
                 URL: https://issues.apache.org/jira/browse/FELIX-5007
             Project: Felix
          Issue Type: Bug
          Components: iPOJO
    Affects Versions: ipojo-manipulator-1.12.1
         Environment: OS name: "linux", version: "3.13.0-62-generic", arch: 
"amd64", family: "unix"
Java version: 1.8.0_60, vendor: Oracle Corporation
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 
2015-04-22T13:57:37+02:00)
            Reporter: Pierre Bourret
            Priority: Minor


While building a project with many sub-modules, the maven-ipojo-plugin fails 
and gives me this error:

{noformat}
[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
{noformat}

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 
{color:red}{{SecurityException: Prohibited package name: java.io}}{color}
- 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?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to