我嘗試添加org.eclipse.jetty.annotations.AnnotationConfiguration
到org.eclipse.jetty.webapp.WebAppContext
的configurationClasses
財產,但(與sbt containe:start
調用碼頭時),得到:java.lang.reflect.InvocationTargetException在碼頭-web.xml中設置WebAppContext.configurationClasses
[warn] Config error at <Set name="configurationClasses">
[warn] <Array type="java.lang.String"><Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item><Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item><Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item><Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item><Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item><Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item><Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item><Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item></Array>
[warn] </Set>java.lang.reflect.InvocationTargetException in file:/Users/erik.allik/code/scala/webtest/src/main/webapp/WEB-INF/jetty-web.xml
[warn] Failed startup of context [email protected]{/,[file:/Users/erik.allik/code/scala/webtest/src/main/webapp/],STARTING}
我試過將<Set ...>
更改爲<Call name="setConfigurationClasses">
(同時使用String[]
以及List<String>
變體)無效 - 每次都會得到相同的反射異常。
我jetty-web.xml
如下:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="configurationClasses">
<Array type="java.lang.String">
<Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
<Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
<Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
<Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
</Array>
</Set>
</Configure>
答:決定由https://github.com/JamesEarlDouglas/xsbt-web-plugin/blob/master/src/jetty-9/scala/Jetty9Runner.scala,xsbt-Web的插件設置的WebAppContext
配置屬性設置爲一個硬編碼值,所以無論在XML CONFIGS什麼,它可能只是被忽略(或者顯然會導致錯誤)。
*在http://wiki.eclipse.org/Jetty/Feature/Annotations上的*「將配置應用於單個webapp」*部分如何? –
該文檔適用於Jetty 7(又名Servlet 2.5) - Jetty 9文檔(也稱爲Servlet 3.1)位於http://www.eclipse.org/jetty/documentation/current/annotations.html - 註釋掃描servlet/filters/WebSocketContext中不支持websockets/etc ...(aka endpoints)。如果你覺得這很重要,請在bugs.eclipse.org(在RT/Jetty下)提交bug。 –
「WebAppContext'中不支持」你打算說? –