I am using MyEclipse Enterprise Workbench v10-1 build 10.1-20120316. I have a Pro license.
I desperately need to learn how to develop web services for a current project. So I started with the first tutorial which is the overview. Right off the bat the initial dialog does no match what I get. I don't even have a selection for XFire and don't understand why the tutorial would suggest using a deprecated selection in the first place. Also I have a selection for Java EE 6.0 (which is the default for my project). I want to use REST (JAX-RS) which isn't even on that list.
So I backed out of that and went to the REST Web Service tutorial. Now that's what I'm looking for. So I bring up the New Web Service Project dialog and, again, it is NOT what I have. It has the WebSphere frameworks and still has no option for Java EE 6.0. But it at least does have a selection for JAX-RS. I selected that and clicked Next.
Now I am on the Project Servlet and Library Configuration dialog. Still I have a problem. There is a third selection for JAX-Rs version. Now I don't have a clue what to do. I have an option for Project Jersey 18.104.22.168 or Project Jersey 1.4. OK, guess I'll pick the latest version. No I got a list of selections for the 1.4 libraries. Only one is selected, JAXB Libraries. Since the tutorial says to also select the Core libraries I went ahead and selected that. Hey, I'm on uncharted teritory here. Already the tutorial is off the reservation as far as my version of MyEclipse is concerned. I click finish and get the obligatory compliance level warning and select custom setting so it sticks with Java 5.0.
OK, so now I have a web services project. Next step is to build a Web Service. So I select New, Web Service and get the New Web Service dialog. Similar to the tutorial except for those pesky WebSphere options. I clicked on Creat new Java bean and click Next. Now I'm at the Bottom-up Scenario dialog that looks surprisingly exactly like the demo. Except for one thing. The third method is truncated on the display and there are NO details on what that line should contain. I'm not sure how to proceed!!!! So, kill that tutorial and bounce on over to the Developing JAX-RS / Rest Web Services tutorial. Oh, it's the same thing as the overview. Man do I feel dumb. I should have known that "Overview" means take a look but don't DO!!! Sorry!
So now I'm on the REAL tutorial. But I still have the same problems listed above. The selection for Jersey version, a selection for Java 6.0 and a big difference in library selections. So I give it the same selections as I did before. Ok, now on the real tutorial it wants me to create the entity class first. Great, did that. Create new web service, those pesky WebSphere selections and that deprecated XFire. Now I'm getting somewhere. I've gotten all the way to New JAX-RS Resource Method. Now I need to add a parameter. Dang. The columns are different. The tutorial shows a Default Value column as well as a Param Value column. My actual dialog doesn't have a Param Value. But it does have Param Name. So I think I can conclude that Param Name is the same as Param Value. Still out in uncharted territory.
Now I have the new Web Service built, with 3 methods. This looks like it might work. The java class shows up on the list and there's that danged red X beside it. I bring up the view and it has @Singleton
highlighted as an error. And it has the import for com.sun.jersey.spi.resource.Singleton
highlighted as an error. Now what am I going to do???
Let's get creative. So I go into the Build configuration and go to the Add MyEclipse Libraries. I find 7 Project Jersey 1.4 libraries. What the heck. I'll pick them all! I clicked finish, returned back to the project and WOW, the errors went away. Now, do I really need all 7 libraries? Now I'll remove them one by one and see what happens. ATOM library, not needed. JSON library gone. Jackson library, outta here. (Where's the Jefferson library?!) FastInfoSet, gone. Mail & MIME, got rid of it. Now I'm down to the two I originally picked plus the Server and Client libraries and still the error is gone. I eliminated Client and still no error. So all I needed to know is that it needed the Server library. Good as gold. Back to the tutorial.
The tutorial gives the completed web service class so I cut-n-paste it to the editor. Done, WOW, no errors!!! High five!
OK. Time to test. Following the tutorial I right click the project and select "Run As .... MyEclipse Server Application".. DANG! As it came up it caught an error. It looks like the error causing the wiff is:
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Producing media type conflict. The resource methods public com.myeclipseide.ws.Customer com.myeclipseide.ws.CustomerResource.getCustomer(int) and public java.util.List com.myeclipseide.ws.CustomerResource.getCustomers() can produce the same media type
This doesn't make sense. Does REST not recognize different method signatures? Only one method can create a specific type of output? Why? Lost again. Maybe later I will Google this error and see if a fix is possible.
Now I have all kinds of stack trace and load exceptions. I did get a browser page up with the index.jsp output. But I sort of doubt it will work. Might as well give it a try. So I start up the Web Services Explorer and get what looks like a proper dialog. Success!! The test cases went fine. Looks like I got lucky with my guesses!!
Now I just have to figure out how to create the specific service I need for my application. Onward to the next tutorial adventure.
Serously. I know this novel will upset or bore some folks. I'm not try to be snide or obnoxious. I just wanted to relay to you an idea of what it feels like to take what we assume is a good tutorial and keep running into discrepancies. I know it is difficult to keep up with tutorials and documentation while trying to make CODE happen. But for us users in the trenches sometimes these tutorials are all we have to try to figure out how to do something. More often that not I cannot get a single tutoral to work properly because it is almost always for a different version of MyEclipse. So it becomes an absolute adventure trying to get through a tutorial and more often than not ended up being a total waste of time. You have deadlines. So do we. If nothing else, please
for each tutorial put which specific version of the software that tutorial was designed for. And what other versions it should/may work for. Then we can decide if it is worth the trouble to see what we can do.
I have been able to get through this tutorial with moderate success. Maybe it will be a building block for making this happen in my application. But I have an error with the web service on start up. Hope I can find a resolution for that.