- This topic has 3 replies, 2 voices, and was last updated 12 years, 5 months ago by support-swapna.
-
AuthorPosts
-
Glenn PuckettParticipantHi,
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 1.0.3.1 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, please, please, 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.
support-swapnaModeratorWGPuckett,
Sorry that you are seeing this issue. I assume you are looking at tutorials on website.
You are seeing the “Singleton” issue as you have selected Project Jersey 1.4 libraries for Java EE 5 project. For Java EE 5 you have to select Project Jersey 1.3.0.1. I could not replicate the issue you mentioned when running the project on Tomcat server. The console does not show any messages or stack traces at my end.
The in built tutorials are more up to date but still a bit behind the current functionality. Please go to Help > Help Contents. In the Contents section, browse through MyEclipse Learning Center > Developing Web Services > Tutorials > REST Web Services.
The tutorial discusses the flow for Java EE 5 project. The tutorials are just to help you get started and you should be able to get it working with minor changes. We apologize for the inconvenience caused.
I have escalated your suggestions with respect to the tutorials to the team.
Please let us know if you are still seeing issues.
Glenn PuckettParticipantI’ll have to admit I am lost here. All of the tutorials for web services assume a response. That is not the situation I have.
I have a process that occurs after a user completes a specific update. This process can take up to 5 minutes to complete. There is no reason for the user to wait for that process to end before they can do anything else. So my goal is to create a separate process, i.e. a web service, where the servlet processing the request can pass the proper information to the service then forget about it and return back to the user. The service completes it’s work, possibly could generate an email, and then just ends, or waits, until it receives a new transaction. But nothing from this process would or should go back to the end user. Am I correct in describing this as an asynchronous service?
I tried just putting void as the return type but Tomcat issued all sorts of errors from that. So I’m stuck. I have tried googling async services but nothing I found there made any sense or was promoting some proprietary software.
One thing I thought about trying is to run it as a singleton so the class could remain instantiated. Then run the actual updates as threads. Then the actual methods called by the servlet could do nothing but capture the information and pass it to a common process that controls the threads. This it could immediately return control back to the servlet. But before I try that I was hoping there is a more straight forward approach to this.
It seems like web services would be the best solution for this challenge. Are there any tutorials or information available describing how to develop async services? Or should I be taking a different path to implement this?
support-swapnaModeratorWGPuckett,
Your web service could kick off a separate thread, to do the real work, and simply return a value to say “OK, I got your request”. The web services sits on top of a normal HTTP request/response, so there needs to be a response of some sort.
I suggest you cross post to web services related forums for better support.
-
AuthorPosts