Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-dev] Tld support for Jetty in OSGi

I think there might also have been a change with the way glassfish
jasper finds the classpath for compilation. It now wants an explicit
classpath listing all of the jars that are considered to be on the
container's classpath. In standard jetty we can create that just fine
(in org.eclipse.jetty.webapp.StandardDescriptorProcessor.getSystemClassPath())
because we interrogate a URLClassloader.

However, in the osgi code, the classloader that we are dealing with is
the special TldLocatableURLClassLoader, which seems to have been
created in order to expose the location of jars/bundles that contain
tlds, as it contains only the org.apache.jasper.glassfish.taglibs jar.

I'm working on getting all of the other necessary jsp jar locations
into this classloader (as it is the parent loader for each webapp) so
the StandardDescriptorProcessor can extract them as usual during
startup.

Chris, BTW, the zipped virgo setup you attached to issue
https://bugs.eclipse.org/bugs/show_bug.cgi?id=349009 has been most
helpful. There are a few things you need to do to the jetty setup to
get it working better (although not fully until I resolve the
classpath and tld problems). I'm attaching the modified jetty.xml file
you should use, along with the 7.6.x jars.

cheers
Jan

On 8 March 2012 03:17, Chris Frost <frostc@xxxxxxxxxx> wrote:
> Hi,
>
> Well, the short of it is that we need to upgrade for the security fix and we need the new version of Jetty on the 7.x line to support the standard tag libs. I think we understand the problem well enough now and just need a solution.
>
> Chris.
>
> ----- Original Message -----
> From: "Hugues Malphettes" <hmalphettes@xxxxxxxxxxx>
> To: "Jetty @ Eclipse developer discussion list" <jetty-dev@xxxxxxxxxxx>
> Sent: Wednesday, 7 March, 2012 2:48:13 PM
> Subject: Re: [jetty-dev] Tld support for Jetty in OSGi
>
> Hi Chris,
>
> With the older version of Jasper we used to stuff the jars that
> contain the tlds files in a URLClassLoader [1]
> Because that was where jasper would discover them.
> I am quite sure we could port the tld-requirebundle to the newer Jasper.
> Easier said than done of course.
> Let me know if you want more pointers.
> I'll work on this eventually otherwise.
> Cheers,
> Hugues
> [1] https://github.com/eclipse/jetty.project/blob/master/jetty-osgi/jetty-osgi-boot/src/main/java/org/eclipse/jetty/osgi/boot/internal/jsp/TldLocatableURLClassloader.java
>
> On Wed, Mar 7, 2012 at 6:59 PM, Chris Frost <frostc@xxxxxxxxxx> wrote:
>> Hi,
>>
>> Thanks for that, that helps a lot. So there is no point trying to use the Required-TldBundle header for the jstl tags and maybe the faces tags as they need to be pre-avaliable on the servlet containers classpath. That header should just be used for other 3rd party tlds.
>>
>> As for figuring out the classpaths, think of each webapp bundle as being it's own webapp classpath. I'm not sure which bundle should be considered to be the system classpath, I would expect some code in the jetty-osgi-boot bundle (or it's jsp fragment) to find the bundles with the standard tlds in, scan them and set the magic context attribute that tells jasper about the system tlds. I would just scan the classpath of the jetty-osgi-boot bundle looking for tlds. Remember that fragment bundles share the same classloader as their host bundles so the jetty-osgi-boot classLoader already contains all the tlds as the jsp fragment imports them.
>>
>> I'm happy to try stuff out as soon as you have anything, just point me at the jars.
>> Thank you for your help on this, it is appreciated.
>>
>> Chris.
>>
>> ----- Original Message -----
>> From: "Jan Bartel" <janb@xxxxxxxxxxx>
>> To: "Jetty @ Eclipse developer discussion list" <jetty-dev@xxxxxxxxxxx>
>> Sent: Tuesday, 6 March, 2012 11:37:32 PM
>> Subject: Re: [jetty-dev] Tld support for Jetty in OSGi
>>
>> Hi Chris,
>>
>> From jetty-7.5 onwards we are using jsp-impl-2.1.3.b10. For your
>> reference, here's our wiki page on jsp:
>> http://wiki.eclipse.org/Jetty/Howto/Configure_JSP
>>
>> The main difference is the way that the new version of jasper expects
>> to find the tlds. As we were doing previously, we need to examine jars
>> to find META-INF/tlds, but now we need to pre-load them into a
>> collection (org.apache.jasper.compiler.TldLocationsCache) that jasper
>> is holding onto that defines "system" tlds (ie tlds that are on the
>> container's classpath, not the webapp's classpath). Jasper is very
>> strict about tld urls and which ones it will consider on the webapp's
>> vs the containers classpath. For example, the jstl tags (and I think
>> the faces tags too, but I can't remember right now) it will only ever
>> consider as being on the system classpath, so putting those jars into
>> a webapp will do you no good, they have to be on the container's
>> classpath.
>>
>> I just need to work out how to marry this concept of system/webapp
>> classpath with osgi. The code that we need is in the
>> org.eclipse.jetty.webapp.TagLibConfiguration  in standard jetty and
>> the class I need to modify in the osgi code is
>> org.eclipse.jetty.osgi.boot.jsp.TagLibOSGIConfiguration.
>>
>> I hope to have something for you to test today, but I'm being impeded
>> by other problems getting our osgi unit tests to work - I think
>> they're tangential problems but I need to resolve those before I can
>> get to the Taglib stuff.
>>
>> cheers
>> Jan
>>
>>
>>
>> On 6 March 2012 21:54, Chris Frost <frostc@xxxxxxxxxx> wrote:
>>> Hi,
>>>
>>> Could you clarify what the changes of glassfish jasper between 7.4 and 7.6 are. As far as I can tell they are both on 2.1.0. Jetty ships with 2.1.0.v201007080150 on 7.4 and 1.2.0.v201112081803 on 7.6.
>>>
>>> Chris.
>>>
>>> ----- Original Message -----
>>> From: "Jan Bartel" <janb@xxxxxxxxxxx>
>>> To: "Jetty @ Eclipse developer discussion list" <jetty-dev@xxxxxxxxxxx>
>>> Sent: Monday, 5 March, 2012 11:14:41 PM
>>> Subject: Re: [jetty-dev] Tld support for Jetty in OSGi
>>>
>>> Hi Chris,
>>>
>>> The problem is no doubt due to the change of glassfish jasper versions
>>> between 7.4 and 7.5. We need to be able to satisfy glassfish jasper's
>>> requirements for the location of the tlds, some of which are required
>>> to be on the container's classpath. So we need to meld osgi's concept
>>> of classpath with glassfish jasper's expectations.
>>>
>>> I'm a mere osgi novice, but I'm happy to take a look at the code and
>>> see if I can improve things. I don't really have an environment where
>>> I can easily test - if I make some code changes do you have
>>> environment where we could test them out??
>>>
>>> thanks
>>> Jan
>>>
>>>
>>>
>>> On 6 March 2012 03:21, Chris Frost <frostc@xxxxxxxxxx> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I've upgraded from 7.4.x to 7.6.x and support for the standard tag libraries appears to have gone away. This was previously working as the 'org.eclipse.jetty.osgi.boot.jsp' fragment imported them in from the 'org.apache.taglibs.standard.glassfish' bundle. Looking at the wirings this is still the case but when trying to display a jsp page using tag libs it now fails with an exception saying the URL associated with one of the tag libs can't be resolved. For example "http://java.sun.com/jsp/jstl/core";.
>>>>
>>>>
>>>> Ideally we could get the 'Require-TldBundle' header working so that each application can specifically it's Tld bundles instead of a server wide setup or depending on fragments of the osgi boot bundle. This has been a problem for a while and is documented in bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=349009 with a zip of Virgo to recreate. It's a few versions out of date but nothing appears to have changed in the behaviour. It appears the documentation on how to use this header never got written so I've just followed the config provided in bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=306971 but enabling it just breaks something very basic and Jetty can't even find static html files and there is nothing in the log saying it has had any problems. I've tried debugging through this but I'm not sure where the entry point is for http requests and I can't spot anything obvious in the code that processes the configuration.
>>>>
>>>> While the standard tag libraries are still working on the 8.x line the 'Require-TldBundle' header is broken on both 8.x and 7.x
>>>>
>>>> Chris.
>>>>
>>>>
>>>> Christopher Frost - VMware
>>>> Virgo from EclipseRT
>>>>
>>>> _______________________________________________
>>>> jetty-dev mailing list
>>>> jetty-dev@xxxxxxxxxxx
>>>> https://dev.eclipse.org/mailman/listinfo/jetty-dev
>>> _______________________________________________
>>> jetty-dev mailing list
>>> jetty-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/jetty-dev
>>> _______________________________________________
>>> jetty-dev mailing list
>>> jetty-dev@xxxxxxxxxxx
>>> https://dev.eclipse.org/mailman/listinfo/jetty-dev
>> _______________________________________________
>> jetty-dev mailing list
>> jetty-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/jetty-dev
>> _______________________________________________
>> jetty-dev mailing list
>> jetty-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/jetty-dev
> _______________________________________________
> jetty-dev mailing list
> jetty-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-dev
> _______________________________________________
> jetty-dev mailing list
> jetty-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-dev
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd";>

<!-- =============================================================== -->
<!-- Configure the Jetty Server                                      -->
<!--                                                                 -->
<!-- Documentation of this file format can be found at:              -->
<!-- http://docs.codehaus.org/display/JETTY/jetty.xml                -->
<!--                                                                 -->
<!-- =============================================================== -->

<Configure id="Server" class="org.eclipse.jetty.server.Server">
	
	<!-- =========================================================== -->
	<!-- Server Thread Pool                                          -->
	<!-- =========================================================== -->
	<Set name="ThreadPool">
		<!-- Default queued blocking threadpool 
      -->
		<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
			<Set name="minThreads">10</Set>
			<Set name="maxThreads">200</Set>
		</New>
	</Set>
	
	<!-- =========================================================== -->
	<!-- Set connectors                                              -->
	<!-- =========================================================== -->
	<Call name="addConnector">
		<Arg>
			<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
				<Set name="host">
					<Property name="jetty.host"/>
				</Set>
				<Set name="port">
					<Property name="jetty.port" default="8080"/>
				</Set>
				<Set name="maxIdleTime">300000</Set>
				<Set name="Acceptors">2</Set>
				<Set name="statsOn">false</Set>
				<Set name="confidentialPort">8443</Set>
				<Set name="lowResourcesConnections">20000</Set>
				<Set name="lowResourcesMaxIdleTime">5000</Set>
			</New>
		</Arg>
	</Call>
	
	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<!-- To add a HTTPS SSL connector                                    -->
	<!-- mixin jetty-ssl.xml:                                            -->
	<!--   java -jar start.jar etc/jetty.xml etc/jetty-ssl.xml           -->
	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<Call name="addConnector">
		<Arg>
			<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
				<Set name="Port">
					<Property name="jetty.port.ssl" default="8443"/>
				</Set>
				<Set name="maxIdleTime">30000</Set>
				<Set name="Acceptors">2</Set>
				<Set name="AcceptQueueSize">100</Set>
				<Set name="Keystore"><Property name="jetty.home" default="."/>/etc/keystore</Set>
				<Set name="Password">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
				<Set name="KeyPassword">OBF:1u2u1wml1z7s1z7a1wnl1u2g</Set>
				<Set name="truststore"><Property name="jetty.home" default="."/>/etc/keystore</Set>
				<Set name="trustPassword">OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4</Set>
			</New>
		</Arg>
	</Call>
	
	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<!-- To add a HTTP blocking connector                                -->
	<!-- mixin jetty-bio.xml:                                            -->
	<!--   java -jar start.jar etc/jetty.xml etc/jetty-bio.xml           -->
	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<!-- To allow Jetty to be started from xinetd                        -->
	<!-- mixin jetty-xinetd.xml:                                         -->
	<!--   java -jar start.jar etc/jetty.xml etc/jetty-xinetd.xml        -->
	<!--                                                                 -->
	<!-- See jetty-xinetd.xml for further instructions.                  -->
	<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
	<!-- =========================================================== -->
	<!-- Set handler Collection Structure                            -->
	<!-- =========================================================== -->
	<Set name="handler">
		<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
			<Set name="handlers">
				<Array type="org.eclipse.jetty.server.Handler">
					<Item>
						<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
					</Item>
					<Item>
						<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
					</Item>
					<Item>
						<New id="RequestLog" class="org.eclipse.jetty.server.handler.RequestLogHandler"/>
					</Item>
				</Array>
			</Set>
		</New>
	</Set>
	
	<!-- =========================================================== -->
	<!-- Configure the deployment manager                            -->
	<!--                                                             -->
	<!-- Sets up 2 monitored dir app providers that are configured   -->
	<!-- to behave in a similaraly to the legacy ContextDeployer     -->
	<!-- and WebAppDeployer from previous versions of Jetty.         -->
	<!-- =========================================================== -->
	<Call name="addBean">
		<Arg>
			<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
				<Set name="contexts">
					<Ref id="Contexts"/>
				</Set>
				<Call name="setContextAttribute">
					<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
					<Arg>.*/jsp-api-[^/]*\.jar$|.*/jsp-[^/]*\.jar$</Arg>
				</Call>
				<!-- Providers of OSGi Apps -->
				<Call name="addAppProvider">
					<Arg>
						<New class="org.eclipse.jetty.osgi.boot.OSGiAppProvider">
							<!-- Set name="monitoredDir"><Property name="jetty.home" default="."/>/webapps</Set -->
							<!-- Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set -->
							<Set name="scanInterval">5</Set>
							<Set name="contextXmlDir"><Property name="jetty.home" default="."/>/contexts</Set>
						</New>
					</Arg>
				</Call>
			</New>
		</Arg>
	</Call>
	
	<!-- =========================================================== -->
	<!-- Enable support for tlds in other bundles                    -->
	<!-- =========================================================== -->
	<Call name="setAttribute">
          <Arg>org.eclipse.jetty.webapp.configuration</Arg>
          <Arg>
            <Array id="plusConfigOSGi" type="java.lang.String">
              <Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
              <Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
              <Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
              <Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
              <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
              <Item>org.eclipse.jetty.osgi.boot.jsp.TagLibOSGiConfiguration</Item>
            </Array>
          </Arg>
	</Call>


	<!-- =========================================================== -->
	<!-- Configure Authentication Login Service                      -->
	<!-- Realms may be configured for the entire server here, or     -->
	<!-- they can be configured for a specific web app in a context  -->
	<!-- configuration (see $(jetty.home)/contexts/test.xml for an   -->
	<!-- example).                                                   -->
	<!-- =========================================================== -->
	<Call name="addBean">
		<Arg>
			<New class="org.eclipse.jetty.security.HashLoginService">
				<Set name="name">Virgo Server Admin Console</Set>
				<Set name="config"><Property name="jetty.home" default="."/>/etc/realm.properties</Set>
				<Set name="refreshInterval">0</Set>
			</New>
		</Arg>
	</Call>
	
	<!-- =========================================================== -->
	<!-- Configure Request Log                                       -->
	<!-- Request logs  may be configured for the entire server here, -->
	<!-- or they can be configured for a specific web app in a       -->
	<!-- contexts configuration (see $(jetty.home)/contexts/test.xml -->
	<!-- for an example).                                            -->
	<!-- =========================================================== -->
	<Ref id="RequestLog">
		<Set name="requestLog">
			<New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
				<Set name="filename"><Property name="jetty.home" default="."/>/logs/yyyy_mm_dd.request.log</Set>
				<Set name="filenameDateFormat">yyyy_MM_dd</Set>
				<Set name="retainDays">90</Set>
				<Set name="append">true</Set>
				<Set name="extended">false</Set>
				<Set name="logCookies">false</Set>
				<Set name="LogTimeZone">GMT</Set>
			</New>
		</Set>
	</Ref>
	
	<!-- =========================================================== -->
	<!-- extra options                                               -->
	<!-- =========================================================== -->
	<Set name="stopAtShutdown">true</Set>
	<Set name="sendServerVersion">true</Set>
	<Set name="sendDateHeader">true</Set>
	<Set name="gracefulShutdown">1000</Set>
	
</Configure>

Back to the top