有人在 Jetty 7 上成功部署了声纳吗?

Posted

技术标签:

【中文标题】有人在 Jetty 7 上成功部署了声纳吗?【英文标题】:Has anyone successfully deployed Sonar on Jetty 7? 【发布时间】:2010-10-31 07:40:00 【问题描述】:

我正在尝试在 Jetty 7 servlet 容器上部署 Sonar(自动代码监控工具)。

我想先使用默认配置(嵌入式 Derby DB)作为 POC,然后再转换到生产级 DB。

到目前为止,我已经尝试了各种方法来完成这项工作(待办事项:记录失败的尝试),但没有任何运气......

有人成功了吗?

这是我在 jetty/webapps 中部署并使用启动时遇到的例外情况

java -DOPTIONS=Server,deploy,jsp -jar start.jar etc/jetty.xml

org.picocontainer.PicoLifecycleException: PicoLifecycleException: method 'public void org.sonar.core.database.JndiDatabaseConnector.start()', instance 'org.sonar.core.database.JndiDatabaseConnector@1f1a3a8, java.lang.RuntimeException: wrapper
        at org.picocontainer.monitors.NullComponentMonitor.lifecycleInvocationFailed(NullComponentMonitor.java:76)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.monitorAndThrowReflectionLifecycleException(ReflectionLifecycleStrategy.java:129)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:115)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
        at org.picocontainer.injectors.AbstractInjector.start(AbstractInjector.java:131)
        at org.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:173)
        at org.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:134)
        at org.picocontainer.behaviors.Stored.start(Stored.java:111)
        at org.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:882)
        at org.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:630)
        at org.sonar.core.Application.start(Application.java:57)
        at org.sonar.web.listeners.ApplicationListener.contextInitialized(ApplicationListener.java:42)
        at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:627)
        at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:189)
        at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1200)
        at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:585)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:334)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:164)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:164)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
        at org.eclipse.jetty.server.Server.doStart(Server.java:221)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:979)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:248)
        at org.eclipse.jetty.start.Main.start(Main.java:637)
        at org.eclipse.jetty.start.Main.main(Main.java:138)
Caused by: java.lang.RuntimeException: wrapper
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.monitorAndThrowReflectionLifecycleException(ReflectionLifecycleStrategy.java:127)
        ... 32 more
Caused by: org.sonar.commons.database.JndiException: Can not bind JDBC datasource to JNDI
        at org.sonar.core.database.JndiDatabaseConnector.createAndBindDatasource(JndiDatabaseConnector.java:124)
        at org.sonar.core.database.JndiDatabaseConnector.start(JndiDatabaseConnector.java:69)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
        ... 31 more
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file:  java.naming.factory.initial
        at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
        at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
        at javax.naming.InitialContext.lookup(Unknown Source)
        at org.sonar.core.database.JndiDatabaseConnector.createJNDISubContexts(JndiDatabaseConnector.java:177)
        at org.sonar.core.database.JndiDatabaseConnector.createAndBindDatasource(JndiDatabaseConnector.java:118)
        ... 37 more

这就是我在 webappls-plus 中部署并使用以下命令启动的结果:

java -DOPTIONS=Server,deploy,jsp -jar start.jar etc/jetty.xml etc/jetty-plus.xml

java.lang.ClassNotFoundException: org.eclipse.jetty.plus.webapp.EnvConfiguration
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at org.eclipse.jetty.util.Loader.loadClass(Loader.java:90)
        at org.eclipse.jetty.util.Loader.loadClass(Loader.java:70)
        at org.eclipse.jetty.webapp.WebAppContext.loadConfigurations(WebAppContext.java:796)
        at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:297)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:164)
        at org.eclipse.jetty.server.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:161)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.server.handler.HandlerCollection.doStart(HandlerCollection.java:164)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.server.handler.HandlerWrapper.doStart(HandlerWrapper.java:92)
        at org.eclipse.jetty.server.Server.doStart(Server.java:221)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:55)
        at org.eclipse.jetty.xml.XmlConfiguration.main(XmlConfiguration.java:979)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jetty.start.Main.invokeMain(Main.java:248)
        at org.eclipse.jetty.start.Main.start(Main.java:637)
        at org.eclipse.jetty.start.Main.main(Main.java:138)

【问题讨论】:

【参考方案1】:

Sonar 尝试将其 JDBC 数据源绑定到 JNDI。但似乎 Jetty 7 需要一些额外的配置来实现这一点。有关详细信息,请参阅此thread。

希望对你有帮助。

【讨论】:

谢谢,我也偶然发现了那个线程。不幸的是,代表太低而无法投票;-)

以上是关于有人在 Jetty 7 上成功部署了声纳吗?的主要内容,如果未能解决你的问题,请参考以下文章

这里有人成功将 Micronaut GraphQL API 部署到 AWS Lambda 吗?

CentOS 7.X部署Jetty

用InteliJ IDEA时,服务器tomcat或Jetty之前部署的项目怎么去掉,现在每次启动都要加载挺多,有朋友知道吗~

Jetty实战之 安装 运行 部署

(转)Jetty实战之 安装 运行 部署

Ktor 和远程 tomcat 部署