a RESTful Pet Catalog
http-equiv="content-type">
Services JAX-RS, and the Java Persistence APIs
a RESTful Pet Catalog
This Sample Pet Store
Catalog application shows how to expose a Catalog as a
RESTful Web Service for remote client applications, and it shows how to
code a
href="http://dojotoolkit.org/">Dojo
client which gets and displays the Web Service responses in
a dynamic Ajax table (
href="http://dojotoolkit.org/book/dojo-book-0-9/docx-documentation-under-development/grid">Dojo
grid). I re-implemented
href="http://weblogs.java.net/blog/caroljmcdonald/archive/2007/09/sample_applicat_2.html">this
Sample Catalog application implemented with JAX-WS on the server side
and JSF on the client side which is also available in the
href="http://developers.sun.com/learning/javaoneonline/j1lab.jsp?lab=LAB-3410&yr=2008&track=1">
Java One Metro hands on lab.
href="https://techdayscode.dev.java.net/servlets/ProjectDocumentList?folderID=9684&expandFolder=9684&folderID=9601">Download
the RESTful Pet Catalog Code
Dojo
class="docTextHighlight">
is an open source DHTML toolkit written in JavaScript.
JAX-RS provides a
standardized API for building RESTful web services in Java. Central to
the RESTful architecture is the concept of resources identified by
universal resource identifiers (URIs). The API provides a set of
annotations which you can add to Plain Old Java Objects (POJOs)
to expose web resources identified by URIs .
Explanation of the usage of Dojo and JAX-RS in a sample Catalog
Application
The image below shows the Catalog Listing page, which allows a user to
page through a list of items
in a store.
src="http://weblogs.java.net/blog/caroljmcdonald/archive/petcatalog.jpg"
height="640" width="561">
Quick installation and use of dojo with Netbeans
There are 3 ways to install dojo which you can read about in
href="http://dojotoolkit.org/book/dojo-book-0-9/part-1-life-dojo/quick-installation">the
book of dojo. A quick and easy way to use dojo with Netbeans is to
download the JavaScript libraries from
href="http://dojotoolkit.org/downloads">http://dojotoolkit.org/downloads.
Create a new NetBeans Web Applications project. Extract the dojo
toolkit into the project web directory: .../web , then rename
dojo-release-1.1.1/ to src/ this will give you the project
structure shown below. I have already done this for the sample
project so you do not have to
download dojo in order to run the sample.
src="http://weblogs.java.net/blog/caroljmcdonald/archive/dojonetproj.JPG"
height="376" width="236">
Dojo style sheets
Every page using the dojo Grid needs to import the grid style sheet
Grid.cssasshown below:
Code Sample from: |
</style> |
This will load the the CSS files required by the Dojo grid widget, you
can just use dojox/grid/_grid/Grid.css instead of tundraGrid
if you don't want the tundra
style.
Loading base dojo and required modules into an application
In order to load dojo into your application, put the relative
path to the dojo.js file in a script element in the head
section of your HTML page as shown below:
Code Sample from: |
|
This script element will load the base dojo script which gives you
access to all the dojo functionality.
Next the application specifies which dojo modules to
load, using the dojo.require function (kind of like import
in Java):
Code Sample from:
style="font-family: monospace;"> |
|
Dojo is organized into three major layers: Dojo Core, Dijit, and
DojoX. DojoX builds on Dojo Core and provides newer
extensions to the Dojo toolkit. The rest of the Java Script for
this application is in the file dynamicTable.js.
The Grid Widget
You can use widgets declaratively by using special attributes inside of
regular HTML tags, or programmatically through JavaScript.
The dojoType attribute declares a Dojo widget. Below is
the declaration of the Grid widget for this applicaton:
Code Sample from:
style="font-family: monospace;"> |
|
The model and structure attributes point to the JavaScript
variables
for the model and layout structure explained below.
The Grid View
A
href="http://dojotoolkit.org/book/dojo-book-0-9/docx-documentation-under-development/grid">Dojo
grid is a widget useful for displaying data sets in a table
with its own scrollable views. The
dojo grid widget requires a layout. A grid layout is declared as an
array of views. Each view
is a group of columns, declared as an array of arrays. Each array
element is an object, the "name" property
of the object names the column. The
column names will be displayed in the top row of the grid. The code
below declares 4 columns: Company
class="userinput">, City,
State, Zip. This grid layout
structure consists of one view as shown below:
Code Sample from: |
// Data Grid layout |
The Grid Model
The dojo grid widget requires a data model. The model variable declares
the type of Dojo object that the Grid will use for the json data that
will be loaded in the grid. There are different
href="http://dojotoolkit.org/book/dojo-book-0-9/docx-documentation-under-development/grid/model-options">options
for the model, this example uses the
dojox.grid.data.Objectswhich is a collection of objects to be displayed in the grid.Code Sample from:
style="font-family: monospace;"> |
|
The loadTable
function calls dojo.xhrGet to
make an XMLHttpRequest to the items JAX-RS web
service specified by the url: parameter. When the
response from web service is returned, the callback function
handleResponsespecified by load:is
called and the response is passed to the callback function in the
responseObject.The handleAs parameter specifies
the response data type,
handleAs: "json" means
the returned data is of the type JSON (Java Script object notation).
In the
handleResponse callback
function, model.setDatais called to populate the Dojo
grid with the data returned from the
JAX-RS web service. Below is an example of atheitems
JSON response from the
itemsJAX-RS web service:
Example json data |
| {"items": {"@uri":"http://host/catalog/resources/items/", "item":[ {"@uri":"http://host/catalog/resources/items/1/", "name":"Friendly Cat", "description":"This black and white colored cat is super friendly.", "id":"1", "imageurl":"http://localhost:8080/CatalogService/images/anthony.jpg"}, {"@uri":"http://host/catalog/resources/items/2/", "name":"Fluffy Cat", "description":"A great pet for a hair stylist! "id":"2", "imageurl":"http://localhost:8080/CatalogService/images/bailey.jpg"} ] } } |
Loading the table
The dojo.addOnLoad function allows you to call a
function after a page has loaded and after Dojo has finished its
initilization. This application uses dojo.addOnLoad to
call the loadTable() function (which we looked at
above) which calls the items JAX-RS web
service and sets the results in the grid data model.
Code Sample from:
style="font-family: monospace;"> |
|
Events for paging
The "<<", ">>" buttons
call the next() previous() functions when
clicked:
Code Sample from: |
|
The next()
style="color: rgb(0, 102, 0); font-weight: bold;"> function increments the page number and then calls the
loadTable()funtion:
Code Sample from: |
|
RESTful Web Services with JAX-RS
The dojo.xhrGet url:
parameter references the
style="font-weight: bold;"> URI resources/items/
style="color: rgb(204, 0, 0); font-weight: bold;"> style="color: rgb(0, 102, 0);"> style="color: rgb(204, 0, 0); font-weight: bold;"> style="color: rgb(0, 102, 0);"> for the style="color: rgb(204, 0, 0); font-weight: bold;"> style="color: rgb(0, 102, 0);">items RESTful web service. The items
style="color: rgb(204, 0, 0); font-weight: bold;"> style="color: rgb(0, 102, 0);">RESTful webservice was generated using Netbeans 6.1 as explained in the href="http://www.netbeans.org/kb/61/websvc/rest.html">Generating
RESTful Web Services from Entity Classes tutorial.
Using Netbeans 6.1 you can generate JPA Entity Classes from Database
tables, then you can Generate RESTful Web Services from Entity
Classes, and then you can test the Web Services with a browser
interface. The items
style="color: rgb(204, 0, 0); font-weight: bold;"> style="color: rgb(0, 102, 0);">RESTful webservice was generated from the item data base table (the sql is in the
how to run section).
Below is a snippet from the
style="color: rgb(0, 102, 0); font-weight: bold;">ItemsResource.javaclass which was generated by the Netbeans "Generate RESTful Web
Services
from Entity Classes" feature :
Code Sample from: .java |
ItemsConverteritems |
The ItemsResource
represents a list of items. The
style="color: rgb(0, 102, 0); font-weight: bold;">ItemsResource get methodreturns a list of Item objects in JSON
format.
- To address a resource in REST you specify its URI.
isstyle="color: rgb(0, 0, 153); font-weight: bold;">@Path
a JAX-RS annotation that identifies the URI path for the resource. For
theItemsResource
the URI path is/style="color: rgb(0, 0, 153); font-weight: bold;"> style="color: rgb(0, 102, 0);">items/.style="color: rgb(0, 0, 153);">
specifiesstyle="font-weight: bold;">@GET
that the
method supports the HTTP GET method.get
style="color: rgb(0, 0, 153); font-weight: bold;">
specifies the MIME types that a method can produce.@ProduceMime
Here,
the annotation specifies that thestyle="color: rgb(0, 102, 0); font-weight: bold;">get
method returns aJSONArrayobject. The
class is a JAXBstyle="color: rgb(0, 102, 0); font-weight: bold;">ItemsConverter
annotated class which is used to marshal a list of Item objects
into XML or href="http://wikis.sun.com/display/Jersey/JSON+support+in+JAXB">JSON
format. Thestyle="font-weight: bold; color: rgb(0, 102, 0);">getEntities
methodstyle="color: rgb(0, 102, 0); font-weight: bold;">
returns a list of Item entity objects and is explained
below.style="color: rgb(0, 0, 153); font-weight: bold;">
specifies@QueryParam
input parameters for methods. When the method is invoked, the
input value will be injected into the corresponding input
argument.style="color: rgb(0, 0, 153); font-weight: bold;">
specifies a default value for an arguement if no@DefaultValue
input
value is given.
Here is an example of an HTTP request for this Web Service:
| Request: GET http://host/catalog/resources/items/?start=0 |
Here is an example of an HTTP response for this Web Service:
| Received: {"items": {"@uri":"http://host/catalog/resources/items/", "item":[ {"@uri":"http://host/catalog/resources/items/1/", "name":"Friendly Cat", "description":"This black and white colored cat is super friendly.", "id":"1", "imageurl":"http://localhost:8080/CatalogService/images/anthony.jpg"}, {"@uri":"http://host/catalog/resources/items/2/", "name":"Fluffy Cat", "description":"A great pet for a hair stylist! "id":"2", "imageurl":"http://localhost:8080/CatalogService/images/bailey.jpg"} ] } } |
The ItemsConverter
class is a JAXB annotated
class, used to marshal a list of Item objects into XML or
JSON format. A snippet of the
style="color: rgb(0, 102, 0); font-weight: bold;">ItemsConverterclass is shown below:
Code Sample from: .java |
|
Java Persistence Query API
The Items
style="color: rgb(0, 102, 0); font-weight: bold;">Resource style="color: rgb(0, 102, 0); font-weight: bold;"> getEntities
method
uses the Java Persistence APIstyle="color: rgb(204, 0, 0);">
Query style="color: rgb(204, 0, 0); font-weight: bold;"> objectto return a list of
items. Code Sample from: .java |
query.setMaxResults(max); return query. |
The Java
Persistence
href="http://java.sun.com/javaee/5/docs/api/javax/persistence/Query.html">Query
APIs are used to create and execute queries that can return a
list of results. The JPA Query interface provides
support for pagination via the setFirstResult() and setMaxResults()
methods: query.
style="color: rgb(0, 0, 0);">setMaxResults(int maxResult)
sets the maximum number of results to retrieve.
style="font-family: mon;"> query.
style="color: rgb(0, 0, 0);">setFirstResult(int startPosition)
sets the position of the first result to retrieve.
In the code below, we show the Item
entity class which maps to the item table that stores the
item instances. This is a
typical Java Persistence entity object. There are two requirements for
an entity:
- annotating the class with an
style="font-weight: bold; color: rgb(0, 0, 153);">@Entity
annotation.
- annotating the primary key identifier with
@Id
Because the fields name, description.... are basic mappings from the
object fields to columns of the same name in the database table, they
don't have to be annotated.
For more information on Netbeans and JPA see href="http://www.netbeans.org/kb/55/persistence.html">basics of
developing a web application using Java™ Persistence API.
| Code Sample from: Item.java |
@Id
|
style="font-weight: bold;">Conclusion
This concludes the sample application which demonstrates a
RESTful Web Service, coded using
JAX-RS: Java API
for RESTful Web Services (JSR-311) ,
which provides a list
of items, and a dojo
client which gets and displays the Web Service responses in
a dynamic Ajax table.
Configuration of the Application
for Netbeans 6.5m1 , Glassfish V2, and MySQL
- download and install
href="http://bits.netbeans.org/download/6.5/m1/" target="_blank">
NetBeans IDE 6.5 M1 or href="http://download.netbeans.org/netbeans/6.1/final/">Netbeans 6.1
-
href="https://glassfish.dev.java.net/public/downloadsindex.html">Download
and install href="https://glassfish.dev.java.net/public/downloadsindex.html">GlassFish
V2 and MySQL.
Another option is to download a bundle that includes href="http://java.sun.com/javaee/downloads/index.jsp">Sun Java
System Application Server 9.1 Update 1 with MySQL Community Server,
or you can href="http://download.netbeans.org/netbeans/6.1/mysql_bundle/"
target="_blank">download Netbeans 6.1, Glassfish V2 and MySQL in a
single bundle.
Running the Sample Code
- Download the
href="https://techdayscode.dev.java.net/servlets/ProjectDocumentList?folderID=9684&expandFolder=9684&folderID=9601">sample
code and extract its contents. You should now see the newly
extracted directory
as<sample_install_dir>/catalog, where<sample_install_dir>
is the directory
where you unzipped the sample package. For example, if you extracted
the contents toC:\on a Windows machine,
then your newly created directory should be atC:\catalog. - Start NetBeans IDE. Click Open Project in the File menu and
select thecatalogdirectory you just
unzipped. - Start the MySQL database as follows:
- Click the Services tab in the NetBeans IDE.
- Expand the databases node. You should see the MySQL server
database in the list of databases.src="http://blogs.sun.com/enterprisetechtips/resource/databaselist.jpg"
alt="Database list" align="bottom" border="0" height="62" width="267"> - Right-mouse click on the MySQL server database and select
Start.
- Create the catalog database as follows:
- Right-mouse click on the MySQL server database and select
Create Database. - Enter the database name catalog. This will open a New
Database Connection window. Click O.K. to accept the displayed
settings.
- Right-mouse click on the MySQL server database and select
- Create the tables in the MySQL catalog database as follows:
- Expand the Drivers node. You should a driver for the catalog
database in the list of drivers.src="http://blogs.sun.com/enterprisetechtips/resource/driverlist.jpg"
alt="Driver list" align="bottom" border="0" height="26" width="252"> - Right-mouse click on the catalog driver and select Connect.
- Right-mouse click on the catalog driver and select Execute
Command. This will open up a SQL command window. - Copy the contents of the
createdbmysql.sqlfile
in thecatalogdirectory and paste the contents into the
SQL command window. - Click the Run SQL icon
src="http://blogs.sun.com/enterprisetechtips/resource/runsql.jpg"
alt="Run SQL icon" align="bottom" border="0" height="28" width="28">
(Ctrl+Shift+E) above the SQL command window.
- Expand the Drivers node. You should a driver for the catalog
- Build the project as follows:
- Right click the
catalognode in
the
Projects window.
- Select Clean and Build Project.
- Right click the
- Run the project as follows:
- Right click the
catalognode in
the
Projects window.
- Select Run Project.
- Right click the
When you run the project, your browser should display the opening page
of the Sample Application (at
http://localhost:8080/catalog/).
For more Information:
-
href="http://dojotoolkit.org/book/dojo-book-0-9/docx-documentation-under-development/grid">Dojox
Grid -
href="http://www.sitepen.com/blog/2007/11/06/simple-dojo-grids/">Simple
Dojo Grids -
href="http://www.sitepen.com/blog/2007/11/13/dojo-grids-diving-deeper/">Dojo
Grids: Diving Deeper -
href="http://www.oreillynet.com/onlamp/blog/2008/02/dojo_goodness_part_1_1.html">Dojo
Goodness
-
href="http://blogs.sun.com/enterprisetechtips/entry/implementing_restful_web_services_in">Implementing
RESTful Web Services in Java - Generating
RESTful Web Services from Entity Classes tutorial - Jersey
(the JAX-RS reference implementation) - basics
of
developing a web application using Java™ Persistence API. -
target="bpcatalog">Java
Persistence reference page on GlassFish Project - Java
EE tutorial, for good tutorial on JPA - Pro
EJB 3: Java Persistence API book
- Login or register to post comments
- Printer-friendly version
- caroljmcdonald's blog
- 4590 reads






Comments
Hi Carol, Thanks for your
by pauljay - 2010-04-01 18:49
Hi Carol, Thanks for your tutorials, this Dojo one was helpful, I am only learning but I find your posts great. Thanks Paulby caroljmcdonald - 2009-03-23 06:40
This is a glassfish installation or configuration problem. please ask in the glassfish forumby arlpan - 2009-03-22 15:01
I'm also getting 'SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak'. I'm running on Vista. Is this a authorization or configuration error?by jhandal7 - 2009-02-09 19:56
Hi Carol Excellent tutorial. I download the project,after I deleted and install again, ang I got: SEVERE could not rename domain.xml to domain.xml.bak Please ,where in netbeans can I solve it? Thanks INFO: Launching GlassFish on Apache Felix OSGi platform Welcome to Felix. ================= INFO: Started bundle org.glassfish.common.glassfish-mbeanserver [7] INFO: Started bundle org.glassfish.core.kernel [96] INFO: Started bundle org.glassfish.common.common-util [78] INFO: Started bundle GlassFish-Application-Common-Module [63] INFO: APIClassLoader = Class Loader for Bundle [GlassFish-Application-Common-Module [63] ] INFO: registering service = org.apache.felix.framework.StartLevelImpl@19eda2c, contract = org.osgi.service.startlevel.StartLevel, name = null INFO: registering service = org.apache.felix.framework.PackageAdminImpl@1cef4f7, contract = org.osgi.service.packageadmin.PackageAdmin, name = null no resource bundle found for version, using default GlassFish version INFO: Started bundle org.glassfish.branding.branding [29] INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started INFO: Started bundle org.glassfish.common.internal-api [82] INFO: Started bundle org.glassfish.admin.config-api [70] INFO: Started bundle org.glassfish.registration.glassfish-registration [92] INFO: Started bundle org.glassfish.deployment.deployment-autodeploy [57] INFO: Started bundle org.glassfish.deployment.deployment-common [88] INFO: Started bundle org.glassfish.flashlight.flashlight-framework [91] INFO: Listening on port 8080 INFO: Network listener http-listener-2 on port 8181 disabled per domain.xml INFO: Listening on port 4848 INFO: Started bundle org.glassfish.common.container-common [99] INFO: The Admin Console Web Application has been downloaded. INFO: Started bundle org.glassfish.common.glassfish-naming [84] INFO: Started bundle org.glassfish.common.glassfish-api [100] INFO: GlassFish v3 Prelude startup time : Felix(27815ms) startup services(2262ms) total(30077ms) INFO: Started bundle org.glassfish.connectors.connectors-runtime [23] INFO: Total number of available updates : 2 INFO: Number of available updates since Sun Feb 08 15:30:54 CST 2009 : 0 INFO: Started bundle org.glassfish.transaction.jta [53] INFO: Started bundle org.glassfish.deployment.deployment-admin [69] INFO: Started JMXConnector, JMXService URL = service:jmx:rmi:///jndi/rmi://Renee-PC.myhome.westell.com:8686/jmxrmi INFO: Started bundle org.glassfish.web.war-util [115] INFO: validateJarFile(C:\Users\Juan\Desktop\Carol\catalog\build\web\WEB-INF\lib\grizzly-servlet-webserver-1.7.3.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class INFO: validateJarFile(C:\Users\Juan\Desktop\Carol\catalog\build\web\WEB-INF\lib\grizzly-servlet-webserver-1.7.3.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class INFO: Started bundle org.glassfish.persistence.jpa-connector [60] INFO: Started bundle org.glassfish.scripting.gf-jruby-connector [56] INFO: Started bundle org.glassfish.web.gf-web-connector [114] INFO: Started bundle org.glassfish.security.security [59] INFO: Started bundle org.glassfish.connectors.gf-connectors-connector [75] INFO: security.secmgroff INFO: Started bundle org.glassfish.security.securitycommon [19] INFO: Security startup service called INFO: Started bundle org.glassfish.security.realms [68] INFO: Security service(s) started successfully.... INFO: registering service = org.glassfish.web.DirContextURLStreamHandlerService@1c5cd7, contract = org.osgi.service.url.URLStreamHandlerService, name = null INFO: Started bundle org.glassfish.web.web-glue [106] INFO: Created HTTP listener http-listener-1 on port 8080 INFO: Created HTTP listener admin-listener on port 4848 INFO: Created virtual server server INFO: Created virtual server __asadmin INFO: Started bundle org.glassfish.deployment.dol [8] INFO: Started bundle org.glassfish.web.web-core [123] INFO: Dual registration of jndi stream handler: factory already defined INFO: Unknown loader 106.0 class org.apache.felix.framework.searchpolicy.ContentClassLoader INFO: Started bundle org.glassfish.web.jstl-connector [112] INFO: Started bundle org.glassfish.web.jsf-connector [119] INFO: Using com.sun.enterprise.transaction.JavaEETransactionManagerSimplifiedDelegate as the delegate INFO: Started bundle org.glassfish.connectors.work-management [34] INFO: Started bundle org.glassfish.common.glassfish-ee-api [46] INFO: Started bundle org.glassfish.connectors.connectors-internal-api [104] INFO: policy.loading INFO: Started bundle org.glassfish.security.websecurity [108] INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@14b2f1a class org.glassfish.internal.api.DelegatingClassLoader INFO: Loading application catalog at /catalog INFO: Deployment of catalog done is 10280 ms SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak INFO: AdminConsoleAdapter's STATE IS: The Admin Console Web Application has been downloaded. INFO: The Admin Console is installing... INFO: The Admin Console is already installed, but not yet loaded. INFO: The Admin Console is loading... INFO: Started bundle org.glassfish.admingui.console-common [43] SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak INFO: Started bundle com.sun.enterprise.hk2 [55] INFO: Started bundle org.glassfish.admingui.console-plugin-service [95] INFO: Started bundle org.glassfish.common.amx-api [10] SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak INFO: Started bundle org.glassfish.deployment.deployment-client [58] INFO: Started bundle org.glassfish.registration.registration-api [16] INFO: Started bundle org.glassfish.registration.registration-impl [37] INFO: Started bundle org.glassfish.javax.servlet [74] INFO: Started bundle com.sun.jsftemplating [48] INFO: Started bundle org.glassfish.admingui.dataprovider [20] INFO: Started bundle com.sun.pkg.client [49] INFO: Started bundle org.glassfish.admingui.console-security-plugin [30] INFO: Started bundle org.glassfish.admingui.console-branding-plugin [86] INFO: Started bundle org.glassfish.l10n.console-updatecenter-plugin-l10n [26] INFO: Started bundle org.glassfish.l10n.webui-jsf-suntheme-plugin-l10n [32] INFO: Started bundle org.glassfish.l10n.console-jdbc-plugin-l10n [85] INFO: Started bundle org.glassfish.l10n.console-core-l10n [11] INFO: Started bundle org.glassfish.l10n.console-web-plugin-l10n [47] INFO: Started bundle org.glassfish.l10n.webui-jsf-plugin-l10n [103] INFO: Started bundle org.glassfish.l10n.console-security-plugin-l10n [80] INFO: Started bundle org.glassfish.admingui.console-web-plugin [105] INFO: Started bundle org.glassfish.admingui.console-updatecenter-plugin [33] INFO: Started bundle org.glassfish.admingui.console-jdbc-plugin [83] INFO: AdminConsoleAdapter's STATE IS: The Admin Console is loading... INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@14b2f1a class org.glassfish.internal.api.DelegatingClassLoader INFO: Initializing Mojarra (1.2_10-b01-FCS) for context '' INFO: Loading application __admingui at / INFO: Loading __admingui Application done is 10563 ms INFO: The Admin Console application is loaded. INFO: Server shutdown initiated INFO: classLoader = WebappClassLoader delegate: true repositories: WEB-INF/classes/ ----------> Parent Classloader: org.glassfish.internal.api.DelegatingClassLoader@14b2f1a INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@1c5d644 INFO: Unknown loader 106.0 class org.apache.felix.framework.searchpolicy.ContentClassLoader INFO: classLoader = WebappClassLoader delegate: true repositories: WEB-INF/classes/ ----------> Parent Classloader: org.jvnet.hk2.osgiadapter.OSGiModulesRegistryImpl$1@191eb90 INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@1c5d644 INFO: [Thread[GlassFish Kernel Main Thread,5,main]] exiting INFO: Stopped bundle = org.glassfish.common.common-util [78] INFO: Stopped bundle = com.sun.jsftemplating [48] INFO: Stopped bundle = org.glassfish.registration.glassfish-registration [92] INFO: Stopped bundle = org.glassfish.web.web-core [123] INFO: Stopped bundle = org.glassfish.security.websecurity [108] INFO: Stopped bundle = org.glassfish.deployment.dol [8] INFO: Stopped bundle = org.glassfish.security.securitycommon [19] INFO: Stopped bundle = org.glassfish.deployment.deployment-client [58] INFO: Stopped bundle = org.glassfish.admingui.console-security-plugin [30] INFO: Stopped bundle = org.glassfish.javax.servlet [74] INFO: Stopped bundle = org.glassfish.persistence.jpa-connector [60] INFO: Stopped bundle = org.glassfish.security.realms [68] INFO: Stopped bundle = org.glassfish.registration.registration-impl [37] INFO: Stopped bundle = org.glassfish.web.war-util [115] INFO: Stopped bundle = org.glassfish.common.container-common [99] INFO: Stopped bundle = org.glassfish.web.jstl-connector [112] INFO: Stopped bundle = org.glassfish.common.glassfish-api [100] INFO: Stopped bundle = org.glassfish.connectors.connectors-internal-api [104] INFO: Stopped bundle = org.glassfish.web.jsf-connector [119] INFO: Stopped bundle = org.glassfish.admingui.console-branding-plugin [86] INFO: Stopped bundle = org.glassfish.admin.config-api [70] INFO: Stopped bundle = com.sun.enterprise.hk2 [55] INFO: Stopped bundle = org.glassfish.l10n.console-updatecenter-plugin-l10n [26] INFO: Stopped bundle = com.sun.pkg.client [49] INFO: Stopped bundle = org.glassfish.admingui.dataprovider [20] INFO: Stopped bundle = org.glassfish.l10n.webui-jsf-suntheme-plugin-l10n [32] INFO: Launching GlassFish on Apache Felix OSGi platform Welcome to Felix. ================= INFO: Started bundle org.glassfish.common.glassfish-mbeanserver [7] INFO: Started bundle org.glassfish.core.kernel [96] INFO: Started bundle org.glassfish.common.common-util [78] INFO: Started bundle GlassFish-Application-Common-Module [63] INFO: APIClassLoader = Class Loader for Bundle [GlassFish-Application-Common-Module [63] ] INFO: registering service = org.apache.felix.framework.StartLevelImpl@419d05, contract = org.osgi.service.startlevel.StartLevel, name = null INFO: registering service = org.apache.felix.framework.PackageAdminImpl@1deeb40, contract = org.osgi.service.packageadmin.PackageAdmin, name = null no resource bundle found for version, using default GlassFish version INFO: Started bundle org.glassfish.branding.branding [29] INFO: [Thread[GlassFish Kernel Main Thread,5,main]] started INFO: Started bundle org.glassfish.common.internal-api [82] INFO: Started bundle org.glassfish.admin.config-api [70] INFO: Started bundle org.glassfish.registration.glassfish-registration [92] INFO: Started bundle org.glassfish.deployment.deployment-autodeploy [57] INFO: Started bundle org.glassfish.deployment.deployment-common [88] INFO: Started bundle org.glassfish.flashlight.flashlight-framework [91] INFO: Listening on port 8080 INFO: Network listener http-listener-2 on port 8181 disabled per domain.xml INFO: Started bundle org.glassfish.common.container-common [99] INFO: Listening on port 4848 INFO: The Admin Console Web Application has been downloaded. INFO: Started bundle org.glassfish.common.glassfish-naming [84] INFO: Started bundle org.glassfish.common.glassfish-api [100] INFO: GlassFish v3 Prelude startup time : Felix(18174ms) startup services(2106ms) total(20280ms) INFO: Started bundle org.glassfish.connectors.connectors-runtime [23] INFO: Started bundle org.glassfish.transaction.jta [53] INFO: Started JMXConnector, JMXService URL = service:jmx:rmi:///jndi/rmi://Renee-PC.myhome.westell.com:8686/jmxrmi INFO: Started bundle org.glassfish.deployment.deployment-admin [69] INFO: Started bundle org.glassfish.web.war-util [115] INFO: validateJarFile(C:\Users\Juan\Desktop\Carol\catalog\build\web\WEB-INF\lib\grizzly-servlet-webserver-1.7.3.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class INFO: validateJarFile(C:\Users\Juan\Desktop\Carol\catalog\build\web\WEB-INF\lib\grizzly-servlet-webserver-1.7.3.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class INFO: Started bundle org.glassfish.persistence.jpa-connector [60] INFO: Started bundle org.glassfish.scripting.gf-jruby-connector [56] INFO: Started bundle org.glassfish.web.gf-web-connector [114] INFO: Started bundle org.glassfish.security.security [59] INFO: Started bundle org.glassfish.connectors.gf-connectors-connector [75] INFO: security.secmgroff INFO: Started bundle org.glassfish.security.securitycommon [19] INFO: Security startup service called INFO: Started bundle org.glassfish.security.realms [68] INFO: Security service(s) started successfully.... INFO: registering service = org.glassfish.web.DirContextURLStreamHandlerService@12d7d02, contract = org.osgi.service.url.URLStreamHandlerService, name = null INFO: Started bundle org.glassfish.web.web-glue [106] INFO: Created HTTP listener http-listener-1 on port 8080 INFO: Created HTTP listener admin-listener on port 4848 INFO: Created virtual server server INFO: Created virtual server __asadmin INFO: Started bundle org.glassfish.deployment.dol [8] INFO: Started bundle org.glassfish.web.web-core [123] INFO: Dual registration of jndi stream handler: factory already defined INFO: Unknown loader 106.0 class org.apache.felix.framework.searchpolicy.ContentClassLoader INFO: Started bundle org.glassfish.web.jstl-connector [112] INFO: Started bundle org.glassfish.web.jsf-connector [119] INFO: Using com.sun.enterprise.transaction.JavaEETransactionManagerSimplifiedDelegate as the delegate INFO: Started bundle org.glassfish.connectors.work-management [34] INFO: Started bundle org.glassfish.common.glassfish-ee-api [46] INFO: Started bundle org.glassfish.connectors.connectors-internal-api [104] INFO: policy.loading INFO: Started bundle org.glassfish.security.websecurity [108] INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@1f8f8c8 class org.glassfish.internal.api.DelegatingClassLoader INFO: Loading application catalog at /catalog INFO: Deployment of catalog done is 8330 ms SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak INFO: classLoader = WebappClassLoader delegate: true repositories: WEB-INF/classes/ ----------> Parent Classloader: org.glassfish.internal.api.DelegatingClassLoader@1f8f8c8 INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@114fc36 SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak INFO: validateJarFile(C:\Users\Juan\Desktop\Carol\catalog\build\web\WEB-INF\lib\grizzly-servlet-webserver-1.7.3.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class INFO: validateJarFile(C:\Users\Juan\Desktop\Carol\catalog\build\web\WEB-INF\lib\grizzly-servlet-webserver-1.7.3.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@1f8f8c8 class org.glassfish.internal.api.DelegatingClassLoader INFO: Loading application catalog at /catalog INFO: Deployment of catalog done is 3666 ms SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak INFO: AdminConsoleAdapter's STATE IS: The Admin Console Web Application has been downloaded. INFO: The Admin Console is installing... INFO: The Admin Console is already installed, but not yet loaded. INFO: The Admin Console is loading... INFO: Started bundle org.glassfish.admingui.console-common [43] SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak INFO: Started bundle com.sun.enterprise.hk2 [55] INFO: Started bundle org.glassfish.admingui.console-plugin-service [95] INFO: Started bundle org.glassfish.common.amx-api [10] INFO: Started bundle org.glassfish.deployment.deployment-client [58] INFO: Started bundle org.glassfish.registration.registration-api [16] INFO: Started bundle org.glassfish.registration.registration-impl [37] INFO: Started bundle org.glassfish.javax.servlet [74] INFO: Started bundle com.sun.jsftemplating [48] SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak INFO: Started bundle org.glassfish.admingui.dataprovider [20] INFO: Started bundle com.sun.pkg.client [49] INFO: Started bundle org.glassfish.admingui.console-security-plugin [30] INFO: Started bundle org.glassfish.admingui.console-branding-plugin [86] INFO: Started bundle org.glassfish.l10n.console-updatecenter-plugin-l10n [26] INFO: Started bundle org.glassfish.l10n.webui-jsf-suntheme-plugin-l10n [32] INFO: Started bundle org.glassfish.l10n.console-jdbc-plugin-l10n [85] INFO: Started bundle org.glassfish.l10n.console-core-l10n [11] INFO: Started bundle org.glassfish.l10n.console-web-plugin-l10n [47] INFO: Started bundle org.glassfish.l10n.webui-jsf-plugin-l10n [103] INFO: Started bundle org.glassfish.l10n.console-security-plugin-l10n [80] INFO: Started bundle org.glassfish.admingui.console-web-plugin [105] INFO: Started bundle org.glassfish.admingui.console-updatecenter-plugin [33] INFO: Started bundle org.glassfish.admingui.console-jdbc-plugin [83] INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@1f8f8c8 class org.glassfish.internal.api.DelegatingClassLoader INFO: Initializing Mojarra (1.2_10-b01-FCS) for context '' INFO: AdminConsoleAdapter's STATE IS: The Admin Console is loading... INFO: Loading application __admingui at / INFO: Loading __admingui Application done is 7732 ms INFO: The Admin Console application is loaded. INFO: classLoader = WebappClassLoader delegate: true repositories: WEB-INF/classes/ ----------> Parent Classloader: org.glassfish.internal.api.DelegatingClassLoader@1f8f8c8 INFO: SharedSecrets.getJavaNetAccess()=java.net.URLClassLoader$7@114fc36 SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bak INFO: validateJarFile(C:\Users\Juan\Desktop\Carol\catalog\build\web\WEB-INF\lib\grizzly-servlet-webserver-1.7.3.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class INFO: validateJarFile(C:\Users\Juan\Desktop\Carol\catalog\build\web\WEB-INF\lib\grizzly-servlet-webserver-1.7.3.2.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class INFO: Unknown loader org.glassfish.internal.api.DelegatingClassLoader@1f8f8c8 class org.glassfish.internal.api.DelegatingClassLoader INFO: Loading application catalog at /catalog INFO: Deployment of catalog done is 1841 ms SEVERE: Could not rename C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml to C:\Program Files\glassfish-v3-prelude\glassfish\domains\domain1\config\domain.xml.bakby caroljmcdonald - 2009-02-07 08:34
Bright, looks like your application has an Error with allocating a datasource connection. I haven't seen this problem myself. You could ask in the glassfish forumby dangoulet1 - 2009-02-06 22:46
Hi Carol, I just wanted to say thanks for this great idea. I'm going to give this a go sometime over the weekend. We've been using woodstock and feel it's too heavy and now that things are up in the air with that project it's time to start reviewing other technologies that will work with our existing Netbeans 6.0 JSF woodstock project. Cheers, Danby losintikfos - 2009-02-05 11:00
Hi Carol, I think this is a perfect kickstart tutorial - especially with all the pieces made coincise i mean JPA, JAXB, JAX-RS. Good job. One problem though, After deploying my application to Glassfish, i can run to access the catalog list from my browser as expected from the tutorial. But when the page is left idle for say 5min, there's no way i am able to get access to the page, as all get is the exception below; Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/2008))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: null Error Code: 0 at oracle.toplink.essentials.exceptions.DatabaseException.sqlException(DatabaseException.java:305) at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:150) at oracle.toplink.essentials.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:184) at oracle.toplink.essentials.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:582) at oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:280) at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:229) at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:93) at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:126) at oracle.toplink.essentials.internal.ejb.cmp3.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:99) at com.sun.enterprise.util.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:181) at com.sun.enterprise.util.EntityManagerWrapper.createQuery(EntityManagerWrapper.java:348) at service.ItemsResource.getEntities(ItemsResource.java:110) at service.ItemsResource.get(ItemsResource.java:61) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$TypeOutInvoker._dispatch(EntityParamDispatchProvider.java:136) at com.sun.jersey.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:85) at com.sun.jersey.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:123) at com.sun.jersey.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71) at com.sun.jersey.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111) at com.sun.jersey.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:63) at com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:722) at com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:692) at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:344) at javax.servlet.http.HttpServlet.service(HttpServlet.java:831) at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:290) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265) at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106) Caused by: java.sql.SQLException: Error in allocating a connection. Cause: null at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:115) at oracle.toplink.essentials.jndi.JNDIConnector.connect(JNDIConnector.java:145) ... 51 more The question, do you know what might be causing this RollBackException? Brightby caroljmcdonald - 2009-01-09 07:36
There was a change with Netbeans 6.5 , I uploaded a new version. You could also download the HOL which explains how to build the app from scratch.by sumved - 2009-01-09 05:23
One more point: When I am running this app on IE 6, it gives an alert with message: "Stack overflow at line: 17"by sumved - 2009-01-09 04:10
Hello Carol I am able to remove those java script errors. But, Now I am getting some exceptions when I start Glassfish V2 server. Exceptions are: javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.XWS_ClientProvider.property.signature.key.alias" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.ClientProvider.property.signature.key.alias" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.ClientProvider.property.security.config" javax.management.InstanceNotFoundException: No object matches the specified name "server.applications.lifecycle-module.JBIFramework.property.com.sun.jbi.home" javax.management.InstanceNotFoundException: No object matches the specified name "domain.applications.lifecycle-module.JBIFramework.property.com.sun.jbi.home" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.XWS_ServerProvider.property.signature.key.alias" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.XWS_ClientProvider.property.dynamic.username.password" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.ServerProvider.property.encryption.key.alias" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.ClientProvider.property.dynamic.username.password" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.ClientProvider.property.encryption.key.alias" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.XWS_ClientProvider.property.encryption.key.alias" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.XWS_ServerProvider.property.encryption.key.alias" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.ServerProvider.property.signature.key.alias" javax.management.InstanceNotFoundException: No object matches the specified name "server.security-service.message-security-config.SOAP.provider-config.ServerProvider.property.security.config" I am using Netbeans 6.5. Do you have petCatalog workspace build in Netbeans 6.5? Please help me out. Regards, Sumved shamiby sumved - 2009-01-07 12:39
I have tried it with IE 6.0 and Firefox as well. Though, When I tried testing Restful Web services, it runs fine. But, only the problem is on the client-side, I think.by caroljmcdonald - 2009-01-07 08:13
sorry I haven't seen that error, its probably related to your browser, which one are you usingby sumved - 2009-01-07 04:10
Hi Carol It has been really nice learning tho' your compact tutorial. Thanks for providing such a nice tutorial. I have a little issue while I was trying to run "catalog" project in Netbeans 6.5 On browser I get some javascript error: [ Error: Out of stack space ] [ Error: Out of memory ] [ Error: already called! ] [ Error: Object doesn't support this property or method ] Can you please suggest why I am getting this error? Thanking you. Regards, Sumved Shami