I don't see the org.eclipse.jetty.osgi.jetty-osgi-boot-jsp bundle on your
list of dependencies. You should use that, then you won't have to mess
around with
ServletContainerIntializersStarters, org.eclipse.jetty.containerInitializers
or any of the things you've added to your jetty-web.xml file. In fact, I
think the jetty-web.xml file would be interpreted too late to be of use
here.

Here's a pointer to the docs to help you out:

https://www.eclipse.org/jetty/documentation/9.4.30.v20200611/framework-jetty-osgi.html#_using_jsps

Also might be useful to take a look at our osgi tests to see which bundles
we deploy along with the WAB:
https://github.com/eclipse/jetty.project/tree/jetty-9.4.x/jetty-osgi

Jan


On Sun, 5 Jul 2020 at 11:12, Gordon Jahn <[email protected]> wrote:

> Good morning!
>
> (This is a repost of a Stack Overflow question I posted on Friday - I then
> realised this was a better place to ask..)
>
> I'm trying to get Jetty 9.4.30 running as an OSGi Service (following this:
> https://examples.javacodegeeks.com/enterprise-java/jetty/jetty-osgi-example/ 
> with
> updated versions) that can host WebApp Bundles. I can deploy and servlets
> work fine, but JSPs aren't working and I keep hitting an exception for TLD
> loading caused by:
>
> Caused by:
> java.lang.NullPointerException
>     at 
> org.apache.jasper.JspCompilationContext.getTldResourcePath(JspCompilationContext.java:563)
>     at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:430)
>     at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:489)
>
> The problem is almost exactly that described at
> http://bengreen.eu/fancyhtml/quickreference/jettyjsp9error.html, except
> that in this case the author is using Jetty as Embedded and is able to set
> org.eclipse.jetty.containerInitializers using code where the server is
> started.
>
> In OSGi, I don't have a place where I'm starting it - it's all happening
> in the bundles. After a lot of tweaking (and untweaking) config files the
> closest I feel I've got is when I copied the configuration performed in
> code into the jetty-web.xml file (which would be deployed in each WAB and
> isn't ideal in itself) as follows:
>
> <Configure id="webappctxt" class="org.eclipse.jetty.webapp.WebAppContext">
>     <New id="initList" class="java.util.ArrayList"></New>
>     <Call name="setAttribute">
>         <Arg>org.eclipse.jetty.containerInitializers</Arg>
>         <Arg>
>             <Call class="java.util.Arrays" name="asList">
>                 <Array 
> type="org.eclipse.jetty.plus.annotation.ContainerInitializer">
>                     <Item>
>                         <New
>                             
> class="org.eclipse.jetty.plus.annotation.ContainerInitializer">
>                             <Arg>
>                                 <New 
> class="org.eclipse.jetty.apache.jsp.JettyJasperInitializer"></New>
>                             </Arg>
>                             <Arg></Arg>
>                         </New>
>                     </Item>
>                 </Array>
>             </Call>
>         </Arg>
>     </Call>
>     <Call name="addBean">
>         <Arg>
>             <New 
> class="org.eclipse.jetty.annotations.ServletContainerInitializersStarter">
>                 <Arg>
>                     <Ref refid="webappctxt" />
>                 </Arg>
>             </New>
>         </Arg>
>     </Call>
>     <Get name="ServletContext">
>         <Call name="setAttribute">
>             <Arg>org.apache.tomcat.InstanceManager</Arg>
>             <Arg>
>                 <New class="org.apache.tomcat.SimpleInstanceManager"></New>
>             </Arg>
>         </Call>
>     </Get></Configure>
>
> When running, I can see the
> org.eclipse.jetty.annotations.ServletContainerInitializersStarter, and it
> has the TLDs from the platform (so all my dependencies seem to be there!)
> but the XML version of the code fails because there are two constructors
> for org.eclipse.jetty.plus.annotation.ContainerInitializer:
>
> ContainerInitializer(java.lang.ClassLoader loader, java.lang.String toString) 
>   ContainerInitializer(javax.servlet.ServletContainerInitializer target, 
> java.lang.Class<?>[] classes)
>
> ...and the Jetty XML code picks the first one and throws a
> "java.lang.IllegalArgumentException: argument type mismatch".
>
> Plugins currently "required" by my WAB are:
>
> Require-Bundle: org.eclipse.jetty.jndi;bundle-version="9.4.30",
>  org.mortbay.jasper.apache-jsp;bundle-version="8.5.54",
>  org.eclipse.jetty.server;bundle-version="9.4.30",
>  org.eclipse.jetty.deploy;bundle-version="9.4.30",
>  org.eclipse.jetty.http;bundle-version="9.4.30",
>  org.eclipse.jetty.io;bundle-version="9.4.30",
>  org.eclipse.jetty.osgi.boot;bundle-version="9.4.30",
>  org.eclipse.jetty.security;bundle-version="9.4.30",
>  org.eclipse.jetty.servlet;bundle-version="9.4.30",
>  org.eclipse.jetty.util;bundle-version="9.4.30",
>  org.eclipse.jetty.webapp;bundle-version="9.4.30",
>  org.eclipse.jetty.xml;bundle-version="9.4.30",
>  org.eclipse.jetty.annotations;bundle-version="9.4.30",
>  org.eclipse.jetty.apache-jsp;bundle-version="9.4.30"
>
> ...and only the WAB bundle is set to auto-start.
>
> For completeness, the VM arguments to configure plugins are:
>
> -Djetty.home.bundle=jetty-config-bundle
> -Djava.naming.factory.url.pkgs=org.eclipse.jetty.jndi
> -Djava.naming.factory.initial=org.eclipse.jetty.jndi.InitialContextFactory
>
> And jetty-config-bundle does contain the jetty.xml, etc. files and they
> are being processed.
>
> Can anyone tell me if they've got this working, and how? Is it
> configurable to just work without needing a jetty-web.xml in each WAB, or
> am I missing a dependency bundle on my plugin?
>
> Thanks in advance,
>
> Gordon Jahn
> _______________________________________________
> jetty-users mailing list
> [email protected]
> To unsubscribe from this list, visit
> https://www.eclipse.org/mailman/listinfo/jetty-users
>


-- 
Jan Bartel <[email protected]>
www.webtide.com
*Expert assistance from the creators of Jetty and CometD*
_______________________________________________
jetty-users mailing list
[email protected]
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to