tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johan Compagner <jcompag...@servoy.com>
Subject Re: tomcat 8 depends on URL.setURLStreamHandlerFactory method
Date Thu, 02 Oct 2014 14:24:58 GMT
thx mark,

that seems to work, at least i do get further but i bomb into the next issue
that is in this code of StandardRoot

    protected void startInternal() throws LifecycleException {
        String docBase = context.getDocBase();

        File f = new File(docBase);
        if (!f.isAbsolute()) {
            f = new File(((Host)context.getParent()).getAppBaseFile(),
f.getName());
        }


The problem here is that docBase for us is not absolute, but is a relative,
(which is why there is a test there)
The problem is that f.getName() is used there. Because that only gives pack
the last part of the filename
So if the name was something like:

"dir1/dir2"

then only "dir2" is returned and of course appbase (which is mostly
tomcat\webapps) + "dir2" is not an actual dir

For us the doc base is: "../../plugins" so it ends up in "webapps\plugins"
which is not correct it needs to go 2 dirs up..

So the current code only works for a docbase that is a single name that has
to be in the appbase folder.
I think it would be better to just use the docBase string as is instead of
using f.getName(), but there could be a reason that tomcat needs this ?

Johan


On 1 October 2014 20:44, Mark Thomas <markt@apache.org> wrote:

> On 01/10/2014 16:59, Johan Compagner wrote:
> > Hi,
> >
> > we have tomcat completely as an OSGI plugin project:
> >
> >
> https://github.com/Servoy/servoy-eclipse-tomcat/tree/master/org.apache.tomcat
> >
> > so that we can start it from our eclipse application and also dynamically
> > add servlets and filters from all kinds of plugins (so everything is osgi
> > based)
> >
> > Our app uses websockets quite heavily so  i thought lets update now to
> the
> > latest 8 that has a lot of improvements in this area.
> >
> > Problem is that in StandardRoot
> >
> >
> https://apache.googlesource.com/tomcat/+/defeda9492a54194ea56e4a8220069608a7aa8f0/java/org/apache/catalina/webresources/StandardRoot.java
> >
> > there is a line:
> >
> > TomcatURLStreamHandlerFactory.register();
> >
> > in the internalInit
> >
> > this tries to call URL.setURLStreamHandlerFactory(this);
> > in the constructor of that TomcatURLStreamHandlerFactory class
> >
> > but this is in eclipse or i guess in an osgi environment not really
> possible
> > because that is already set so now it bombs out with "factory al ready
> set"
> > error
> >
> > Is there any workaround for this or is there any way to improve tomcat 8
> so
> > that it places nicer inside an osgi container like eclipse?
>
> You need to call the static disable() method before you start Tomcat.
> That will stop Tomcat trying to register the factory.
>
> If you want to be able to use WAR URLs (necessary to support web
> applications that are packaged as WARs and *not* unpacked) then you'll
> need to register the WarURLStreamHandler with whatever factory you have
> configured.
>
> Mark
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>


-- 
Johan Compagner
Servoy

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message