Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 227177 - NetBeans modifies web.xml and sun-jaxws.xml (in a Maven war project)
NetBeans modifies web.xml and sun-jaxws.xml (in a Maven war project)
Status: RESOLVED FIXED
Product: webservices
Classification: Unclassified
Component: JAX-WS
7.3
PC Windows 7
: P2 with 11 votes (vote)
: 8.0.1
Assigned To: Milan Kuchtiak
issues@webservices
: 8.0_WAIVER_APPROVED
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-03-07 16:42 UTC by an_re
Modified: 2016-08-22 22:15 UTC (History)
11 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
Sample maven project exposing the problem (4.71 KB, application/zip)
2013-03-07 16:42 UTC, an_re
Details
The state after NetBeans Run action (target directory was removed to reduce size) (4.77 KB, application/zip)
2013-03-07 16:43 UTC, an_re
Details
patch (976 bytes, patch)
2013-05-29 04:44 UTC, David Konecny
Details | Diff
Non JSR-109 Server Detected dialog (22.55 KB, image/png)
2014-07-16 11:24 UTC, Milan Kuchtiak
Details

Note You need to log in before you can comment on or make changes to this bug.
Description an_re 2013-03-07 16:42:38 UTC
Created attachment 132344 [details]
Sample maven project exposing the problem

