开发者

how to get web-fragment.xml working

开发者 https://www.devze.com 2023-02-18 03:50 出处:网络
I have following web-fragment.xml in a jar file, under META-INF/ It seems I cannot get it to work (although I think it did in previous tests).

I have following web-fragment.xml in a jar file, under META-INF/

It seems I cannot get it to work (although I think it did in previous tests).

The same content works in web.xml.

The web application is itself part of an ear, but I wouldn't expect that to matter.

I tried with <web-app> tag and <web-fragment>. Where is the reference documentation, btw?

The idea is to include my jar in all of my ear's wars (10+) to have common things implemented in one place (authentication, ...). The question is about web-fragment, I'll get the things working (which was the case in web.xml) once I can migrate to that.

tag was itself at 2.5 before, changed it to 3.0 (and cleaned the project to be sure).

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <context-param>
        <param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name>
        <param-value>be.epc.common.web.util.EpcResourceResolver</param-value>
    </context-param>    
    <error-page>
        <error-code>403</error-code>
        <location>/epcResources/noaccess.jsf</location>
    </error-page>    
    <error-page>
        <exception-type>javax.ejb.AccessLocalException</exception-type>
        <location>/epcResources/noaccess.jsf</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/epcResources/notfound.jsf</location>
    </error-page>
    <error-page>
        <error-code>500</error-code>
        <location>/epcResources/error.jsf</location>
    </error-page>
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
        <url-pattern>/icefaces/*</url-pattern>
        <url-pattern>*.jsf</url-pattern>
    </servlet-mapping>
    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Toutes pages</web-resource-name>
            <description/>
            <url-pattern>*.xhtml</url-pattern>
            <url-pattern>*.jsf</url-pattern>
        </web-resource-collection>
        <auth-constraint>
            <description/>
            <role-name>APP_EPC</role-name>
        </auth-constraint>
        <user-data-constraint>
            <description>HTTPS</description>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>epcRealm</realm-name>
        <form-login-config>
            <form-login-page>/unauthenticated-redirect.jsp</form-login-page>
            <form-error-page>/unauthenticated-redirect.jsp</form-error-page>
        </form-login-config>
    </login-config>
    <security-role>
        <description/>
        <role-name>APP_EPC</role-name>
    </security-role>
</web-开发者_JAVA百科app>


try by replace "web-app" tag to "web-fragment"


Ok, I lost some time on it, but it was quite simple.

I use Netbeans, and expected it to put CommonWeb.jar in my WAR's WEB-INF/lib. It didn't. I don't know why it does for some libraries and not for others.

Anyway, I just unchecked "package" under my WAR project properties' lib directory, and added an entry for the same jar in project properties / packaging, specyfing WEB-INF/lib as path. Something classical, I'm not too proud for having to ask for something like that ;-)

0

精彩评论

暂无评论...
验证码 换一张
取 消