Then I tried to deploy and run the Pet Store by running the following commands:
- in the application server directory /bin: asadmin start-domain
asadmin start-database
- in the Pet Store demo directory C:\J2EE\PetStore\latest\javapetstore-2.0-ea5: ant setup
ant run
Even though all commands were successful, the application won't start. More specifically I got the error "The requested resource () is not available" when navigating to http://localhost:8087/petstore.
So, without further ado, these are the steps I've performed to make it work.
1. in C:\J2EE\PetStore\latest\javapetstore-2.0-ea5\bp-project\build.properties I corrected the following variables:
a. javaee.home to point to my application server: c:/J2EE/Sun/AppServer
b. javaee.server.username to point to my username (the one I used when I installed Glassfish)
c. javaee.server.passwordfile to point to ${javaee.home}/samples/passwordfile
2. I created the file "passwordfile" under c:/J2EE/Sun/AppServer/samples containing a single line: AS_ADMIN_PASSWORD=myPassword (the password I chose when I installed Glassfish)
3. I also updated the file app-server.properties in C:\J2EE\PetStore\latest\javapetstore-2.0-ea5\bp-project with javaee.home=c:/J2EE/Sun/AppServer
At this point, I got the Pet Store demo running on the Glassfish server (after running again "ant setup" and "ant run"). However, only the first page was properly shown (http://localhost:8087/petstore/) and as soon as I navigated to "Enter the Store" (http://localhost:8087/petstore/faces/index.jsp), I saw a blank page.
Note: instead of running "ant run", you can also deploy the petstore.war from the /dist directory (or from /build) by using the Glassfish admin console:
By looking at the logging of the "ant setup" command I noticed that there was some issue with the username/password when trying to install the connection pool. I could also see this by inspecting the Glassfish log files (in the admin console, at http://localhost:4848/). So, I've done the following:
4. instead of relying on the ant script to install the connection pool and the data source (i.e. the ant setup command), I installed them by hand using the Glassfish admin console; see below the general properties of the connection pool:
Also, note the "Additional Properties":
Here I had to add the following properties: - Password with the value APP (I know this from the file app-server.properties, see 3), - DatabaseName with the value petstore (I found this by googling the web)
At this point if you click Ping under the General tab, you should get the message "Ping succeeded".
5. I also installed the data source (using the Glassfish admin console), which I called jdbc/PetstoreDB (I know this from the web.xml file):
Finally, I could navigate to http://localhost:8087/petstore/faces/index.jsp and got the Pet Store demo working properly ! (of course, don't forget to start the DB server and the application server by running: asadmin start-domain
asadmin start-database )
this was very very helpful. Thank you for sharing this!
ReplyDelete