问题描述
当我启动Jetty(通过Gretty插件)时,我得到了CNF异常.当我跑步
When I started the Jetty (over Gretty plugin) I get the CNF exception. When I run
{
"servletContainerId": "jetty9.3",
"servletContainerDescription": "Jetty 9.3.25.v20180904",
"httpEnabled": true,
"httpPort": 8585,
"serverConfigFile": "C:\\Users\\user\\eclipse-workspace\\WS\\jetty.xml",
"logbackConfigFile": "C:\\Users\\user\\eclipse-workspace\\WS\\MyWebApp\\config\\logback.xml",
"loggingLevel": "INFO",
"consoleLogEnabled": true,
"fileLogEnabled": true,
"logFileName": "MyWebApp",
"logDir": "C:\\Users\\user/logs",
"baseDir": "C:\\Users\\user\\eclipse-workspace\\WS\\MyWebApp\\build\\serverBaseDir_jetty9.3",
"webApps": [{
"inplace": true,
"inplaceMode": "soft",
"webappClassPath": ["file:/C:/Users/user/eclipse-workspace/WS/MyWebApp/build/classes/java/main/", "file:/C:/Users/user/eclipse-workspace/WS/MyWebApp/build/resources/main", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.springframework/spring-web/4.3.7.RELEASE/7b69fc68cdb74c1c92f72905af6995696fcb56aa/spring-web-4.3.7.RELEASE.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.springframework/spring-core/4.3.7.RELEASE/54fa2db94cc7222edc90ec71354e47cd1dc07f7b/spring-core-4.3.7.RELEASE.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.2/4bfc12adfe4842bf07b657f0369c4cb522955686/commons-logging-1.2.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.springframework/spring-beans/4.3.7.RELEASE/2de9f59f3202965438f3a02057d6ad8274636044/spring-beans-4.3.7.RELEASE.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.springframework/spring-aop/4.3.7.RELEASE/3f243d685e4a8a78a0c291445c6d85560ec4d339/spring-aop-4.3.7.RELEASE.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.springframework/spring-context/4.3.7.RELEASE/34b66b0b7910122ef95ba4fff6da9238ef80a5de/spring-context-4.3.7.RELEASE.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.springframework/spring-expression/4.3.7.RELEASE/5257b6486e43d8c05674323fea5b415d4da72f38/spring-expression-4.3.7.RELEASE.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-rt-frontend-jaxws/3.1.12/b692298ec0df9920732e4248c52b136515c5b286/cxf-rt-frontend-jaxws-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-core/3.1.12/ff07181b388f099e9e7095cbe3d586a391d84dc3/cxf-core-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.ws.xmlschema/xmlschema-core/2.2.2/3346ea4712a8bc80dbc1877628bfca1d6c4d55ef/xmlschema-core-2.2.2.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.codehaus.woodstox/woodstox-core-asl/4.4.1/84fee5eb1a4a1cefe65b6883c73b3fa83be3c1a1/woodstox-core-asl-4.4.1.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.codehaus.woodstox/stax2-api/3.1.4/ac19014b1e6a7c08aad07fe114af792676b685b7/stax2-api-3.1.4.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-rt-bindings-xml/3.1.12/d7cc73475b7fd4be85b67d94c980da9b89cc365b/cxf-rt-bindings-xml-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.ow2.asm/asm/5.0.4/da08b8cce7bbf903602a25a3a163ae252435795/asm-5.0.4.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-rt-bindings-soap/3.1.12/593a4f533452842d76ced8c23b230e0ed0e033db/cxf-rt-bindings-soap-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-rt-wsdl/3.1.12/cc2bf92c9818b12aa9a8383297c15b5ee51f8a44/cxf-rt-wsdl-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/wsdl4j/wsdl4j/1.6.3/6d106a6845a3d3477a1560008479312888e94f2f/wsdl4j-1.6.3.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-rt-databinding-jaxb/3.1.12/c0a312c95af2197a0f0496f903442ece0c3d6cc6/cxf-rt-databinding-jaxb-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-core/2.2.11/c3f87d654f8d5943cd08592f3f758856544d279a/jaxb-core-2.2.11.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-impl/2.2.11/a49ce57aee680f9435f49ba6ef427d38c93247a6/jaxb-impl-2.2.11.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-rt-ws-addr/3.1.12/aea598a46cfb69e9cb61c06684461b225e304e5c/cxf-rt-ws-addr-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-rt-ws-policy/3.1.12/18364d215dc9df5821b118b0387f3aef4ebd1b8d/cxf-rt-ws-policy-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.neethi/neethi/3.0.3/ee37a38bbf9f355ee88ba554a85c9220b75ba500/neethi-3.0.3.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-rt-frontend-simple/3.1.12/26a89cf3181e23b31ea84e3baf3006e1c7699de7/cxf-rt-frontend-simple-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/xml-resolver/xml-resolver/1.2/3d0f97750b3a03e0971831566067754ba4bfd68c/xml-resolver-1.2.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.cxf/cxf-rt-transports-http/3.1.12/3f0d7bb7971e8b0c9ce135f81debca4b5ebcd65f/cxf-rt-transports-http-3.1.12.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.5.3/d1577ae15f01ef5438c5afc62162457c00a34713/httpclient-4.5.3.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.9/9ce04e34240f674bc72680f8b843b1457383161a/commons-codec-1.9.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.6/e3fd8ced1f52c7574af952e2e6da0df8df08eb82/httpcore-4.4.6.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/com.cgi..3rdparty/ojdbc8/12.2.0.1.0/60f439fd01536508df32658d0a416c49ac6f07fb/ojdbc8-12.2.0.1.0.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/soap/soap/2.3.1/b1c8d536eead15574d6324b30c450176f70b830d/soap-2.3.1.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.25/da76ca59f6a57ee3102f8f9bd9cee742973efa8a/slf4j-api-1.7.25.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-core/1.2.3/864344400c3d4d92dfeb0a305dc87d953677c03c/logback-core-1.2.3.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.slf4j/jcl-over-slf4j/1.7.25/f8c32b13ff142a513eeb5b6330b1588dcb2c0461/jcl-over-slf4j-1.7.25.jar", "file:/C:/Users/user/eclipse-workspace/WS/Authentication/Client/build/classes/java/main/", "file:/C:/Users/user/eclipse-workspace/WS/Authentication/Client/build/resources/main", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.5/a1e6cbb3cc2c5f210dd1310ff9fcb2c09c0d1438/httpclient-4.5.jar", "file:/C:/Users/user/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.1/f5aa318bda4c6c8d688c9d00b90681dcd82ce636/httpcore-4.4.1.jar", "file:/C:/Users/user/eclipse-workspace/WS/MonitoringSupport/build/classes/java/main/", "file:/C:/Users/user/eclipse-workspace/WS/MonitoringSupport/build/resources/main", "file:/C:/Users/user/eclipse-workspace/WS/Plus/build/classes/java/main/", "file:/C:/Users/user/eclipse-workspace/WS/Plus/build/resources/main/"],
"contextPath": "/MyWebApp",
"webXml": null,
"resourceBase": "C:\\Users\\user\\eclipse-workspace\\WS\\MyWebApp\\build/inplaceWebapp/"
}
]
}
请参阅CP部分:
这是jetty.xml:
here is the jetty.xml:
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<New id="ResourceRef_MyWebApp" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>jdbc/MyWebAppDS</Arg>
<Arg>
<New class="oracle.jdbc.pool.OracleDataSource">
<Set name="DriverType">thin</Set>
<Set name="URL">jdbc:oracle:thin:@localhost:1521/XE</Set>
<Set name="User">user</Set>
<Set name="Password">passwd</Set>
<Set name="connectionCachingEnabled">true</Set>
<Set name="connectionCacheProperties">
<New class="java.util.Properties">
<Call name="setProperty">
<Arg>MinLimit</Arg>
<Arg>5</Arg>
</Call>
</New>
</Set>
</New>
</Arg>
</New>
</Configure>
这是Oracle JNDI DS的Jetty服务器配置.不幸的是,Gretty插件没有详细报告配置错误":
It's Jetty server configuration for Oracle JNDI DS. Unfortunately Gretty plugin reports "Config error" with no detail:
15:47:58.311 [QUIET] [system.out] 07/15/19 15:47:58.311 [main] WARN Config error at <New id="ResourceRef_MyWebApp" class="org.eclipse.jetty.plus.jndi.Resource"><Arg/><Arg>jdbc/MyWebAppDS</Arg><Arg>
15:47:58.311 [QUIET] [system.out] <New class="oracle.jdbc.pool.OracleDataSource"><Set name="DriverType">thin</Set><Set name="URL">jdbc:oracle:thin:@localhost:1521/XE</Set><Set name="User">user</Set><Set name="Password">passwd</Set><Set name="connectionCachingEnabled">true</Set><Set name="connectionCacheProperties">
15:47:58.312 [QUIET] [system.out] <New class="java.util.Properties"><Call name="setProperty"><Arg>MinLimit</Arg><Arg>5</Arg></Call></New>
15:47:58.312 [QUIET] [system.out] </Set></New>
15:47:58.312 [QUIET] [system.out] </Arg></New> [o.e.j.x.XmlConfiguration] [XmlConfiguration.java:451]
15:47:58.350 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Changing state to: FAILED
15:47:58.350 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process 'command 'C:\Java\jdk1.8.0_191\bin\java.exe'' finished with exit value 1 (state: FAILED)
和Jetty ClassLoader产生:
and Jetty ClassLoader produce:
15:47:58.312 [ERROR] [system.err] Exception in thread "main" java.lang.ClassNotFoundException: oracle.jdbc.pool.OracleDataSource
15:47:58.313 [ERROR] [system.err] at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
15:47:58.313 [ERROR] [system.err] at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
15:47:58.313 [ERROR] [system.err] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
15:47:58.313 [ERROR] [system.err] at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
15:47:58.313 [ERROR] [system.err] at org.eclipse.jetty.util.Loader.loadClass(Loader.java:86)
这显然是CL的问题,但我不知道在哪里添加ojdbc.jar以供码头使用. (我不喜欢将其添加到java.class.path系统属性中,而是希望仅将其用于构建中的所有Web应用程序.)
it's obviously CL issue, but I don't know where to add ojdbc.jar to be usable by jetty. (I do not like to add it into java.class.path System Property, but like to use it only for all web applications in build).
推荐答案
jetty.xml
加载的类是服务器类路径的一部分.
Classes loaded by jetty.xml
are part of the Server classpath.
但是您的oracle类被配置为webapp的类路径的一部分.
But your oracle class is configured to be part of your webapp's classpath.
由于标准的WebApp类路径隔离,服务器无法查看您的WebApp.
The Server cannot see into your WebApp due to standard WebApp classpath isolation.
将oracle jar移到Server类路径.
Move your oracle jar to the Server classpath.
这篇关于码头JNDI资源失败:"java.lang.ClassNotFoundException:oracle.jdbc.pool.OracleDataSource"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!