Jersey Rest service: 'Resource /Servers is not open' - eclipse

I am new to Java EE and am trying to learn the same using tutorials and examples online.
I am trying to follow http://www.vogella.com/articles/REST/article.html#first and create a RESTful service using Jersey.
Since this is my first RESTful service, I have basically copy-pasted whatever code is present till http://www.vogella.com/articles/REST/article.html#first_run.
However, when I try to run the service, I am getting an error:
Could not load the Tomcat server configuration at /Servers/Tomcat v7.0 Server at localhost-config. The Servers project is closed.
When I tried looking into the server configuration, I see that the configuration path is showing an error for the value: /Servers/Tomcat v7.0 Server at localhost-config.
When I try to change any (server) configuration and save it, I get the message: "Error while saving. Resource '/Servers' is not open."
Five differences between my project and what is described in the page:
I am using JDK 1.7, while the page mentions JDK1.6.
I am using Apache Tomcat Server 7.0, while the page mentions Tomcat version 6.0.
The Dynamic web module version is set to 3.0 in my project, while it is 2.5 in the page.
I have a couple of practise spring apps configured on my tomcat server. I am not sure how to remove them. :(
I have updated my web.xml to use web-app_3_1.xsd in the place of web-app_2_5.xsd.
I am not able to understand why this is happening.
If this does not seem to be solvable, I would be thankful, if you can point me to any resource that explains creating a RESTFul service using Jersey using Java EE7, Apache Tomcat 7 and, preferably, Eclipse.

The solution turned out to be simple. When I looked at the Project Explorer, I saw that there was a project called "Servers". Once I "opened" this project, the problem got resolved.
Seems like marking all projects and selecting "Close Project" has a side effect in Java EE Perspective. :)

Related

How to run/debug java web service project in eclipse

