In somewhat related news, I found two recently posted blog entries on REST to be particularly interesting. With the change to the persistence.xml file and the appropriate libraries copied to the appropriate Tomcat directories, it was easy to use NetBeans' "Test RESTful Web Services" feature to have the newly generated web services automatically deployed (to Tomcat in this case because it was my currently selected server) and have a browser-based client access the deployed web services. For example, I copied the libraries specified (except for Derby because I was using Oracle) in the Copying Libraries to Tomcat section to the appropriate Tomcat directories as specified.ĭuring the NetBeans generation process, the web.xml ( WEB-INF) file and the context.xml ( META-INF) file are generally taken care of automatically. The previously referenced article also pointed out some other useful changes that I needed to make. For my Oracle database using TopLink Essentials, the persistence.xml file now looks like this: In particular, it recommends changing that file to remove the jta-data-source element, to change the transaction-type attribute of the persistence-unit element to RESOURCE_LOCAL, and to specify JPA implementation-specific provider properties in the file. The NetBeans-centric article Getting Started with RESTful Web Services on Tomcat points out in the Configuring the Persistence File section how to change that file for Tomcat. The default persistence.xml file generated as part of the JPA entity generation process (and based on my wizard settings) is shown next: In this blog entry, I'll focus on the deploying the JPA-backed Jersey-based RESTful web services on Tomcat. While much of the process is the same regardless of the server used, the JPA persistence.xml file does need to be altered. In the referenced blog entry, I did not talk much about the differences of deployment to Tomcat or to GlassFish or other web server. Similarly, the ability of NetBeans to automatically generate Jersey artifacts for JPA entities was also used and illustrated. The process illustrated there takes advantage of the ability of NetBeans 6.1 (which many other IDEs now have as well) to generate JPA- compliant entity classes from source database tables. In my blog entry Project Jersey and Java-Based REST, I used several screen snapshots and some text to illustrate how NetBeans 6.1 can be used with Jersey (the JSR-311/JAX-RS reference implementation) to quickly and easily develop RESTful web services from database tables.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |