Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 326595 - JettyServerServiceTracker does not provider useful properties
Summary: JettyServerServiceTracker does not provider useful properties
Status: CLOSED WONTFIX
Alias: None
Product: Jetty
Classification: RT
Component: osgi (show other bugs)
Version: 7.1.5   Edit
Hardware: Sun All
: P3 normal (vote)
Target Milestone: 7.1.x   Edit
Assignee: Jesse McConnell CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-29 16:27 EDT by Brian de Alwis CLA
Modified: 2010-10-12 10:03 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian de Alwis CLA 2010-09-29 16:27:18 EDT
I'm actually using Jetty 7.1.6 as an OSGi bundle to build a webapp structured as a set of web-bundles (as described in <http://wiki.eclipse.org/Jetty/Tutorial/Jetty-OSGi_SDK>.  I'm using the 'jetty.home.bundle' property (fantastic idea, btw).

I would like to define a different location for the Jetty log files, something independent of the 'jetty.home' property, and so I thought I'd use a new property to specify the location for log files ('jetty.logs').  I pass '-Djetty.logs=/tmp/jetty-logs' on the command line, and I can see that it's available through System.getProperty("jetty.logs"), but it's not being used when parsing the jetty.xml.  I even set a bp on XmlConfiguration#propertyObj() to check.

It turns out the XmlConfiguration is being provided a property-dictionary munged by org.eclipse.jetty.osgi.boot.internal.serverfactory.JettyServerServiceTracker.serviceChanged() from the properties provided by the ServiceReference.  Unfortunately this properties list has only 4 elements:

{service.id=28, objectClass=[Ljava.lang.String;@7badb7b8, managedServerName=defaultJettyServer, jetty.etc.config.urls=bundleentry://9.fwk204442458/etc/jetty.xml}

and no system properties are being passed.  This may mean that the 'jetty.home' isn't being properly set either.

I think this properties dictionary should be augmented with the system properties too.

Steps to repeat:
  * Create a simple servlet bundle (e.g., example.servlet).
  * Add an etc/jetty.xml.  
  * Change the RequestLog's location to use a 'jetty.logs' property.  E.g., 

    <Ref id="RequestLog">
      <Set name="requestLog">
        <New id="RequestLogImpl" class="org.eclipse.jetty.server.NCSARequestLog">
          <Set name="filename"><Property name="jetty.logs"
              default="./logs"/>/yyyy_mm_dd.request.log</Set>
     ...

  * Create a suitably-configured run configuration, and add '-Djetty.logs=/tmp' to the VM arguments
  * Run the configuration.  Note that the logs are not being put in /tmp.  Place a breakpoint in org.eclipse.jetty.xml.XmlConfiguration#propertyObj() and notice the very small properties dictionary.
Comment 1 Jesse McConnell CLA 2010-10-07 15:10:19 EDT
https://bugs.eclipse.org/bugs/show_bug.cgi?id=323985

This is an extension of that above issue...you can see how greg resolved the issue at the bottom which I believe will not resolve it here, but would a similar approach in this case?  Seems like it would as its largely doing the same thing.  I'll dig a bit in the code and might just add that in.
Comment 2 Jesse McConnell CLA 2010-10-07 15:30:21 EDT
You could also use SystemProperty instead of Property in that bit of xml you have there and that should work.
Comment 3 Hugues Malphettes CLA 2010-10-07 16:06:18 EDT
Thanks Jesse.
Brian,
Glad that jetty.home.bundle is useful for you.

It sounds like you want to use the SystemProperty itself:
<Set name="filename"><SystemProperty name="jetty.logs"
              default="./logs"/>/yyyy_mm_dd.request.log</Set>

Given that system properties are available to the XmlConfiguration I am not
convinced that passing the system properties as part of the properties map is
useful.

Does this solve the issue?
Comment 4 Brian de Alwis CLA 2010-10-12 06:48:41 EDT
Thanks for the pointers.  SystemProperty works for me.
Comment 5 Jesse McConnell CLA 2010-10-12 10:03:27 EDT
alternate solution identified, closing