I have a Java Web Service project which was just handed over to me by a colleague who just resigned (no one is assisting me in my new company). Im new to Java (J2EE) and my background is .Net + frontend + azure so I am pretty much very confused with setting up and running the java project. Also, Since my background is .Net Im referencing everything with how things work in Visual Studio from running a project, setting up a project to setting up and debugging a WCF project which I realized now is very different from eclipse + java.
I would really appreciate if someone could explain to me how I can run this project which is supposedly a java web service (as I was told)?
First I have a project that is like this:
Im assuming that the project boxed as blue is the webservice (and the rest are just libraries)? Is this correct? if so how do I run and debug the project using eclipse
Second when I click on debug as -> debug on server this is all I see:
Another colleague told me to install JBOSS (I haven't installed a server in eclipse) because that is what they used. Is there good documentation (step-by-step guide) on how to install JBOSS to run in eclipse. Im assuming that JBOSS + eclipse is like IIS express + Visual studio. Are there also other alternatives to JBOSS + eclipse like perhaps tomcat + ecplise that I can configure.
I really really find it hard to setup the java web service project in eclipse I have little to no prior experience with java j2ee programming especially with web services so any clarifications with my questions would be much appreciated. To sum up:
How would I really know that the project is a java webservice?
If so, how do I run the project and host the project using debugging in eclipse with tomcat or jboss?
I would appreciate if anyone can point me to the right direction of figuring out the source code
From here we can only guide you, you will have to go through some tutorials to understand how java projects work.
Your project is a webservice project according to your web.xml file because its having context params for rest.
the context param sets a front url to your webservice which in this case is gametime.
Check these tutorials and you will understand how it works
http://www.mkyong.com/tutorials/jax-rs-tutorials/
Create simple examples given in the above tutorial and then you can execute your's program
Jboss is a application server which we use to run our app.
You can install jboss in eclipse or you can use it externally also.
To install eclipse and jboss you can follow the link
http://theopentutorials.com/tutorials/java-ee/installing-jboss-tools-in-eclipse/
The other option is to download eclipse and jboss seperately
and use them.
Go to jbosshome/bin
If you download both of them seperately
then in that case for jboss
Invoke the add-user.sh or add-user.bat script. ...
Choose to add a Management user. ...
Choose the realm for the user. ...
Enter the desired username and password. ...
Choose whether the user represents a remote JBoss Enterprise Application Platform 6 server instance. ...
Enter additional users. ...
Create users non-interactively.
After this go to eclipse and follow steps of below link to add jboss to eclipse
http://www.mastertheboss.com/eclipse/jboss-eclipse/jboss-and-eclipse
A Java web application among other things has a predefined directory structure including folders named WEB-INF, WEB-CONTENT etc.
On how to deploy a web application to Tomcat via Eclipse you can follow the steps in this tutorial.

How to solve SplitsrcTargetPreparation exception in Oracle weblogic server?

I am trying to run a simple Restful web service example on oracle weblogic server . but i am getting this issue while run the project on server. Publishing to Oracle Weblogic server at localhost has encountered a problem.Runtime exception occurred in publish task 'SplitsrcTargetPreparation'.
Have a look on screen sort.What i have to do ?
None of the other answers solved my problem, but I finally found a solution. I'm not claiming that this is the best or only way of resolving this issue, but it worked for me. Hope it helps others.
Open the Properties of your WebLogic server instance in Eclipse. Select Publishing. Set the publishing mode to "Publish as an exploded archive". You will no longer get a split source error.
Check the following.
Maven version – If you have imported as a maven project then make
sure that maven version is compatible to the java version you are
using.
Makes sure that you are using the java from the Middleware
which is comes bundled with weblogic.
New domain – Corrupt domain
may also cause this. Create a new domain

Applet Web service client, with Eclipse Indigo using Apache CXF,

I'm trying to consume a web service within an applet.
For that objective i've tried Apache and Apache2, both with good results
but the problem is that the jar dependencies are far too fat for my application
(the jar for axis or axis2 are over 1.5MB, and the applet is less than 200KB)
So i will try consuming the web service with Apache CXF, hoping that the jars
are at least a bit smaller.
Using eclipse one creates an empty project and in the main classes implements
the applet and blah blah, but to create the web service one must use the web service
wizard.
I've used this wizard before, to consume the web service using Axis, but the moment i choose other options i get this message:
****The Apache CXF 2.x Web service runtime in Tomcat v7.0 Server does not support the client project****
What i´m missing?
I've already installed, CXF 2.x runtime, and the Tomcat 7 Server, and of course the Eclipse Web Tools.
This question How to generate web service client with Apache CXF in Eclipse Helios?
shows a very hard solution and it´s one year old!
is there any other way to consume webservices within an applet?
ksoap2 has no documentation on complex webservices, and ksoap2-android
neither
Sorry for a boring question, but any help is greatly apreciated
Apache CXF 2-x Web service runtime Tomcat Server not support client
The Apache CXF 2.x Web service runtime in Tomcat v7.0 Server does not support the client project
Answer: If you see above error during creating web service client in eclipse using Apache CXF means you are using java project to generate the client from WSDL. Latest version of JAX-WS supports Dynamic Web Module v2.5 and up. So create client using apache CXF first you need to create Dynamic web project.
Once dynamic project created then open web service client wizard to create client from WSDL and issue should be resolved.

Tomcat REST services not deployed with Intellij IDEA

I have just switched to Intellij Idea (11) and I'm having possibly simple problem for which I cannot find a solution within Intellij IDE. I have a web application which contains some classes marked with annotations from javax.ws.rs like eg. #Path("/members") etc and my web.xml file configured for handling REST calls.
The application is build with Maven, when I package the application either from command line or through the Intellij IDE and copy the .war file into tomcat webapps directory manually, all works fine, eg. I can access GET based services from the browser.
If I deploy the application through configured tomcat in Intellij IDE the application works but without the REST portion, so I'm not able to execute any rest based calls (all end up with 404 error). I cannot see anything in logs about deploying rest service classes like I do during manual deployment:
INFO: Adding scanned resource: com.softberries.klerk.rest.MemberResourceRESTService
so its definitively an IDE configuration option I've missed which prevents tomcat from scanning classes for this annotations.
The question is how should I configure my Tomcat within the IDE to work the same as started manually.
with Intellij you need to expose the classes as web services from Tools > WebServices.
Also check that in Setting > Web Services, the prefix path for web service is correct (by default is /services).
Here you have a nice tutorial about how to create webservices in intellij.
http://www.academia.edu/4526516/Creating_Web_Services_Applications_with_IntelliJ_IDEA
By the way... when you do a deploy from intellij, the application goes to:
C:\Users\userName.IntelliJIdea10\system\tomcat\NameDeploy"
This info appears in the console as: "Using CATALINA_BASE": .../path...
Hope this helps,
Cheers

Consuming Web Services in Netbeans

I've setup a project in Netbeans 6.5 with some web services that I've created myself and some web services that I've imported from WSDL files. I've setup a couple of desktop application through Netbeans in order to consume these web services. I'm not too sure where to go from here.
I have the GUI setup but not sure how to reference the web services so they can be consumed. I was wondering would anybody be able to guide me through this process or point me in the direction of a relevant tutorial. I'd also like to learn how to consume a web service through a JSP (also created in Netbeans) if possible.
Thanks.
You may find this tutorial useful:
http://netbeans.org/kb/docs/websvc/client.html, but since you are using Netbean 6.5 this may be the correct version:
http://netbeans.org/kb/61/websvc/client.html. As the steps show, it isn't difficult to build a jax-ws client using Netbeans.
But, it depends on what version of Java you are using also, most likely. You may want to download the latest version of jax-ws, if you get errors with your wsdl.
For a JSP, just create a custom tag to call the client.