You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by Saminda Abeyruwan <sa...@gmail.com> on 2008/03/03 18:35:24 UTC
Starting embed Felix inside a servlet.
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
Re: Starting embed Felix inside a servlet.
Posted by Alin Dreghiciu <ad...@gmail.com>.
Hi Saminda,
Maybe this will inspire you:
https://scm.ops4j.org/repos/ops4j/projects/pax/runner/pax-runner-handler/src/main/java/org/ops4j/pax/runner/handler/internal/
I do not know your time frame about starting Felix from a servlet, but
we have have plans to support this in Pax Runner:
http://issues.ops4j.org/jira/browse/PAXRUNNER-91
Yet I did not do that since there was not to much interest in it.
Cheers,
Alin
On Tue, Mar 4, 2008 at 1:35 AM, Saminda Abeyruwan <sa...@gmail.com> wrote:
> 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
>
Re: Starting embed Felix inside a servlet.
Posted by Karl Pauls <ka...@gmail.com>.
you can set
felix.service.urlhandlers=false
regards,
Karl
On Mon, Mar 3, 2008 at 6:35 PM, Saminda Abeyruwan <sa...@gmail.com> wrote:
> 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
>
--
Karl Pauls
karlpauls@gmail.com
Re: Starting embed Felix inside a servlet.
Posted by Saminda Abeyruwan <sa...@gmail.com>.
Tomcat will set
org.apache.naming.resources.DirContextURLStreamHandlerFactory to "factory"
instance variable of ava.net.URLConnection
Thank you
Saminda
On Mon, Mar 3, 2008 at 11:05 PM, Saminda Abeyruwan <sa...@gmail.com>
wrote:
>
> 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
--
Saminda Abeyruwan
Senior Software Engineer
WSO2 Inc. - www.wso2.org