How do I reference libraries in NetBeans?

2020-07-06 01:56发布

问题:

I have a Java Web Services project that was created in an older version of NetBeans, and I haven't accessed it in many months, so my paths and installed libraries are different.

When I try to open the project, I get a "Resolve Reference Problems" dialog, and two Reference Problems are listed:

"metro" library could not be found
"JAX-WS-ENDORSED" library could not be found

I have a fresh installation of JDK 6 Update 25 with NetBeans 7.0, and am running Windows 7.

What steps can I take to solve this? I don't even know where to start, as every approach I've taken so far hasn't gotten me anywhere.

Note: JAX-WS-ENDORSED does not appear in my Libraries listing, so I can't remove it. Something hidden is referencing it. How would I find this?

回答1:

I just came across this issue and found some help from http://netbeans.org/bugzilla/show_bug.cgi?id=187145. Apparently, Netbeans will create the JAX-WS-ENDORSED library when a new web service is created. So go to File > New File, choose Web Service > Web Service Client and fill in dummy values (this can be done in a throwaway project). This client can then be removed, and Netbeans will have created the library with the following classpath entries:

java/modules/ext/jaxws22/api/jaxws-api.jar
ide/modules/ext/jaxb/api/jaxb-api.jar

These are relative to your Netbeans install directory (on OS X will be located in Contents/Resources/Netbeans within the .app). Alternatively, you could create the library manually using the entries above.

This only needs to be done once, as the library will be added to Netbeans Global Libraries list.



回答2:

The best solution is to edit project.properties file and replace below piece of code.

Original property: endorsed.classpath=\${libs.JAX-WS-ENDORSED.classpath}

Replace with: endorsed.classpath=\${lib.JAX-WS 2.2.classpath}

In older versions of Netbeans there is JAX-WS-ENDORSED library in libs location.

Newer versions of Netbeans having JAX-WS 2.2 library in lib folder

** ALL THE BEST **



回答3:

Netbeans maintains a set of libraries, which are simply a comvenient way to manage groups of related jar files. Start by clickong Tools > Libraries. You will see the library manager window.

You will see the options to add your own libraries if you have jar files downloaded. If you do not see the library that you are looking for you can download them and add them your self. Once the library exist in Netbeans you can go to the Project Explorer window and right click on the Libraries tab of your project. Select Add Library and you will have the chance to add the library that you added in the library manager.



回答4:

If it is still needed, I had the same situation when opened a netbeans 6.9 project in netbeans 7. There is no way to resolve the 'jaxb-endorsed' (in my case was jaxb and not jaxws) reference using the libraries window.

I found a endorsed.classpath property in the nbproject/project.properties file. I still not sure what is its purpose, but in this property I found the bad reference to jaxb-endorsed.classpath, so I deleted, closed netbeans and opened again, and the reference problem has gone.

I already have Jaxb 2.2 library added to my project, so it is working good with the modification I did to the project.properties.

I hope it helps.



回答5:

I had a similar problem : DO NOT DELETE THE JAX-WS-ENDORSED - remind me to downvote. I had to go to the imported project > resolve reference problems dialogue > delete the references from there which were pointing to the old NB folders - pic :

and then create the throwaway web service as suggested by William Scott and then add the newly created jars :



回答6:

You may want to right click on your project, go to properties -> Libraries.

Remove the JAX-WS-ENDORSED library, and try using JAX-WS 2.2

Also remove metro and try adding METRO 2.0

That may solve your problem.

You may also want to right-click on your web service references and select

Edit Web Service Attributes

Then on wsimport Options tab see if xendorsed is set to true.

UPDATE

You may need to close netbeans and then open it again, and it may work. I was having a problem similar and I just did that and it worked.

The only difference, and it may not be needed, is that I also added the JAXB 2.2 library, but that was because I was trying to solve a compilation error.



回答7:

I had same problem and Fix it by install soap webservice and and resful webservice in netbeans plugin



回答8:

I fix it:

  1. unistall netbeans.
  2. delete HOME/.netbeans and HOME/.nbi
  3. then install netbeans again


回答9:

Old thread, different and effective solution... I just moved some projects from one system to another and got this error. With NetBeans v7.3+, go to Tools>Plugins, Available Plugins, then search for "SOAP". You should see "SOAP Web Services". On loading this library you'll get the JAX-WS-ENDORSED library. Restart NetBeans and you should be able to get a Clean Build.

Loading this package brings in a number of other libraries. On restarting the IDE you may get a notification that other packages now have available updates.



回答10:

Do the following ( BTW in my case its NetBeans 6.9.1 )

  • 1 Why this appeared now ?
    Because i tried to open project on other pc with fresh copy of net bean

  • 2 How the problem looks like ? Jar Lib Not Found for JAX-WS-ENDORSED

  • 3 Why it was needed at the first place and what its used for? Well i have a webservice on same server/domain e.g localhost , so of course it will work if i removed the web service from the folder in sources but i need it

  • 4 What to do? Try to add dummy any online free web service in form wsdl

like Some test web service or search for any other one

This is the source of my public free to use wsdl

  • 5 What then ? Just add it please

  • Now what ? Wait for scanning project stuff it should be ok you can re check from library properties of project or see that there is no red/ or resolve references problem in project properties

  • So what happened exactly? Note: JAX-WS-ENDORSED it will be added automatically to your libraries same methodology can solve other problems as well