So to sum up:
An executable Jar using embedded Jetty to serve a Click app works in
this configuration:
Basic structure is:
- META-INF/MANIFEST.MF
- META-INF/resources/
----- click pages, css, js, etc
----- WEB-INF/
--------- web.xml, click.xml, menu.xml
--------- lib/click-2.3.0.jar, click-extras-2.3.0.jar
- net/mypackage/*
- com/unpackedjarlibrary1/*
- com/unpackedjarlibrary2/*
And the main method pointed to the jar manifest eventually uses the
following code to launch the webapp:
Server server = new Server(8080);
URL resourceBase =
this.getClass().getClassLoader().getResource("META-INF/resources");
WebAppContext context = new WebAppContext();
context.setDescriptor("WEB-INF/web.xml");
context.setResourceBase(resourceBase.toExternalForm());
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
try {
server.start();
server.join();
} catch (Exception e) {
//omitted
}
Thanks again, Bob.
On Thu, Jun 30, 2011 at 14:36, Bob Schellink <[email protected]> wrote:
>
> What happens if you put your resources under META-INF/resources of your jar?
>
> regards
>
> Bob
>
> On Thu, Jun 30, 2011 at 12:42 PM, Mike Hoolehan <[email protected]> wrote:
> > Yes, click jar is within my app jar. The app is entirely self contained
> > with no outside dependencies.
> >
> > Basic structure is:
> > - META-INF/MANIFEST.MF
> > - net/mypackage/*
> > - com/unpackedjarlibrary1/*
> > - com/unpackedjarlibrary2/*
> > ....
> > - WebContent/
> > -- click htm pages, css, js, etc
> > -- /META-INF/click.xml,menu.xml,MANIFEST.MF
> > -- /META-INF/lib/click-2.3.0.jar, click-extras-2.3.0.jar
> >
> > The click jars don't seem to work correctly if unpacked in the root like all
> > the other libs. Jetty doesn't find them and do anything with them, it seems,
> > unless they are in the WebContent/META-INF/lib. If they are here, though, I
> > get the following on jetty startup and everyting works fine:
> >
> > $ java -jar myapp.jar
> > 2011-06-30 13:36:21.169:INFO::jetty-7.x.y-SNAPSHOT
> > 2011-06-30 13:36:21.512:INFO::Copying WEB-INF/lib
> > jar:file:/home/mike/workspace/<omitted>/<omitted>-0.0.1.jar!/WebContent/WEB-INF/lib/
> > to /tmp/Jetty_0_0_0_0_8080_WebContent____mon7rc/webinf/WEB-INF/lib
> > 2011-06-30 13:36:23.790:INFO::NO JSP Support for /, did not find
> > org.apache.jasper.servlet.JspServlet
> > [Click] [info ] *** Initializing Click 2.3.0 in debug mode ***
> > [Click] [info ] initialized LogService:
> > org.apache.click.service.ConsoleLogService
> > [Click] [debug] listing classes in
> > jar:file:/tmp/Jetty_0_0_0_0_8080_WebContent____mon7rc/webinf/WEB-INF/lib/click-2.3.0.jar!/META-INF/resources
> > [Click] [info ] found jar:
> > file:/tmp/Jetty_0_0_0_0_8080_WebContent____mon7rc/webinf/WEB-INF/lib/click-2.3.0.jar
> > [Click] [debug] listing classes in
> > jar:file:/tmp/Jetty_0_0_0_0_8080_WebContent____mon7rc/webinf/WEB-INF/lib/click-extras-2.3.0.jar!/META-INF/resources
> > [Click] [info ] found jar:
> > file:/tmp/Jetty_0_0_0_0_8080_WebContent____mon7rc/webinf/WEB-INF/lib/click-extras-2.3.0.jar
> > [Click] [debug] automapped pages:
> > [Click] [debug] /border/standard-border.htm ->
> > net.<omitted>.click.page.border.StandardBorder
> > [Click] [debug] /click/error.htm -> CLASS NOT FOUND
> > [Click] [debug] /click/error.htm -> CLASS NOT FOUND
> > [Click] [debug] /click/not-found.htm -> CLASS NOT FOUND
> > [Click] [debug] /click/not-found.htm -> CLASS NOT FOUND
> > [Click] [debug] /home.htm -> net.<omitted>.click.page.Home
> > [Click] [debug] /ormlite-test-table-ops-page.htm ->
> > net.<omitted>.click.page.OrmliteTestTableOpsPage
> > [Click] [debug] /panels/panel-footer.htm -> CLASS NOT FOUND
> > [Click] [debug] /panels/panel-footer.htm -> CLASS NOT FOUND
> > [Click] [debug] /panels/panel-themeswitcher.htm -> CLASS NOT FOUND
> > [Click] [debug] /panels/panel-themeswitcher.htm -> CLASS NOT FOUND
> > [Click] [debug] /simple-ajax-page.htm ->
> > net.<omitted>.click.page.SimpleAjaxPage
> > [Click] [debug] initializing FileLoadService:
> > org.apache.click.service.CommonsFileUploadService
> > [Click] [debug] initializing TemplateService:
> > org.apache.click.service.VelocityTemplateService
> > [Click] [debug] initializing ResourceService:
> > org.apache.click.service.ClickResourceService
> > [Click] [debug] initializing MessagesMapService:
> > org.apache.click.service.DefaultMessagesMapService
> > [Click] [info ] Click 2.3.0 initialized in debug mode
> > 2011-06-30 13:36:27.569:INFO::Started [email protected]:8080
> >
> > Everything works fine as far as I can tell except this menu.css issue.
> >
> >
> > On Thu, Jun 30, 2011 at 12:08, Bob Schellink <[email protected]> wrote:
> >>
> >> Hi Mike,
> >>
> >> How is the jar structured? Do you merge the Click jar into your main
> >> jar? In a war, resources inside folders receive preference over jars
> >> which is why one can override the resources from the Click jar. I'm
> >> not familiar what the runtime structure will look like under Jetty
> >> using a jar instead of a war.
> >>
> >> regards
> >>
> >> Bob
> >>
> >> On Thu, Jun 30, 2011 at 10:58 AM, Mike Hoolehan <[email protected]> wrote:
> >> > As Bob mentioned in an earlier topic
> >> > (http://markmail.org/message/cf5ll5ae5n25whyn), adding your own
> >> > click/menu.css will prevent Click from overwriting with its own
> >> > menu.css.
> >> > This works fine for me when running as a war file (tested in Tomcat or
> >> > Jetty). However, when I run the same app built as a executable Jar file
> >> > using embedded Jetty, my custom click/menu.css is not being used - and
> >> > the
> >> > auto-generated one is. Is there something preventing Click from
> >> > detecting
> >> > the menu.css when in it's a JAR resource?
> >> >
> >> > I have confirmed that there is only one click/menu.css in the jar file
> >> > and
> >> > it is my correct custom one.
> >> >
> >> > I understand I can write my own velocity macro to re-render the menu
> >> > with my
> >> > own css class names, but is there a simple way to keep original
> >> > rendering
> >> > but use custom CSS when deployed in a JAR?
> >> >
> >> > Regards,
> >> > Mike
> >> >
> >
> >