我创建了一个包含文件的Servlet 3.0 Web片段jar:
/META-INF/resources/WEB-INF/classes/com/foo/whatever/i18n.properties
应用程序启动时由Web片段启用的其中一个Servlet上下文侦听器执行以下代码:
public static final String BUNDLE_BASE_NAME = "com.foo.whatever.i18n";
//... later:
ResourceBundle.getBundle(BUNDLE_BASE_NAME, locale);
Run Code Online (Sandbox Code Playgroud)
这意味着i18n.properties如果最终用户未在其Web应用程序中的相同路径中指定自己的文件,则应使用Web片段的上述文件.
这适用于Tomcat 7,但不适用于Jetty 8.这是在Jetty 8中部署时产生的异常:
java.util.MissingResourceException:找不到基本名称com.foo.whatever.i18n的bundle,locale en_US
有没有办法让Jetty 8兑现Web片段的类路径贡献?
我有两个Web应用程序(web-module1.war和web-module2.war),我想使用Web片段(web-core.jar)进行常见的servlet声明,如FacesServlet.
当我在web.xml中声明FacesServlet没问题,但是当我将此声明移动到web-fragment.xml时,我收到此错误:
java.lang.IllegalStateException: No Factories configured for this Application.
This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which …Run Code Online (Sandbox Code Playgroud) 我刚刚发现了Web片段,并希望在可插拔应用程序中使用它们。基本上,我正在构建一个插件,其中将包含我应用程序的安全性部分(基于Spring安全性)。Web片段仅包含servlet过滤器:
<!-- Loads the security fragment first -->
<ordering>
<before>
<others />
</before>
</ordering>
<!-- Spring security filter -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Run Code Online (Sandbox Code Playgroud)
问题在于它根本不起作用。如果我在主应用程序中对其进行测试,则该过滤器可以正常工作,但如果将其放在此处,则不会拦截任何呼叫。我认为这可能是由Maven构建引起的。我将项目打包为jar,因为我已经读过了。web-fragment.xml在/ bin / META-INF /下。
谁能解释我在做什么错?
谢谢。
web-fragment ×3
facesservlet ×1
java ×1
jetty ×1
jetty-8 ×1
jsf-2 ×1
maven ×1
myfaces ×1
servlet-3.0 ×1
spring ×1
web-inf ×1