I am trying to set up a project in Netbeans using Maven (my first time using Maven) with a dependency on Jersey. I am having trouble getting Netbeans to find the correct package for WebResource. According to the documentation I am following to set up a connection to a server I need to use the following code to test the connection:
However, Netbeans tells me that it cannot find the symbol class WebResource and asking the IDE to fix imports does not import the package. Below is my POM, created automatically by Netbeans with the dependencies after JUnit added by me:
I got the dependencies from the Jersey documentation. Could someone please explain what I am doing wrong?
"Twenty years from now you will be more disappointed by the things you didn't do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover." - Mark Twain
I think you can get rid of everything, except jersey-container-servlet (if you're writing servlets) or jersey-client (if you're writing clients). Maven will automatically get all other necessary dependencies.
The problem is probably that you're using <scope>provided</scope>, but you're not using a GlassFish server. Remove the scope from these dependencies, and it should work.
Thanks Stephan, several hours of Googling provided no clue about that. I even missed it in the Maven docs! What would you say is the best resource to learn amount using Maven for dependency management?
Most of what I know about Maven is from the POM reference, experimenting, and Google-fu when I run into a problem. It also helps that almost everything I've done in Java lately has been a Maven project.
It may seem a bit boring, but I really recommend going through the entire POM reference page on Apache. You can experiment with it while you go through it. It shouldn't take longer than a few hours.