Maven Jetty插件中的Jetty JNDI错误 [英] Jetty JNDI error within Maven Jetty Plugin

查看:362
本文介绍了Maven Jetty插件中的Jetty JNDI错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试配置可以从Maven Jetty插件的调用中使用的JNDI数据源。我试图在WAR文件外部执行此操作,以便稍后可能使用Jetty部署我们的webapp的任何人都不必编辑WAR的WEB-INF目录中的配置文件。我创建了一个jetty.xml文件,如下所示:

I am trying to configure a JNDI data source that can be used from an invocation of the Maven Jetty Plugin. I am trying to do this external to the WAR file, so that anyone who might later deploy our webapp with Jetty will not have to edit a configuration file inside the WAR's WEB-INF directory. I created a jetty.xml file as follows:

<?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插件中引用了这个文件,如下所示:

I then referenced this file from within the Maven plugin as follows:

 <plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>maven-jetty-plugin</artifactId>
  <configuration>
   <jettyConfig>config/jetty.xml</jettyConfig>
  </configuration>
 </plugin>

但是当我尝试通过mvn jetty运行webapp时:run-war我收到以下错误:

However when I attempt to run the webapp via mvn jetty:run-war I get the following error:

Embedded error: 
Object is not of type class org.mortbay.jetty.webapp.WebAppContext

如果我省略顶级< Configure> 元素并尝试直接通过以下方式创建新的JNDI资源:

If I leave out the top level <Configure> element and just try to create a new JNDI resource directly via:

<New id="sbeDataSource" class="org.mortbay.jetty.plus.naming.Resource">

然后我收到类似的错误:

Then I get a similar error:

Embedded error:
Object is not of type class org.mortbay.jetty.plus.naming.Resource

给出了什么?

推荐答案

除了Pascal Thivent的回答,你的 jetty.xml 实际上看起来像 jetty-env.xml ,所以你可以配置maven-jetty-plugin来使用它< jettyEnvXml>

In addition to Pascal Thivent's answer, your jetty.xml actually looks like jetty-env.xml, so you can configure maven-jetty-plugin to use it with <jettyEnvXml>:

<plugin> 
  <groupId>org.mortbay.jetty</groupId> 
  <artifactId>maven-jetty-plugin</artifactId> 
  <configuration> 
   <jettyEnvXml>config/jetty.xml</jettyEnvXml> 
  </configuration> 
</plugin>

这篇关于Maven Jetty插件中的Jetty JNDI错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