0

I'm developing a web-application with Apache Tomcat. My web-app has a META-INF directory with the context.xml file in it. The problem is that when I try to create a .war file with the command "jar -cvf mywebapp.war ." , I get this warning (I'm translating as I can to English):

META-INF will be ignored
adding META-INF/context.xml(in = 142)(compression 17%)
META-INF/MANIFEST.MF will be ignored

Since when I start Tomcat I get some errors, I thought that maybe it was all due to this warning. Thank you.

EDIT:

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="mywebapp" version="2.5" 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_2_5.xsd">

    <display-name>My web app</display-name>
    <description>...</description>

    <welcome-file-list>
        <welcome-file>html/index.html</welcome-file>
    </welcome-file-list>

    <!-- Define the roles we want to use in the application -->
    <security-role> 
        <role-name>member</role-name> 
    </security-role>

    <security-constraint> 
        <!-- Define the resource -->
        <web-resource-collection> 
            <web-resource-name>Members Only</web-resource-name> 
            <url-pattern>html/members/*</url-pattern> 
        </web-resource-collection> 

        <!-- Only members can access this resource --> 
        <auth-constraint> 
            <role-name>member</role-name> 
        </auth-constraint>  

        <user-data-constraint>
            <!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE -->
            <transport-guarantee>NONE</transport-guarantee>
        </user-data-constraint>     
    </security-constraint> 

    <!-- Use BASIC security -->
    <login-config> 
        <auth-method>BASIC</auth-method> 
        <realm-name>Secure area</realm-name> 
    </login-config> 

</web-app>
user3067088
  • 1,869
  • 4
  • 17
  • 19
  • Is `context.xml` present in the resulting war? You can check with the command `jar -tvf mywebapp.war`. Also if you could post your Tomcat log we may be able to help you figure out what the problem is. – David Levesque Dec 20 '13 at 17:13
  • I've just opened the .war file and I've discovered that context.xml is present. This is my Tomcat log: http://i40.tinypic.com/zvzs5f.png . Thank you – user3067088 Dec 20 '13 at 17:24
  • There is an `IllegalArgumentExcpetion: invalid ...` in your log. This is most likely a problem with your `web.xml` or an annotation. Can you post your `web.xml`? You can include it in the body of your question using the "Code Sample" tag. – David Levesque Dec 20 '13 at 18:14
  • I edited the question as you suggested. Thank you so much for your willingness. I've been searching for a solution for hours without results. – user3067088 Dec 20 '13 at 18:24

1 Answers1

0

Try adding a slash at the beginning of the <url-pattern> for resource "Members Only" in the <security-constraint> section, e.g.:

<url-pattern>/html/members/*</url-pattern> 

instead of

<url-pattern>html/members/*</url-pattern>
David Levesque
  • 22,181
  • 8
  • 67
  • 82