views:

2545

answers:

1

All stuff is running under Windows XP Pro SP2/32-bit.

I have downloaded Jetty 7 pre3 from http://dist.codehaus.org/jetty/jetty-7.0.0-prereleases/jetty-7.0.0pre3/jetty-assembly-7.0.0pre3.zip>dist.codehaus.org.
I have extracted jetty to C:\jetty-7.0.0pre3\ (so I have C:\jetty-7.0.0pre3\bin\ and other dirs)
I have put my webapp into C:\jetty-7.0.0pre3\webapps\

I have resource-ref in my web.xml:

<resource-ref>
  <description>dev datasource</description>
  <res-ref-name>jdbc/dev</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>Container</res-auth>
</resource-ref>

and did configuration in jetty.xml:

<Array id="plusConfig" type="java.lang.String">
  <Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
  <Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
  <Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
  <Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
  <Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
</Array>

<New id="dev" class="org.mortbay.jetty.plus.naming.Resource">
  <Arg>jdbc/dev</Arg>
  <Arg>
    <New class="oracle.jdbc.pool.OracleConnectionPoolDataSource">
      <Set name="User">username</Set>
      <Set name="URL">jdbc:oracle:thin:@10.201.201.64:1521:DEV</Set>
      <Set name="Password">password</Set>
    </New>
  </Arg>
</New>

<Call name="addLifeCycle">
  <Arg>
    <New class="org.mortbay.jetty.deployer.WebAppDeployer">
      <Set name="contexts"><Ref id="Contexts"/></Set>
      <Set name="webAppDir"><SystemProperty name="jetty.home" default="."/>/webapps</Set>
      <Set name="parentLoaderPriority">false</Set>
         <Set name="extract">true</Set>
         <Set name="allowDuplicates">false</Set>
      <Set name="defaultsDescriptor"><SystemProperty name="jetty.home" default="."/>/etc/webdefault.xml</Set>
      <Set name="ConfigurationClasses"><Ref id="plusConfig"/></Set>
    </New>
  </Arg>
</Call>

I'm running java -DOPTION=plus -jar start.jar from C:\jetty-7.0.0pre3\ and I'm getting following error:

2008-10-14 12:12:49.163::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2008-10-14 12:12:49.413::WARN:  Config error at <New id="dev" class="org.mortbay.jetty.plus.naming.Resource"><Arg>jdbc/dev</Arg><Arg>
    <New class="oracle.jdbc.pool.OracleConnectionPoolDataSource"><Set name="User">username</Set><Set name="URL">jdbc:oracle:thin:@10.201.201.64:1521:DEV</Set><Set name="Password">password</Set></New>
  </Arg></New>
2008-10-14 12:12:49.413::WARN:  EXCEPTION
java.lang.ClassNotFoundException: org.mortbay.jetty.plus.naming.Resource
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.mortbay.util.Loader.loadClass(Loader.java:91)
        at org.mortbay.xml.XmlConfiguration.nodeClass(XmlConfiguration.java:224)
        at org.mortbay.xml.XmlConfiguration.newObj(XmlConfiguration.java:572)
        at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:256)
        at org.mortbay.xml.XmlConfiguration.configure(XmlConfiguration.java:214)
        at org.mortbay.xml.XmlConfiguration.main(XmlConfiguration.java:971)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.mortbay.start.Main.invokeMain(Main.java:218)
        at org.mortbay.start.Main.start(Main.java:564)
        at org.mortbay.start.Main.main(Main.java:136)

C:\jetty-7.0.0pre3\lib\plus\jetty-plus-7.0.0pre3.jar is on the classpath. In the same console:

C:\jetty-7.0.0pre3>set classpath
CLASSPATH=C:\Program Files\IBM\WebSphere MQ\Java\lib\providerutil.jar;C:\Program
 Files\IBM\WebSphere MQ\Java\lib\com.ibm.mqjms.jar;C:\Program Files\IBM\WebSpher
e MQ\Java\lib\ldap.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\jta.jar;C:\Pro
gram Files\IBM\WebSphere MQ\Java\lib\jndi.jar;C:\Program Files\IBM\WebSphere MQ\
Java\lib\jms.jar;C:\Program Files\IBM\WebSphere MQ\Java\lib\connector.jar;C:\Pro
gram Files\IBM\WebSphere MQ\Java\lib\fscontext.jar;C:\Program Files\IBM\WebSpher
e MQ\Java\lib\com.ibm.mq.jar;.;c:\Program Files\Java\jdk1.5.0_05\classes;C:\Prog
ram Files\Java\jre1.5.0_05\lib\ext\QTJava.zip;C:\Program Files\Java\jre1.5.0_05\
lib\spring.jar;c:\jetty-7.0.0pre3\lib\plus\jetty-plus-7.0.0pre3.jar

What's wrong? How should I add org.mortbay.jetty.plus.naming.Resource to the visibility area of start.jar?

+1  A: 

The problem is that addLifeCycle does not take a Resource object; it takes LifeCycle implementations such as WebAppContexts or WebAppDeployers.

Assuming you have a WebAppDeployer (or equivalent) set up in your jetty.xml, try this:

<Array id="plusConfig" type="java.lang.String">
  <Item>org.mortbay.jetty.webapp.WebInfConfiguration</Item>
  <Item>org.mortbay.jetty.plus.webapp.EnvConfiguration</Item>
  <Item>org.mortbay.jetty.plus.webapp.Configuration</Item>
  <Item>org.mortbay.jetty.webapp.JettyWebXmlConfiguration</Item>
  <Item>org.mortbay.jetty.webapp.TagLibConfiguration</Item>
</Array>

<Call name="addLifeCycle">
  <Arg>
    <New class="org.mortbay.jetty.deployer.WebAppDeployer">
      ....
      <Set name="ConfigurationClasses"><Ref id="plusConfig"/></Set>
      ....
    </New>
  </Arg>
</Call>


<New id="dev" class="org.mortbay.jetty.plus.naming.Resource">
  <Arg>jdbc/dev</Arg>
  <Arg>
    <New class="oracle.jdbc.pool.OracleConnectionPoolDataSource">
      <Set name="User">username</Set>
      <Set name="URL">jdbc:oracle:thin:@10.201.201.64:1521:DEV</Set>
      <Set name="Password">password</Set>
    </New>
  </Arg>
</New>

If you want the datasource only for a particular webapp, then do a similar configuration within a jetty-env.xml file for that webapp.

Also, since you're using Jetty 7, you will need to load the (optional) plus libraries (if the exe isn't doing that for you already). You'll know they aren't being loaded, because you'll get a ClassNotFoundException on startup.

Starting up Jetty on Linux, I would do it like so:

java -DOPTIONS=plus -jar start.jar

However, I am not familiar with Windows. Possibly

Jetty-Service.exe -DOPTIONS=plus

would work? If not, then look for something which would set the system property "OPTIONS" to "plus" when you run jetty.

Athena