




免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
dukes bookstore1. required softwarethe following software is required to run the examples. tutorial bundle java platform, standard edition sun java system application server netbeans ide apache ant tutorial bundlethe tutorial example source is contained in the tutorial bundle. to obtain the tutorial bundle, go to /javaee/5/docs/tutorial/information/download.html. the tutorial bundle is a zip file that you can unzip in a location of your choice.after you have installed the tutorial bundle, the example source code is in the tut-install/javaeetutorial5/examples/ directory, where tut-install is the directory where you installed the tutorial. the examples directory contains subdirectories for each of the technologies discussed in the tutorial. java platform, standard editionto build, deploy, and run the examples, you need a copy of java platform, standard edition 5.0 or java platform, standard edition 6.0 (j2se 5.0 or jdk 6). you can download the j2se 5.0 software from /javase/downloads/index_jdk5.jsp. you can download the jdk 6 software from /javase/downloads/.download the current jdk update that does not include any other software (such as netbeans or java ee). sun java system application serversun java system application server is targeted as the build and runtime environment for the tutorial examples. to build, deploy, and run the examples, you need a copy of the application server and, optionally, netbeans ide. you can download the application server from /javaee/downloads/.scroll down to the section entitled download the components independently and click the download link next to sun java system application server (based on glassfish v2).2. set up environment virables:a. set your java environment virablesb. set your classpath for java db as example shown below:classpath =c:sunappserverjavadblibderby.jar; c:sunappserverjavadblibderbytools.jar;. c. set your path for application server and ant as example shown below:path=c:sunappserverbin; c:sunappserverlibantbin3. starting the application serverto start the application server, open a terminal window or command prompt and execute the following:asadmin start-domain -verbose domain1or, on windows, you can choose:programs sun microsystems application server start default server4. starting the java db database serverthe application server includes the java db database.to start the java db database server, open a terminal window or command prompt and execute:asadmin start-databaseon windows, from the start menu, choose:programs sun microsystems application server start java db5. accessing databases from web applicationsdata that is shared between web components and is persistent between invocations of a web application is usually maintained in a database. to maintain a catalog of books, the dukes bookstore examples described in chapters chapter4, java servlet technology through chapter15, internationalizing and localizing web applications use the java db database included with the application server.to access the data in a database, web applications use the new java persistence api (see chapter24, introduction to the java persistence api). see chapter25, persistence in the web tier to learn how the dukes bookstore applications use this api to access the book data.to run the dukes bookstore applications, you need to first populate the database with the book data and create a data source in the application server. the rest of this section explains how to perform these tasks.6. populating the example databasewhen you deploy any of the dukes bookstore applications using ant deploy, the database is automatically populated at the same time. if you want to populate the database separately from the deploy task or are using netbeans ide to deploy the application, follow these steps:1. in a terminal window, go to the books directory or any one of the bookstore1 through bookstore6 example directories.2. start the java db database server. for instructions, see starting and stopping the java db database server. you dont have to do this if you are using netbeans ide. it starts the database server automatically.3. type ant create-tables. this task runs a command to read the file tutorial.sql and execute the sql commands contained in the file.4. at the end of the processing, you should see the following output:5. .sql 181 of 181 sql statements executed successfullywhen you are running create-tables, dont worry if you see a message that an sql statement failed. this usually happens the first time you run the command because it always tries to delete an existing database table first before it creates a new one. the first time through, there is no table yet, of course.7. creating a data source in the application servera datasource object has a set of properties that identify and describe the real world data source that it represents. these properties include information such as the location of the database server, the name of the database, the network protocol to use to communicate with the server, and so on.data sources in the application server implement connection pooling. to define the dukes bookstore data source, you use the installed derby connection pool named derbypool.you create the data source using the application server admin console, following this procedure:1. expand the resources node.2. expand the jdbc node.3. select the jdbc resources node.4. click the new. button.5. type jdbc/bookdb in the jndi name field.6. choose derbypool for the pool name.7. click ok.8. make sure the application server was regiested to netbeansto run the tutorial examples in netbeans ide, you must register your application server installation as a netbeans server instance. follow these instructions to register the application server in netbeans ide.1. select toolsservers manager to open the server manager dialog.2. click add servers.3. under server, select sun java system application server and click next.4. under platform location, enter the location of your application server installation.5. select register local default domain and click next.6. under admin username and admin password, enter the admin name and password created when you installed the application server.7. click finish.9. to deploy and run the application using netbeans ide, follow these steps:step 1 in netbeans ide, select fileopen project folder.step 2 in the open project dialog, navigate to:tut-install/javaeetutorial5/examples/web/select the bookstore1 folder.step 3 select the open as main project check box and the open required projects check box.step 4 click open project folder.1. in the projects tab, right-click the bookstore1 project, and select deploy2. to run the application, right-click the bookstore1 project, and select run or open the bookstore url http:/localhost:8080/bookstore1/bookstore.troubleshooting dukes bookstore database problemsthe dukes bookstore database access object returns the following exceptions: booknotfoundexception: returned if a book cant be located in the bookstore database. this will occur if you havent loaded the bookstore database with data or the server has not been started or has crashed. you can populate the database by running ant create-tables. booksnotfoundexception: returned if the bookstore data cant be retrieved. this will occur if you havent loaded the bookstore database with data or if the database server hasnt been started or it has crashed. unavailableexception: returned if a servlet cant retrieve the web context attribute representing the bookstore. this will occur if the database server hasnt been started.because you have specified an error page, you will see the messagethe application is unavailable. please try later.if you dont specify an error page, the web container generates a default page containing the messagea servlet exception has occurredand a stack trace that can help you diagnose the cause of the exception. if you use errorpage.html, you will have to look in the server log to determine the cause of the exception.building the examples on the command-line using ant (if you want to try)build properties common to all the examples are specified in the perties file in the tut-install/javaeetutorial5/examples/bp-project/ directory. you must create this file before you can run the examples. copy the file perties.sample to perties and edit it to reflect your environment. the tutorial examples use the java blueprints build system and application layout structure.to run the ant scripts, you must set common build properties in the file tut-install/javaeetutorial5/examples/bp-project/perties as follows: set the javaee.home property to the location of your application server installation. the build process uses the javaee.home property to include the libraries in as-install/lib/ in the classpath. all examples that run on the application server include the java ee library archive, as-install/lib/javaee.jar. in the build classpath. some examples use additional libraries in as-install/lib/; the required libraries are enumerated in the individual technology chapters.note - on windows, you must escape any backslashes in the javaee.home property with another backslash or use forward slashes as a
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 食品安全知识培训反思课件
- 郑州保安考试题库及答案
- 人文助手考试题库及答案
- 食品安全投资知识培训总结课件
- DB61T 1258-2019 地理标志产品 洛南豆腐
- 大专发动机题库及答案
- DB61T 1217-2018 变形金属超声波水浸C扫描检测方法
- 2025年各种交通标识题库及答案
- 2025年中班减法算法题目及答案
- 2025年工业自动化领域招聘面试模拟题及解析
- 2025湖北省监督数据分析应用中心专项招聘22人考试参考试题及答案解析
- 文创市集限定摊位协议
- 2025秋人教部编版三年级上册语文教学计划
- 妇产科护理 课件06章-正常产褥期母婴的护理
- 《劳模工匠之光》课件 第1、2单元 民族大厦的基石、改革攻坚的先锋
- 2025年中国癌症筛查及早诊早治指南(试行)
- 2025年全国企业员工全面质量管理知识竞赛题库及答案
- 基孔肯雅热防控指南专题课件
- 2025年中级钳工技能鉴定考核试题库(附答案)
- 2025秋教科版科学二年级上册教学课件:第一单元第1课 动物的家
- GB/T 15620-2025镍及镍合金实心焊丝和焊带
评论
0/150
提交评论