Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6176343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:05:06+00:00 2026-05-24T00:05:06+00:00

I’m in the process of writing unit tests for a JEE5 web service. The

  • 0

I’m in the process of writing unit tests for a JEE5 web service. The behaviour of the web service depends on the attributes set in the web.xml file. I’m wanting to therefore split my web.xml into a constant part and a part that is changed around inbetween test runs.

To see if it’s actually possible, I’ve tried to see if I can split out the welcome-file-list attribute. Using some instructions I found I’ve come up the following:

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd" [
  <!ENTITY fragment SYSTEM "fragment.xml">
]>
<web-app 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">
    <listener>
        <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>NewWebService</servlet-name>
        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>NewWebService</servlet-name>
        <url-pattern>/NewWebService</url-pattern>
    </servlet-mapping>
    <session-config>
        <session-timeout>
            30
        </session-timeout>
    </session-config>
  &fragment;
</web-app>

fragment.xml

<?xml version="1.0" encoding="UTF-8"?>
<welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

However, I’m getting validation errors on the web.xml file:

Attribute “version” must be declared for element type “web-app”. [7]
Attribute “xmlns” must be declared for element type “web-app”. [7]
Attribute “xmlns:xsi” must be declared for element type “web-app”. [7]
Attribute “xsi:schemaLocation” must be declared for element type “web-app”. [7]

I get the feeling that using a web app v2.3 DTD and a web app v2.5 schema inside the same file is the problem, but I don’t know how I’m going to be able to get around it.

(Any other approaches in splitting a web.xml file into smaller chunks would be welcome too!)

Update

If I remove the DTD reference like so…

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app[
  <!ENTITY fragment SYSTEM "fragment.xml">
]>
<web-app 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">
etc, etc, etc.

…it appears as though the validation process ignores the web-app_2_5.xsd file:

Element type “web-app” must be declared. [5]
Element type “listener” must be declared. [6]
Element type “listener-class” must be declared. [7]
Element type “servlet” must be declared. [9]
etc, etc, etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:05:08+00:00Added an answer on May 24, 2026 at 12:05 am

    I ended up adding a hook into my web service that checks for the presence of an eproperties file. If it finds one, it knows that it is in testing mode and instead of using the values specified in web.xml, it pulls them from the properties file. Not very elegant but at least it works. The properties file is copied to the WEB-INF directory by the JUnit test during the @BeforeClass method. Given the success of this method I’ve been wondering whether web.xml is the best place to store web application settings anyway…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm parsing an XML file, the creators of it stuck in a bunch social
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.