码头配置:MySQL JNDI的问题 [英] Jetty configuration: problems with MySQL JNDI

查看:126
本文介绍了码头配置:MySQL JNDI的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嵌入式Jetty具有用于配置的jetty.xml。



当我用gradle运行jetty时,它会抛出一个异常:

 产生的原因:抛出java.lang.ClassNotFoundException:com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource 
。在org.eclipse.jetty.util.Loader.loadClass(Loader.java :86)
在org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.nodeClass(XmlConfiguration.java:364)
在org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.newObj(XmlConfiguration.java :754)
在org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.itemValue(XmlConfiguration.java:1125)
在org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.value(XmlConfiguration.java :1030)
在org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.newObj(XmlConfiguration.java:775)
在org.eclipse.jetty.xml.XmlConfiguration $ JettyXmlConfiguration.configure(XmlConfiguration.java :423)在org.eclipse.jetty.xml.XmlConfiguration
$ JettyXmlC (org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:248)
在org.eclipse.jetty.xml.XmlConfiguration $ configure。调用(来源不明)
在com.sahlbach.gradle.plugins.jettyEclipse.JettyEclipseRun.applyJettyXml(JettyEclipseRun.groovy:533)
在com.sahlbach.gradle.plugins.jettyEclipse.JettyEclipseRun.startJetty(JettyEclipseRun .groovy:318)

这是抛出异常的jetty.xml行:

 < New id =relevanteclass =org.eclipse.jetty.plus.jndi.Resource> 
< Arg>< / Arg>
< Arg> jdbc / Relevante< / Arg>
< Arg>
< New id =relevanteDataSourceclass =com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource>
< Set name =url> jdbc:mysql:// localhost:3306 / xxxx< / Set>
< Set name =user> xxxx< / Set>
< Set name =password> xxxx< / Set>
< / New>
< / Arg>
< / New>

MySQL连接器是gradle的依赖关系,我不知道是否需要放置连接器转换为本地地址(除了作为gradle的依赖)。

  jettyEclipse {
additionalRuntimeJars = files(new File ($ rootDir / src / main / webapp / WEB-INF / lib / mysql-connector-java-5.0.8-bin.jar))
warFile = file($ rootDir / build / libs / relevanteme .war)
jettyConfig = file($ rootDir / jetty.xml)
contextPath =
automaticReload =true
scanIntervalInSeconds = 5
webDefaultXml = file($ rootDir / webdefault.xml)
}

谢谢!!

解决方案

解决方案的服务器配置有两个xml文件。这两个文件中的一个将是jetty.xml,它将具有所有的服务器配置。另一个文件是jetty-env.xml,带有WebApp配置并连接到数据库(该文件必须位于webapp / WEB-INF /中)。



更多信息在此资料库中。


The Jetty embedded has a jetty.xml for the configuration. This configuration has a mysql jndi-connection.

When I run jetty with gradle, it throws an exception:

Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource
at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.nodeClass(XmlConfiguration.java:364)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:754)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.itemValue(XmlConfiguration.java:1125)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.value(XmlConfiguration.java:1030)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newObj(XmlConfiguration.java:775)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:423)
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:298)
at org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:248)
at org.eclipse.jetty.xml.XmlConfiguration$configure.call(Unknown Source)
at com.sahlbach.gradle.plugins.jettyEclipse.JettyEclipseRun.applyJettyXml(JettyEclipseRun.groovy:533)
at com.sahlbach.gradle.plugins.jettyEclipse.JettyEclipseRun.startJetty(JettyEclipseRun.groovy:318)

This is the line of jetty.xml where the exception is thrown:

<New id="relevante" class="org.eclipse.jetty.plus.jndi.Resource">
    <Arg></Arg>
    <Arg>jdbc/Relevante</Arg>
    <Arg>
        <New id="relevanteDataSource" class="com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource">
           <Set name="url">jdbc:mysql://localhost:3306/xxxx</Set>
           <Set name="user">xxxx</Set>
           <Set name="password">xxxx</Set>
        </New>
     </Arg>
</New>

The MySQL connector is a dependency of gradle and I don't know if I need to place the connector into a local address (in addition to as dependency in gradle).

jettyEclipse {
     additionalRuntimeJars = files( new File("$rootDir/src/main/webapp/WEB-INF/lib/mysql-connector-java-5.0.8-bin.jar") )
     warFile = file("$rootDir/build/libs/relevanteme.war")  
     jettyConfig = file("$rootDir/jetty.xml")
     contextPath = ""
     automaticReload = "true"
     scanIntervalInSeconds = 5
     webDefaultXml = file("$rootDir/webdefault.xml")
}

Thanks!!

解决方案

The solution's to have two xml files for server configuration. One of these two files will be jetty.xml which will have all the server configuration. The other file will be jetty-env.xml with webApp configuration and connection to the database (this file has to be in webapp/WEB-INF/).

More information in this repository.

这篇关于码头配置:MySQL JNDI的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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