Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] tag libraries in container

Thanks Jan!

I now see:

2016-05-10 17:54:15 DEBUG o.e.j.a.AnnotationConfiguration:570 - Scanned 155 container path jars, 4 WEB-INF/lib jars, 1 WEB-INF/classes dirs in 8779ms for context o.e.j.w.WebAppContext@39ace1a7{/main,file:///path/to/work/main/webapp/,STARTING}{/path/to/web/main.war}

So apparently Jetty doesn't support using partial wildcards like -cp /my/path/*:/my/path/log4j-*.jar:(...) , which is ok, it may not be a valid syntax, not sure.

It also breaks if we specify a jar that doesn't exists, maybe a warning would be ok.

java.io.FileNotFoundException: /path/to/lib/mail.jar (No such file or directory)
        at java.util.zip.ZipFile.open(Native Method) ~[?:1.8.0_91]
        at java.util.zip.ZipFile.<init>(ZipFile.java:219) ~[?:1.8.0_91]
        at java.util.zip.ZipFile.<init>(ZipFile.java:149) ~[?:1.8.0_91]
        at java.util.jar.JarFile.<init>(JarFile.java:166) ~[?:1.8.0_91]
        at java.util.jar.JarFile.<init>(JarFile.java:103) ~[?:1.8.0_91]
        at sun.net.www.protocol.jar.URLJarFile.<init>(URLJarFile.java:93) ~[?:1.8.0_91]
        at sun.net.www.protocol.jar.URLJarFile.getJarFile(URLJarFile.java:69) ~[?:1.8.0_91]
        at sun.net.www.protocol.jar.JarFileFactory.get(JarFileFactory.java:84) ~[?:1.8.0_91]
        at sun.net.www.protocol.jar.JarURLConnection.connect(JarURLConnection.java:122) ~[?:1.8.0_91]
        at sun.net.www.protocol.jar.JarURLConnection.getJarFile(JarURLConnection.java:89) ~[?:1.8.0_91]
        at org.eclipse.jetty.webapp.MetaInfConfiguration.getTlds(MetaInfConfiguration.java:408) ~[jetty-webapp-9.3.8.v20160314.jar:9.3.8.v20160314]
        at org.eclipse.jetty.webapp.MetaInfConfiguration.scanForTlds(MetaInfConfiguration.java:326) ~[jetty-webapp-9.3.8.v20160314.jar:9.3.8.v20160314]

Anyways, all good now, thanks a lot
Ben



On Tue, May 10, 2016 at 5:12 PM, Jan Bartel <janb@xxxxxxxxxxx> wrote:
Benjamin,

You've distracted me with the AnnotationConfiguration :)  That's not what you want to be looking at for finding the tlds. That is controlled by the MetaInfConfiguration based on jar names that are matched in WebInfConfiguration from the containerIncludeJarPattern.  Do a server.setDumpAfterStart(true) and you should see what your classloader hierarchy and jetty setup looks like.

Jan

On 11 May 2016 at 09:56, Benjamin Jaton <benjamin.jaton@xxxxxxxxx> wrote:
I do have the jar in the classpath: java -cp (...) my.custom.WebServer

It finds my own classes and more properly so I'm pretty sure that the jar itself is in the classpath (I see it when I run the 'ps' command, and the path resolves correctly).

I use this now to rule out any syntax issue:
webAppContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",   ".*\\.jar$");
webAppContext.setAttribute("org.eclipse.jetty.server.webapp.WebInfIncludeJarPattern", ".*\\.jar$");

And I still see that message:

2016-05-10 16:46:01 DEBUG o.e.j.a.AnnotationConfiguration:570 - Scanned 0 container path jars, 4 WEB-INF/lib jars, 1 WEB-INF/classes dirs in 279ms for context o.e.j.w.WebAppContext@2e3b4394{/main,file:///path/to/work/main/webapp/,STARTING}{/path/to/web/main.war}

Thanks,
Ben


On Tue, May 10, 2016 at 4:37 PM, Jan Bartel <janb@xxxxxxxxxxx> wrote:
Benjamin,

You need to put whatever jars you want to use that are external to the webapp explicitly onto the classpath for your embedded runtime - we look at the classloader parent of the webapp to find container jars for name matching and thus annotation scanning etc.

 Also probably best to double escape the "." in ".jar" in a java string so its "\\.jar"

Jan



On 11 May 2016 at 09:25, Benjamin Jaton <benjamin.jaton@xxxxxxxxx> wrote:
Did I mention that I was using an embedded Jetty? I am not using start.jar, and I don't have a real "jetty.home" for Jetty.

I did set manually jetty.base though:
        System.setProperty("jetty.home", "/path/to/folder/");
        System.setProperty("jetty.base", "/path/to/folder/");

Those libs are also used by other applications, so I'd rather not have them in a folder that is specific to jetty.
Can I specify container libs without / outside a jetty base?



On Tue, May 10, 2016 at 4:14 PM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
The technique you want ...

First: setup a proper ${jetty.base}
Second: don't ever modify/change/edit/delete/rename any content in ${jetty.home}
Third: keep the directories separate, not nested within each other.

If you want arbitrary libs to exist in the server classpath, enable the "ext" module for your ${jetty.base} and put them in your ${jetty.base}/lib/ext/ directory.

Test if you have the server classpath setup correctly by ...

$ cd /path/to/my/jettybase
$ java -jar /path/to/my/jettyhome/start.jar --list-config



Joakim Erdfelt / joakim@xxxxxxxxxxx

On Tue, May 10, 2016 at 3:34 PM, Benjamin Jaton <benjamin.jaton@xxxxxxxxx> wrote:
Hello,

I have an existing embedded jetty and I would like to have the jstl-1.2.jar shared instead of having it inside each war.

So I am setting the jetty.home property to /path/to/folder/
and I put the jar in /path/to/folder/lib/web/jstl-1.2.jar

Then I set this:

webAppContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
                ".*/jstl-1.2.jar$");

https://www.eclipse.org/jetty/documentation/9.2.7.v20150116/configuring-webapps.html

However I still get this error in my logs:

org.apache.jasper.JasperException: /WEB-INF/jsp/login.jsp (line: 1, column: 1) The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application

I tried to use ".*/.*/jstl-1.2.jar" and the full path of the jar without success.
I tried to switch to DEBUG but I couldn't see anything about scanning the jars (just the o.e.j.a.AnnotationParser ones)

Any idea?

Thanks,
Ben

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
Expert assistance from the creators of Jetty and CometD


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
Expert assistance from the creators of Jetty and CometD


_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top