NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Error in web.xml related to multiple url-pattern tags?

 
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users
View previous topic :: View next topic  
Author Message
mezmo



Joined: 23 Sep 2009
Posts: 2

PostPosted: Wed Sep 23, 2009 7:58 pm    Post subject: Error in web.xml related to multiple url-pattern tags? Reply with quote

I've got a JEE 5 app, and I'm using both filters and servlets with a single, say filter-mapping section, and multiple url-pattern entries in it. When I open the file I get the error "Fatal errors were found in web.xml file. It is highly recommended that you fix the errors in the XML view (XML tab) as soon as possible. Try to validate the XML document to see the problem". So, I do XML check, its fine, I do XML validate, and it is fine. When I hover over the doc in the file view I see the message, "DOM graph creation failed: org.netbeans.modules.schema2beans.Schema2BeansRuntimeException property url-pattern already bound to a DOM node". But according to everything I can read on the subject, including the schema, what I'm doing is acceptable, and the app deploys fine. Any ideas what the problem may be?
tia
Back to top
zemu



Joined: 23 Jun 2010
Posts: 2

PostPosted: Wed Jun 23, 2010 7:48 am    Post subject: Reply with quote

Hi,

I know the question is 9-month old, but it could still be useful to someone.

I had the same problem with Netbeans 6.8 and it turned out it was due to my servlet-mapping configuration, that contained several url-pattern nodes. I resolved it by splitting it into several servlet-mapping nodes, each containing only one url-pattern.

BEFORE :

<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>pattern1</url-pattern>
<url-pattern>pattern2</url-pattern>
</servlet-mapping>

AFTER :

<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>pattern1</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>pattern2</url-pattern>
</servlet-mapping>

It worked just fine for me, the IDE stopped to complain.
Back to top
mezmo



Joined: 23 Sep 2009
Posts: 2

PostPosted: Wed Jun 23, 2010 2:12 pm    Post subject: True but..... Reply with quote

That's the standard for older JEE platforms, and yes its still supported, but the newer, more concise syntax was introduced in JEE 5, and my point was that it should support both, and both are supported by the schema, but for some reason its giving an erroneous error.
It needs to be fixed, maybe in 6.9...I'll have to try it out.
Back to top
troy giunipero
Posted via mailing list.





PostPosted: Wed Jun 23, 2010 2:45 pm    Post subject: Re: Error in web.xml related to multiple url-pattern tags? Reply with quote

Can you produce the web.xml file that is giving an error? I was
recently working on a project that included multiple <url-pattern>
entries, and didn't have any problems in 6.8 or 6.9:

<servlet>
<servlet-name>Controller</servlet-name>
<servlet-class>controller.ControllerServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/category</url-pattern>
<url-pattern>/addToCart</url-pattern>
<url-pattern>/viewCart</url-pattern>
<url-pattern>/updateCart</url-pattern>
<url-pattern>/checkout</url-pattern>
<url-pattern>/purchase</url-pattern>
<url-pattern>/chooseLanguage</url-pattern>
</servlet-mapping>


On 6/23/10 9:49 AM, zemu wrote:
Quote:
Hi,

I know the question is 9-month old, but it could still be useful to someone.

I had the same problem with Netbeans 6.8 and it turned out it was due to my servlet-mapping configuration, that contained several url-pattern nodes. I resolved it by splitting it into several servlet-mapping nodes, each containing only one url-pattern.

BEFORE :

<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>pattern1</url-pattern>
<url-pattern>pattern2</url-pattern>
</servlet-mapping>

AFTER :

<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>pattern1</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>pattern2</url-pattern>
</servlet-mapping>

It worked just fine for me, the IDE stopped to complain.




Back to top
zemu



Joined: 23 Jun 2010
Posts: 2

PostPosted: Wed Jun 23, 2010 3:04 pm    Post subject: Reply with quote

Below is a tight version of my web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>My App</display-name>

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

<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>/about</url-pattern>
<url-pattern>/loginpage</url-pattern>
</servlet-mapping>

</web-app>

With this version, I have the error mezmo reported ("url-pattern already bound to a DOM node") and if I try to edit the file using another tab than XML tab (like 'General' or 'Servlets') a dialog box warns me my xml file contains error and I should edit it via the XML tab.

If I change the attributes of the node <web-app> so that 'version' and 'xsi:schemaLocation' point to version 2.5 instead of 2.4, the warning dialog box disappear, but I still got the error about url-pattern.

I just saw that I my app is running as J2EE 1.4, so maybe all this a normal after all. What surprises me it that the error was not present before, and I do not think I recently change the java version the app runs as.
Back to top
troy giunipero
Posted via mailing list.





PostPosted: Thu Jun 24, 2010 9:03 am    Post subject: Re: Error in web.xml related to multiple url-pattern tags? Reply with quote

You need to use schema version 2.5 (or 3.0) to take advantage of
multiple url-patterns in a single servlet-mapping. Also, you need to
define your servlet (using the <servlet> tag) in order for the
<servlet-mapping> entry to have the proper effect.

On 6/23/10 5:04 PM, zemu wrote:
Quote:
Below is a tight version of my web.xml :

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>My App</display-name>

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

<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>/about</url-pattern>
<url-pattern>/loginpage</url-pattern>
</servlet-mapping>

</web-app>

With this version, I have the error mezmo reported ("url-pattern already bound to a DOM node") and if I try to edit the file using another tab than XML tab (like 'General' or 'Servlets') a dialog box warns me my xml file contains error and I should edit it via the XML tab.

If I change the attributes of the node<web-app> so that 'version' and 'xsi:schemaLocation' point to version 2.5 instead of 2.4, the warning dialog box disappear, but I still got the error about url-pattern.

I just saw that I my app is running as J2EE 1.4, so maybe all this a normal after all. What surprises me it that the error was not present before, and I do not think I recently change the java version the app runs as.




Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java EE Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo