1

簡単に言えば。接続プールを使用して webapp で oracle jndi dataSource を使用できるようにしたいと考えています。プロジェクトを Maven インストールし、Jetty hightide 7.xx サーバーに手動でデプロイして実行したいと考えています。次のようにjetty-envファイルをWEB-INFフォルダーに配置します。

jetty-env.xml

<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN"
   "http://jetty.mortbay.org/configure.dtd">
<Configure id="thisfile" class="org.eclipse.jetty.webapp.WebAppContext">
  <New class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
    <Arg>jdbc/jndimyds</Arg>
    <Arg>
     <New class="oracle.jdbc.pool.OracleDataSource">
    <Set name="DriverType">thin</Set>
    <Set name="URL">jdbc:oracle:thin:@localhost:1521:xe</Set>
    <Set name="User">username</Set>
    <Set name="Password">password</Set>
    <Set name="connectionCachingEnabled">true</Set>
    <Set name="connectionCacheProperties">
        <New class="java.util.Properties">
            <Call name="setProperty">
                <Arg>MinLimit</Arg>
                <Arg>5</Arg>
            </Call>
            <!-- put the other properties in here too -->
        </New>
    </Set>

</New>
    </Arg>
</New>
</Configure>

データソース Bean

そして、これは私のdataSource Beanです..

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" >
            <value>java:comp/env/jdbc/jndimyds</value>
        </property> 
        <property name="lookupOnStartup" value="false" />
        <property name="cache" value="true" />
        <property name="proxyInterface" value="javax.sql.DataSource" />
    </bean>

Maven のインストールは問題ありませんが、jetty サーバーにデプロイして起動すると、次のエラーが発生します。

2012-04-19 00:42:18.962:WARN::Failed startup of context o.e.j.w.WebAppContext{/myapp,file:/C:/Users/tharinduv/AppData/Local/Temp/jetty-0.0.0.0-2080-myapp.war-_myapp-any-/webapp/},C:\jetty\webapps\myapp.war
java.lang.IllegalArgumentException: Object is not of type class org.eclipse.jetty.webapp.WebAppContext
        at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:203)
        at org.eclipse.jetty.plus.webapp.EnvConfiguration.configure(EnvConfiguration.java:118)
        at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:414)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.jav
a:1153)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:588)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:436)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLife
Cycle.java:55)
        at org.eclipse.jetty.deploy.bindings.StandardStarter.processBinding(StandardStarter.java:36)
        at org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:180)
        at org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:479)
        at org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:136)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:137)
        at org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:50)

jetty-plus.xml と start.ini で必要な変更を行いました。pomファイルに追加したいものはありますか.ほとんどの投稿はmaven-jetty-pluginを提案していますが、それはjetty-runコマンドを正しく使用する場合にのみ有効ですか? 私を助けてください。

4

1 に答える 1

0

私の友人の 1 人は、問題は jetty-jsp、jetty-all-server などのいくつかの jetty 依存関係があることであると整理しました。それらを除外して libs フォルダーからそれらの jar を削除すると、このエラーは持続しなくなりました。

于 2012-04-19T09:44:39.750 に答える