We help IT Professionals succeed at work.

maven bootclasspath append

rumi78 used Ask the Experts™
I have built socket provider factory library: net-socket-provider by maven.
How should I configure other module pom.xml dependencies to use net-socket-provider in compile and tests as bootclasspath/a:net-socket-provider-1.0.jar ?

When I configure dependency as system or compile I get:
java.lang.SecurityException: Prohibited package name: java.net
        at java.lang.ClassLoader.preDefineClass(ClassLoader.java:480)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:626)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)

at line:
        Socket.setSocketImplFactory(new MySocketFactory());

When I call by hand:
javac/java  -Xbootclasspath/a:net-socket-provider-1.0.jar ....
everything works correctly.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Mick BarryJava Developer
Top Expert 2010



Dear objects,

It is configuration for compile only.
BTW I don't want to change rt.jar I only want to append my jar to bootclasspath (MySocketFactory is in java.net package)

What about tests ? How to configure bootclasspath to run tests by maven ?

Any reason why your factory needs to be in the java.net package?  It would make more sense to package that in your own package so it does not appear to be part of the java system API.  That should also eliminate the "Prohibited package name" exception.
Java Developer
Top Expert 2010
depends how you are running your tests, foir example surfire provides options you could use to pass option