tags:

views:

2806

answers:

1

Hi I am getting this error when starting up Jetty that uses Mysql Connection Pool. Could someone help me out please?

[root@localhost test]# java -DOPTIONS=plus,ext.default -classpath %CLASSPATH% -jar /usr/src/jetty7/start.jar myjetty.xml
2008-12-20 18:24:08.138::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
2008-12-20 18:24:08.307::WARN:  Config error at <New id="dev" class="org.mortbay.jetty.plus.naming.Resource"><Arg>jdbc/mysql</Arg><Arg>
<New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"><Set name="User">root</Set><Set name="URL">jdbc:mysql://192.168.1.105/app</Set><Set name="Password">sqlpass</Set></New>
</Arg></New>
2008-12-20 18:24:08.307::WARN:  EXCEPTION 
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.mortbay.xml.XmlConfiguration.newObj(XmlConfiguration.java:608)
    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:974)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    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)
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
    at javax.naming.InitialContext.getNameParser(InitialContext.java:480)
    at org.mortbay.jetty.plus.naming.NamingEntry.save(NamingEntry.java:182)
    at org.mortbay.jetty.plus.naming.NamingEntry.<init>(NamingEntry.java:58)
    at org.mortbay.jetty.plus.naming.NamingEntry.<init>(NamingEntry.java:76)
    at org.mortbay.jetty.plus.naming.Resource.<init>(Resource.java:44)
    ... 15 more
2008-12-20 18:24:08.308::WARN:  Nested in java.lang.reflect.InvocationTargetException:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:325)
    at javax.naming.InitialContext.getNameParser(InitialContext.java:480)
    at org.mortbay.jetty.plus.naming.NamingEntry.save(NamingEntry.java:182)
    at org.mortbay.jetty.plus.naming.NamingEntry.<init>(NamingEntry.java:58)
    at org.mortbay.jetty.plus.naming.NamingEntry.<init>(NamingEntry.java:76)
    at org.mortbay.jetty.plus.naming.Resource.<init>(Resource.java:44)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.mortbay.xml.XmlConfiguration.newObj(XmlConfiguration.java:608)
    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:974)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    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)
[root@localhost test]#

Here is my Jetty.xml

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" 
"http://jetty.mortbay.org/configure.dtd"&gt;

<Configure id="Server" class="org.mortbay.jetty.Server">
<Call name="addConnector">
    <Arg>
        <New class="org.mortbay.jetty.nio.SelectChannelConnector">
            <!-- the ip address or domain to bind -->
            <Set name="host"><SystemProperty name="jetty.host" /></Set>

            <!-- the port to use/bind, defaults to 8080 if property not set -->
            <Set name="port"><SystemProperty name="jetty.port" default="8090"/></Set>

            <!-- the time in milliseconds when a connection is considered idle -->
            <Set name="maxIdleTime">300000</Set>

            <!-- the number of acceptors (their job is to accept the connection and dispatch to thread pool) -->
            <Set name="Acceptors">2</Set>

            <!-- should the connection statistics be turned on? (Not advisable in production) -->
            <Set name="statsOn">false</Set>

            <!-- the confidential port -->
            <Set name="confidentialPort">8443</Set>

            <!-- indicates the minimum number of connections when the server is considered low on resources -->
            <Set name="lowResourcesConnections">20000</Set>

            <!-- when low on resources, this indicates the maximum time (milliseconds) a connection must be idle to not be closed -->
            <Set name="lowResourcesMaxIdleTime">5000</Set>
        </New>
    </Arg>
</Call>

<Set name="handler">
  <New id="Handlers" class="org.mortbay.jetty.handler.HandlerCollection">
    <Set name="handlers">
     <Array type="org.mortbay.jetty.Handler">
       <Item>
         <New id="Contexts" class="org.mortbay.jetty.handler.ContextHandlerCollection"/>
       </Item>
       <Item>
         <New id="DefaultHandler" class="org.mortbay.jetty.handler.DefaultHandler"/>
       </Item>
       <Item>
         <New id="RequestLog" class="org.mortbay.jetty.handler.RequestLogHandler"/>
       </Item>
     </Array>
    </Set>
  </New>
</Set>

<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/mysql</Arg>
  <Arg>
    <New class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">

      <Set name="User">root</Set>
      <Set name="URL">jdbc:mysql://192.168.1.105/app</Set>
      <Set name="Password">sqlpass</Set>
    </New>
  </Arg>
</New>

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

      <Set name="contexts"><Ref id="Contexts"/></Set>
      <Set name="configurationDir"><SystemProperty name="jetty.home" default="/root/test"/>/contexts</Set>

      <Set name="scanInterval">5</Set>
    </New>
  </Arg>
</Call>

<Ref id="RequestLog">
  <Set name="requestLog">
    <New id="RequestLogImpl" class="org.mortbay.jetty.NCSARequestLog">
      <Set name="filename"><SystemProperty name="jetty.logs" 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">true</Set>
      <Set name="logCookies">false</Set>
      <Set name="LogTimeZone">GMT</Set>
    </New>
  </Set>
</Ref>

</Configure>
+2  A: 

Ensure that the jetty-plus.jar file is on your classpath, and also that the configuration file etc/jetty-plus.xml is included on the command line:

java -DOPTIONS=plus,ext.default -classpath %CLASSPATH% -jar /usr/src/jetty7/start.jar /path/to/etc/jetty-plus.xml myjetty.xml
Adam Batkin