Hi Devs,

I've a use case where, embed Felix instance needed to be started from a
servlet. I wrote the the code  and tried to initialize embed Felix  from the
servelt using load-on-startup. I happen to receive the following exception,

java.lang.Error: factory already defined
        at java.net.URL.setURLStreamHandlerFactory(URL.java:1074)
        at org.apache.felix.framework.URLHandlers.<init>(URLHandlers.java
:95)
        at org.apache.felix.framework.URLHandlers.registerInstance(
URLHandlers.java:299)
        at org.apache.felix.framework.URLHandlersActivator.start(
URLHandlersActivator.java:60)
        at org.apache.felix.framework.util.SecureAction.startActivator(
SecureAction.java:589)
        at org.apache.felix.framework.Felix$SystemBundleActivator.start(
Felix.java:3771)
        at org.apache.felix.framework.util.SecureAction.startActivator(
SecureAction.java:589)


Thus, the problem lies with URLHandlers.java:95, where it does the
URL.setURLStreamHandlerFactory(this);

When my servlet engine started (Tomcat), it also set the "factory" (which is
beyond my control) in
java.net.URLConnection.

Thus, calling URL.setURLStreamHandlerFactory(this) ; from URLHandlers.java:95
caused "the factory already defined" error.

Is there a workaround to solve this problem from Felix.

Thank you

Saminda
 --
Saminda Abeyruwan

Senior Software Engineer
WSO2 Inc. - www.wso2.org

Reply via email to