NetBeans 7.3 modifies web.xml and sun-jaxws.xml when invoking the Run action on an existing Maven war project.
This happens when a Tomcat 6 or 7 is selected as the deployment server.
In the web.xml of the provided sample project, the web service servlet is already defined and configured as:
    <servlet>
        <servlet-name>VerifierWebService</servlet-name>
        <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>VerifierWebService</servlet-name>
        <url-pattern>/verifier/*</url-pattern>
    </servlet-mapping>
In sun-jaxws.xml it is suitably configured as:
    <endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime" version="2.0">
      <endpoint name="Verifier" implementation="org.example.webservice.Verifier" url-pattern="/verifier/*"/>  
    </endpoints>
See attached sample-web_before.zip (unzips into sample-web folder).

NetBeans 7.3 modifies the web.xml and adds additional servlet and servlet-mapping definitions (after the existing ones):
    <servlet>
        <servlet-name>VerifierService</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>VerifierService</servlet-name>
        <url-pattern>/VerifierService</url-pattern>
    </servlet-mapping>
sun-jaxws.xml is also modified:
    <endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
      <endpoint implementation="org.example.webservice.Verifier" name="VerifierService" url-pattern="/VerifierService"/>
    </endpoints>
Thus the service is no longer available on the "/verifier/*" URL.
See attached sample-web_after.zip (unzips into sample-web folder).

Steps to reproduce:
- Unzip attached sample-web_before.zip.
- Open the project in sample-web directory using NetBeans 7.3 (official release).
- Choose to run the project, select Tomcat 6 or 7.
- After the server was started, the above-mentioned files are modified, the web service is not accessible on the URL specified
  in original web.xml/sun-jaxws.xml. There is not even a warning that either of these files were modified.

It might be related to https://netbeans.org/bugzilla/show_bug.cgi?id=218819
or http://netbeans.org/bugzilla/show_bug.cgi?id=217892.
This did not happen in NetBeans 7.2.
Comment 1 an_re 2013-03-07 16:43:46 UTC
Created attachment 132345 [details]
The state after NetBeans Run action (target directory was removed to reduce size)
Comment 2 phansson 2013-05-21 08:53:28 UTC
Bumped into this one today. Wonder if there's a workaround ?

The bug is pretty serious if you ask me. Netbeans shouldn't on its own change existing source code (yes, I would say those files are source code, they may have been manually edited by the developer).
Comment 3 phansson 2013-05-21 09:03:21 UTC
I've resorted to setting the read-only attribute on the files:

..../src/main/webapp/WEB-INF/sun-jaxws.xml
..../src/main/webapp/WEB-INF/web.xml


I did from the OS. This way NB can't change those files.

This seems to circumvent the bug for now.
Comment 4 rodrigorsantos 2013-05-27 22:23:34 UTC
This makes impossible to work with webservices.
I can't test using my url-pattern defined in file sun-jaxws.xml
Comment 5 Martin Janicek 2013-05-28 15:52:33 UTC
To be honest (based on the feedback we have here), I think this has to be fixed in the 7.3.1.
Comment 6 Petr Jiricka 2013-05-28 16:06:26 UTC
I am able to reproduce in the latest 7.3.1 build. I agree bug 218819 looks related; OTOH bug 217892 does not.

Looking at the history, there were some changes in this area during the 7.3 release cycle which may have caused regressions, e.g.: http://hg.netbeans.org/web-main/rev/923cac7f0e06

David, can you please try to investigate? Thanks.
Comment 7 David Konecny 2013-05-29 04:44:55 UTC
Created attachment 135039 [details]
patch
Comment 8 David Konecny 2013-05-29 04:57:17 UTC
Yes, the commit http://hg.netbeans.org/web-main/rev/923cac7f0e06, which Petr mentioned, did cause this issue (issue 218819 on the other hand is not relevant). The commit introduced a new method WSUtils.needNonJsr109Artifacts and used it in two places. Unfortunately the second usage (from WSUtils.java) was incorrect and changed the behaviour to call addJaxWsEntries() even when it is not appropriate. I rolled back that change in attached patch and it resolved this issue for me.

MartinJ, could you please review the change and if you are OK with it commit it and push it. I cannot do it myself as I discovered some nasty classloader issue as a result of fixing issue 229898 and I need to resolve that first. Thanks!

As for the integration into NB 7.3.1 the fix should be save as it reverts the code to a previous state and it should not cause regressions.
Comment 9 Martin Janicek 2013-05-29 08:41:55 UTC
The patch is fine and safe. Pushed in web-main #12e862692652
Comment 10 Martin Janicek 2013-05-29 08:46:21 UTC
Not sure what is the decision about 7.3.1 integration and if it's even desirable to do another final build --> reassigning to Petr
Comment 11 Marian Mirilovic 2013-05-29 09:22:26 UTC
Jirka Skrivanek is going to verify the fix.

Please backport as soon as possible after verification, so we can start another (and hopefully the last) build. Thanks in advance.
Comment 12 Petr Jiricka 2013-05-29 10:22:38 UTC
Ok, transplanted to release73 as http://hg.netbeans.org/releases/rev/b8f49f19dde0. Module spec version increase is not necessary, in release73 it is already higher (1.19.1) thank 7.3 patch 1 (1.18.1).

For anyone who would like to try out the fix in trunk and does not want to wait for the next daily build, it will be available in this build when it completes in about 30 minutes: http://bertram2.netbeans.org:8080/job/web-main/10649/
Comment 13 Jiri Skrivanek 2013-05-29 11:01:02 UTC
Verified in NetBeans IDE Dev (Build web-main-10649-on-20130529).
Comment 14 Quality Engineering 2013-05-29 15:38:18 UTC
Integrated into 'releases', will be available in build *201305291404* or newer. Wait for official and publicly available build.
Changeset: http://hg.netbeans.org/releases/rev/b8f49f19dde0
User: Martin Janicek <mjanicek@netbeans.org>
Log: #227177 - NetBeans 7.3 modifies web.xml and sun-jaxws.xml (in a Maven war project)
Comment 15 Quality Engineering 2013-05-30 01:36:41 UTC
Integrated into 'main-golden', will be available in build *201305292301* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/12e862692652
User: Martin Janicek <mjanicek@netbeans.org>
Log: #227177 - NetBeans 7.3 modifies web.xml and sun-jaxws.xml (in a Maven war project)
Comment 16 misterm 2013-06-17 14:09:03 UTC
This has started happening again on Build 20130615-4b6222f102af
Comment 17 Milan Kuchtiak 2013-06-28 09:54:10 UTC
Not able to reproduce yet.
Need to evaluate the code how could this happen.
Comment 18 Milan Kuchtiak 2013-06-28 16:02:04 UTC
Managed to reproduce now, and got the problem.The fix is based on not adding entries to web.xml, sun-jaxws.xml:1. sun-jaxws.xml is not changed when the entries are already there for given implementation class.2. web.xml is not changed, when    a/ the servlet name is found for given Endpoint   or   b/ url pattern from sun-jaxws.xml Endpoint
Comment 19 Milan Kuchtiak 2013-06-28 16:04:19 UTC
Managed to reproduce now, and got the problem.

The fix is based on not adding entries to web.xml, sun-jaxws.xml:

1. sun-jaxws.xml is not changed when the entries are already there for given implementation class.

2. web.xml is not changed, when 
   a/ the servlet name is found for given Endpoint
   or
   b/ url pattern from sun-jaxws.xml Endpoint matches one of the the web.xml servlet mappings.

See:
http://hg.netbeans.org/web-main/rev/b27b2138e670
http://hg.netbeans.org/web-main/rev/569aaa4e6840
Comment 20 Quality Engineering 2013-07-01 15:58:35 UTC
Integrated into 'main-silver', will be available in build *201307011244* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/b27b2138e670
User: Milan Kuchtiak <mkuchtiak@netbeans.org>
Log: #227177 Don't add entries to web.xml, sun-jaxws.xml when there are already some for given implementation class
Comment 21 phansson 2014-03-07 14:27:55 UTC
I believe the problem still exist. My tests are from NB8.0RC1.

Because of this long time bug I've set my web.xml file to read-only at the level of the OS. This way I get assurance that NB doesn't try to change that file without me knowing it.

In NB8.0RC1 I get a "Cannot lock read-only file foo/bar/web.xml" warning when I start up my IDE. This is because I have the project in question as one of those files that open when I start the IDE. The project is Maven based.

This is my sun-jaxws.xml:
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
  <endpoint implementation="com.myorg.armada.CalculationSvc" name="CalculationSvc" url-pattern="/WebService"/>
</endpoints>

and this is my web.xml:
<web-app ...>
    <servlet>
        <description>Armada Calc Service</description>
        <servlet-name>CalculationWS</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>CalculationWS</servlet-name>
        <url-pattern>/calculation</url-pattern>
    </servlet-mapping>
</web-app>

What NB does silently is to add an additional <servlet> and <servlet-mapping> as follows:

    <servlet>
        <servlet-name>CalculationSvc</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>CalculationSvc</servlet-name>
        <url-pattern>/CalculationSvc</url-pattern>
    </servlet-mapping>

(luckily the change cannot be saved to disk because I've set the file read-only, hence I get that read-only warning from the IDE)

What the source code change means is that the webservice which was previously exposed on '/WebService' is now suddenly exposed on '/CalculationSvc' instead. ==> the webservice no longer works.

Now, my sun-jaxws.xml and web.xml may not be completely by-the-book (dunno actually, aren't they?). But they work and they've been like that for this project since ...  well probably since project's inception 4-5 years ago.


My points are:

1. NB should *NOT* change my source code without telling me and it most definitely shouldn't do it SILENTLY on 'project open' action. Period ! Even if the project has the most crappy of source I don't think there's any excuse for the IDE to ever change source code silently.

2. Why does the IDE feel a need to change web.xml file in the first place? What would happen if it didn't?


Whatever it is that the Maven jaxws module is trying to accomplish by doing this there must be other ways to accomplish it. I'll be glad to contribute with ideas, etc, if I could just figure out what it is the module is trying to accomplish.
Comment 22 Milan Kuchtiak 2014-04-28 11:55:08 UTC
> 2. Why does the IDE feel a need to change web.xml file in the first place? What would happen if it didn't?

The motivation was to make services work automatically - in JSR-109 environment (e.g GlassFish)  and in non JSR-109 environment (e.g. Tomcat). Thus, Netbeans is trying to include servlet and servlet-mapping to web.xml elements "silently".

It's true, user should be informed, or asked, when web.xml is modified.
Comment 23 Milan Kuchtiak 2014-07-16 11:22:34 UTC
Now, Netbeans doesn't modify web.xml and sun-jaxws.xml when user doesn't wish to.

Specifically, when user says NO in "Non JSR-109 server detected" dialog, and checks "Don't ask this question next time" checkbox neither web.xml nor sun-jaxws.xml will be modificated. See the dialog in attachment.  


See:
http://hg.netbeans.org/web-main/rev/d32a96f81f4d
Comment 24 Milan Kuchtiak 2014-07-16 11:24:27 UTC
Created attachment 148082 [details]
Non JSR-109 Server Detected dialog
Comment 25 Milan Kuchtiak 2014-07-16 12:28:36 UTC
One more commit:
http://hg.netbeans.org/web-main/rev/7ff50d13fba9
Comment 26 Quality Engineering 2014-07-17 02:18:43 UTC
Integrated into 'main-silver', will be available in build *201407170001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/d32a96f81f4d
User: Milan Kuchtiak <mkuchtiak@netbeans.org>
Log: #227177 Don't modify web.xml and sun-jaxws.xml if user doesn't want
Comment 27 marianoCali 2016-08-22 19:53:22 UTC
I have this problem in my team work.
We use linux kubuntu 14.04 LTS and Kubuntu 16.04 LTS.
NetBeans IDE 8.1 (Build 201510222201).

I want to know what I must do in order to solve this problem.

My sun-jaxws.xml is:

<pre>
    <?xml version="1.0" encoding="UTF-8"?>
<endpoints version="2.0" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime">
  <endpoint implementation="com.cablevision.provisioning.services.wsprovisioning.WSProvisioning" name="WSProvisioning" url-pattern="/WSProvisioning"/>
  <endpoint implementation="com.cablevision.provisioning.services.cliente.ServicesCliente" name="ServicesCliente" url-pattern="/ServicesCliente"/>
  <endpoint implementation="com.cablevision.provisioning.services.cablemodem.ServicesCablemodem" name="ServicesCablemodem" url-pattern="/ServicesCablemodem"/>
  <endpoint implementation="com.cablevision.provisioning.services.wsprovisioning.WSProvisioning" name="WSProvisioningService" url-pattern="/WSProvisioningService"/>
  <endpoint implementation="com.cablevision.provisioning.services.cliente.ServicesCliente" name="ServicesClienteService" url-pattern="/ServicesClienteService"/>
  <endpoint implementation="com.cablevision.provisioning.services.cablemodem.ServicesCablemodem" name="ServicesCablemodemService" url-pattern="/ServicesCablemodemService"/>
</endpoints>

</pre>

I saw the message you talk about "JSR-109 compliant"
https://bugzilla-attachments-227177.netbeans.org/bugzilla/attachment.cgi?id=148082

Can someone show me how we can to solve this.
Thanks in advance.
Comment 28 markiewb 2016-08-22 22:15:20 UTC
(In reply to marianoCali from comment #27)
> I have this problem in my team work.
> We use linux kubuntu 14.04 LTS and Kubuntu 16.04 LTS.
> NetBeans IDE 8.1 (Build 201510222201).
> 
> I want to know what I must do in order to solve this problem.
> ...

@marianoCali: Please file a new issue instead of reopening this 3 years old issue! You can link to this issue from the new issue!

Reverting the changed fields.


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