Eclipse Jetty v8.0 JNDI数据源在scala lift应用程序中不可用

Eclipse Jetty v8.0 JNDI数据源在scala lift应用程序中不可用,scala,jetty,lift,sbt,Scala,Jetty,Lift,Sbt,我使用xsbt v.0.10.1、web插件、lift v2.4-M4、Scala 2.9.1、Jetty 8.0.0.v20110901 在Boot.scala中,我添加了这样的代码: DefaultConnectionIdentifier.jndiName = "jdbc/db" logger.warn("JNDI connection availbale ? " + DB.jndiJdbcConnAvailable_?) 在码头日志中,我看到: 08:39:06.562 [Scanner

我使用xsbt v.0.10.1、web插件、lift v2.4-M4、Scala 2.9.1、Jetty 8.0.0.v20110901

在Boot.scala中,我添加了这样的代码:

DefaultConnectionIdentifier.jndiName = "jdbc/db"
logger.warn("JNDI connection availbale ? " + DB.jndiJdbcConnAvailable_?)
在码头日志中,我看到:

08:39:06.562 [Scanner-0] WARN  bootstrap.liftweb.Boot - JNDI connection availbale ? false
我使用web.xml v2.5:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <filter>
        <filter-name>LiftFilter</filter-name>
        <display-name>Lift Filter</display-name>
        <description>The Filter that intercepts lift calls</description>
        <filter-class>net.liftweb.http.LiftFilter</filter-class>
    </filter>

    <resource-ref>
        <description>My DataSource Reference</description>
        <res-ref-name>jdbc/db</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>

    <filter-mapping>
        <filter-name>LiftFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

</web-app>

提升过滤器
提升过滤器
拦截电梯呼叫的过滤器
net.liftweb.http.LiftFilter
我的数据源引用
jdbc/db
javax.sql.DataSource
容器
提升过滤器
/*
以及我的应用程序的my context.xml:

<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!-- ==================================================================
Configure and deploy the test web application in $(jetty.home)/webapps/test

Note. If this file did not exist or used a context path other that /test
then the default configuration of jetty.xml would discover the test
webapplication with a WebAppDeployer.  By specifying a context in this
directory, additional configuration may be specified and hot deployments 
detected.
===================================================================== -->

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Array id="plusConfig" 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.plus.webapp.EnvConfiguration</Item> <!-- add -->
    <Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>    <!-- add -->
    <Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
    <Item>org.eclipse.jetty.webapp.TagLibConfiguration</Item>
  </Array>

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Required minimal context configuration :                        -->
  <!--  + contextPath                                                  -->
  <!--  + war OR resourceBase                                          -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="contextPath">/</Set>
  <Set name="war"><SystemProperty name="jetty.home" default="."/>/test.war</Set>
  <Set name="configurationClasses"><Ref id="plusConfig"/></Set>

  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <!-- Optional context configuration                                  -->
  <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
  <Set name="extractWAR">true</Set>
  <Set name="copyWebDir">false</Set>


   <New id="ds" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
    <Arg>jdbc/db</Arg>
    <Arg>
     <New class="com.jolbox.bonecp.BoneCPDataSource">
                 <Set name="driverClass">org.h2.Driver</Set>
                 <Set name="jdbcUrl">jdbc:h2:~/test</Set>
                 <Set name="username">sa</Set>
                 <Set name="password">sa</Set>
     </New>
    </Arg>
   </New>

</Configure>

org.eclipse.jetty.webapp.webinf配置
org.eclipse.jetty.webapp.WebXmlConfiguration
org.eclipse.jetty.webapp.MetaInfConfiguration
org.eclipse.jetty.webapp.FragmentConfiguration
org.eclipse.jetty.plus.webapp.EnvConfiguration
org.eclipse.jetty.plus.webapp.plus配置
org.eclipse.jetty.webapp.JettyWebXmlConfiguration
org.eclipse.jetty.webapp.TagLibConfiguration
/
/测试战争
真的
假的
jdbc/db
org.h2.Driver
jdbc:h2:~/test
sa
sa
我尝试了一个简单的java应用程序,检查JNDI的可用性,它工作正常,在sbt中似乎有问题

也许有人已经有这样的问题了


谢谢。

这是Lift v2.4-M4的一个错误

这在Boot.scala的开头:

DefaultConnectionIdentifier.jndiName = "jdbc/db"
logger.warn("JNDI connection available (manyally) ? " + (((new InitialContext).lookup("java:/comp/env/jdbc/db").asInstanceOf[DataSource]) != null))
logger.warn("JNDI connection available (lift) ? " + DB.jndiJdbcConnAvailable_?)
印刷品:

16:43:52.937 [main] WARN  bootstrap.liftweb.Boot - JNDI connection available (manyally) ? true
16:43:53.015 [main] WARN  bootstrap.liftweb.Boot - JNDI connection available (lift) ? false

作为临时解决方案,我实现了ConnectionManager并添加到DB.defineConnectionManager中。

这是Lift v2.4-M4的一个bug

这在Boot.scala的开头:

DefaultConnectionIdentifier.jndiName = "jdbc/db"
logger.warn("JNDI connection available (manyally) ? " + (((new InitialContext).lookup("java:/comp/env/jdbc/db").asInstanceOf[DataSource]) != null))
logger.warn("JNDI connection available (lift) ? " + DB.jndiJdbcConnAvailable_?)
印刷品:

16:43:52.937 [main] WARN  bootstrap.liftweb.Boot - JNDI connection available (manyally) ? true
16:43:53.015 [main] WARN  bootstrap.liftweb.Boot - JNDI connection available (lift) ? false
作为临时解决方案,我实现了ConnectionManager并将其添加到DB.defineConnectionManager