【发布时间】:2011-04-24 22:57:20
【问题描述】:
我正在尝试配置可通过调用 Maven Jetty 插件使用的 JNDI 数据源。我正在尝试在 WAR 文件外部执行此操作,以便以后可能使用 Jetty 部署我们的 webapp 的任何人都不必编辑 WAR 的 WEB-INF 目录中的配置文件。我创建了一个jetty.xml文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
<!-- Atomikos XA aware (but not XA capable) JDBC data source -->
<New id="sbeDataSource" class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/myDataSource</Arg>
<Arg>
<New class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
.......
</New>
</Arg>
</New>
</Configure>
然后我从 Maven 插件中引用了这个文件,如下所示:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<jettyConfig>config/jetty.xml</jettyConfig>
</configuration>
</plugin>
但是,当我尝试通过 mvn jetty:run-war 运行 webapp 时,出现以下错误:
Embedded error:
Object is not of type class org.mortbay.jetty.webapp.WebAppContext
如果我遗漏了顶级 <Configure> 元素并尝试直接通过以下方式创建新的 JNDI 资源:
<New id="sbeDataSource" class="org.mortbay.jetty.plus.naming.Resource">
然后我得到一个类似的错误:
Embedded error:
Object is not of type class org.mortbay.jetty.plus.naming.Resource
什么给了?
【问题讨论】:
标签: java maven-2 jetty jndi maven-jetty-plugin