Setting up your windows computer to run jpetstore 3.x with mysql and tomcat

xiaoxiao2021-03-06  41

Table of contents

Revision History Motivation Special Note: Transactions Walkthrough

Java Tomcat JPETSTORE - Download mysql mysql jdbc driver jpetstore - Database JPETSTORE - DEPLOY JPETSTORE - DRIVER SETUP TROUBLESHOOTING

No action instance for path / shop / index could be created Error getting transaction can't get transactions to work on red hat 9.0! / Edited my.cnf - now mysql doesn't start! Comments

My personal site / Tutorial Requests - by Adrian Lanning Linux - Transactions / INNODB / my.cnf - by Adrian Lanning Transactions / INNODB / my.cnf - by Chris Smith Create User / GRANT usage - by Chris Smith Access Denied / GRANT usage - by Marc Mulzer Linux Install - by George Entenman Solaris Install - By Christoph Kutzinski

Revision HistoryVersion 2.2.2 - 02/13/04

Added Trouplashooting Ticket On Red Hat 9.0. Added New Comment On Setting Up Transactions 2.2.1 - 01/27/04

Updated JPetStore sql scripts to use a lowercase jpetstore database name for better compatibility with * nix systems Added Christoph's comment on installing JPetStore on Linux Added comment on installing JPetStore on Solaris Version 2.2 -... 01/22/04

Added 'USE JPETSTORE;' line to top of 'jpetstore-mysql-dataload.sql' file as Chris Smith recommends Added link to 'jpetstore-mysql-schema-innodb.sql' file Chris sent me Added a comments section where helpful.. Correspondence Will Go. Version 2.1 - 01/11/04

SHIFTED HOSTING TO My Personal Website. Added Links To SQL Scripts and Made Minor Changes To JpetStore - Database. Version 2 - 12/30/03

Changed tutorial to html format. Included Linux-friendly mysql scripts (thanks to maria tzvetanova). Version 1 - 10/13/03

ORIGINAL Writing

Motivation

I Made this Walkthrough in The Hopes of Saving Someone Some Time When Installing Clinton Begin's Excellent JPETSTORE APPLICATION.

This Guide Will Walk You Through The Steps Involved in Setting Up A Windows System To Run JpetStore. It Does Not Assume Any Prior Installation / Configuration of Dependent Software.

Linux / Solaris 9 Note:

The Steps in this Walkthrough Are Generally The Same for a Linux or Solaris 9 Installation.

George Let Me Know How He Got JpetStore to Work On Linux and Christoph Let Me Know How does Solaris 9.

Maria Tzvetanova pointed out that the lowercase table names in the mysql setup scripts In Version 1 caused errors when used on Linux systems. This is because (unlike Windows) MySQL on Linux is case-sensitive. She has supplied updated mysql scripts with uppercase table names Which is inclined in Version 2.

Special NOTE: TRANSACTIONS

The MySQL scripts that come with this walkthrough set up tables of the default (ISAM) type. These tables do NOT support transactions but are very fast. The MySQL driver is smart enough to act as if transactions occur so that transaction-aware software (like Will Still Run Fine. But in reality, Each SQL Command is a seperate "transaction".

If you need Transaction Support, Use The MySQL Script That Comes with the jpetstore distribution (in the ddl / mysql directory). That file buys InnoDB Tables Which Do Support Transactions.

You Will Still Need To Set Up A User So You Can Still Use The JpetStore-MySQL-Create-User.sql Script.

Note: Check Out Chris Smith's Helpful Comment Regarding The Use of InnoDB Tables.

Chris Sent Me A Modified Version of The InnoDB Schema Script That Comes with Jpetstore Which Supports Re-Running The Script To Reset The Database To The Starting State. See The Above Comment.walkthrough

Java

Download Java SDK 1.4.2_01 (Had Trouble Using The NetBeans Bundle So I Recommend Using The Regular SDK Package). Tomcat

Download and Install The Latest version of tomcat from http://jakarta.apache.org/site/binindex.cgi.

I install all my Apache apps to. "C: / program files / apache" to keep it simple Just keep all the other defaults the same, and input your preferred admin password when prompted Start Tomcat You can use either the Windows Service or.. The Start Menu Shortcut, "Start-> Programs-> Apache Tomcat 5.0-> Start Tomcat". Verify Tomcat IS Working Correctly. goto http: // localhost: 8080. If you see a tomcat base page you're good. goto http: // localhost: 8080 / jsp-examples and try out a couple of the examples to confirm that Tomcat is working properly.Note: I had trouble getting the example, http: // localhost: 8080 / jsp-examples / jsp2 / misc / config.jsp to work. to fix this exception I followed the on-screen instructions and copied "$ JAVA_HOME / lib / tools.jar from the JDK to the common / lib directory of the Tomcat server, followed by a Tomcat restart. ":) JPETSTORE - Download

Download and UNZIP The Latest Version of JpetStore to a Temp Directory. MySQL

Download mysql 4.0.14b, unzip, and run setup. Goto your default mysql directory (c: / mysql for me) and copy my-medium.cnf to my.cnf. Now move my.cnf to c: /. Open a commnd Prompt (dos prompt). Now goto, "c: / mysql / bin" and run, "mysqld-nt -install". This Will Install the mysql daem (Server) AS WINDOWS Service That Will Start Automatically When Windows Starts. You Can Verify this by going to start-> control panel-> administrative tools-> services underwin2000. Start the mysql service.win2000:

Go to Start-> Control Panel-> Administrative Tools-> Services.

Double-Click The MySQL Service

Click The Start Button.

Set root mysql password. *** Very important step ***

GOTO "C: / MySQL / BIN". Run "mysqladmin -uroot password new-pass" where new-pass: don't type the quotes ... verify mysql is Running Correctly.

Run "mysql -uroot -p". You will be promoted for a password. Just Enter in whatver you type for new-pass. You Should See a "mysql>" Prompt. If not, check Google for Whate Error Code You Received. Run "Show Databases;". Note: Don't forget the ';' '. If you ever see a prompt with just a "->" THEN you know you forgot the'; '. If you don't see, - ---------

| Database |

--------

| mysql |

| Test |

--------

2 rows in set (0.02 sec)

THEN you know Something is Wrong ... try google. MySQL JDBC Driver

Download The MySQL JDBC Driver, MySQL-Connector-Java-3.0.9-Stable. Unzip The Driver. Copy The File, "MySQL-Connector-Java-3.0.9-Stable-bin.jar" to Tomcat's Common / Lib Directory. JPETSTORE - DATABASE

Now download these files to your computer: jpetstore-mysql-schema.sql or jpetstore-mysql-schema-innodb.sql if you want transaction support (see Chris's comment) .jpetstore-mysql-dataload.sql jpetstore-mysql-create-user .sql Make sure you logged out of mysql, jump back to your shell prompt, and execute the following commands. "mysql -uroot -p

Find jpetstore.war in the build / wars folder of wherever you unzipped the JPetStore download to Copy jpetstore.war to your Tomcat / webapps folder For me this was at.. "C: / Program Files / Apache / Tomcat 5.0 / webapps". Tomcat Will AutomaticLoy your app if you have it started. If it's not started just follow the instructions in step 2. don't try to access (run) The app yet. JPETSTORE - Driver Setup

Find /webapps/jpetstore/WEB-INF/classes/properties/petstore.properties from your Tomcat directory. (C: / program files / apache / tomcat 5.0, for me) Change the default (oracle) values ​​to match the following: SimpleDriver = org.gjt.mm.mysql.driver

SimpleURL = JDBC: MySQL: // localhost: 3306 / JPETSTORE

SimpleuserName = JPETSTORE

Simplepassword = ibatis9977

Save it! Test

Shutdown and restart your Tomcat Web Server by either stopping the Service or using the System Tray icon Once Tomcat has restarted, click here (link will open a new window):. Http: // localhost: 8080 / jpetstore Have fun Troubleshooting.!

I raising ''. :)

NO Action Instance for Path / Shop / Index Could Be CREATED Message: http status 500 - no action instance for path / shop / index could be

created

Description: The Server Encountered An Internal Error (no action instance

For path / shop / index could be created) That prevented it from fulfecting

This Request.

I got this error by deleting the JDBC driver from Tomcat's common / lib directory If you see this error, follow the directions in Step 5, and then restart the Tomcat server Note:.. The "No action instance for path ..." error will occur ANY time Tomcat can not instantiate an action (usually because it can not find a required library / jar file) so there are many different reasons why you might be getting this error.In general, check the log files in% CATALINA_HOME% / Logs and see if you can find what's causeing the error.

Access Denied / Error Getting Transaction Unhandled Exception: com.ibatis.db.dao.daOException: Error getting transaction.

Cause: java.sql.sqlexception: Invalid Authorization Specification, Message from

Server: "Access Denied for User: 'JPETSTORE @ localhost'" "

<---- Caused by: java.sql.sqlexception: Invalid Authorization Specification,

Message from Server: "Access Denied for User: 'JPETSTORE @ localhost' (Using

Password: yes) "---->

I got this error by deleting the jpetstore @ localhost user from MySQL See Step 6. Note:. While porting the iBATIS JPetStore to use MySQL I had a big problem where I got this error even when I had clearly created a 'jpetstore' user. After trying a few things out, I found out you have to make the user as 'jpetstore @ localhost' rather than 'jpetstore' in order for this to work If anybody knows why this occurs, please let me know Note:.. Several people have emailed me with helpful comments regarding this error See Chris's comment and Marc's comment below.Can't get Transactions to work on Red Hat 9.0 / Edited my.cnf -.! Now Mysql does not start 040213 22:34:42 mysqld! Ended

040213 22:34:48 mysqld started

InnoDB: error: log file / var / lib / mysql / ib_logfile0

IS of diffreent size 0 5242880 bytes

InnoDB: Than specified in the .cnf file 0 67108864 BYTES!

040213 22:34:48 can't init damases

040213 22:34:48 aborting

For a more thorough look at this problem see my comment below. I recently set up INNODB transactions on Red Hat 9.0 and had problems. My Red Hat 9.0 came with mysql installed. I thought transactions were working but they were not. I found there Was no my.cnf file (usually at /etc/my.cnf). i copied my-large.cnf to /etc/my.cnf and change it to fit my system as per theinnodb Reference Manual Ten I Tried Restarting MySQL .. .no luck. Nothing happened. Found the above error in the innodb error log file. Solution This only works if you do not care about your innodb transaction backups! Although to get this error, InnoDB probably was not working in the first place . Just move those log files to ib_logfile0.bak, ib_logfile1.bak, etc. and start mysql again. Consequences This solution is not elegant but it works. At least it worked for me because I did not have any real data in the innodb Tables anyways. InnoDB Stores All Transactions in it's log files so by moving those, i probably eRased all the ba Ckups of my transactions. If you have data you need to save, you'll Have to get help from homeone wiser tr.;) Comments

One of the best parts About sharing online is getting great feedback. I've incruded what I felt to be the most useful / mot>.

My Personal Site / Tutorial Requests - by Adrian Lanning if anyyone Has Any Tutorial Requests or Would Like to Collaborate with Me

On Writing Tutorials / Walkthroughs for Other Apps Email ME and Let's Talk.

Curious About Me? Here's a Link to My Personal Website

Hosted by The Great People At SDF.

Note: SDF IS A Non-Profit Corp. Offering A Website, Mail, And UNIX Shell Access For A $ 36 One-Time Fee! (AND no''m not getting paid to sign That.) I've been a member for About A year now and a friend of mine Has Been for over 10 years.linux - Transactions / InnoDB / My.cnf - by Adrian Lanning Chris Writes in His Comment Below: Transactions:

IF you are going to use the innodb table structure, i think the innodb

Entries in my.cnf will also need to be uncommeted and set to point points

EXISTING PATHS.

I recently set up INNODB transactions on Red Hat 9.0 and had problems I'd like to share their solutions here Ok, my Red Hat 9.0 came with mysql installed The regular INNODB files were also in the mysql data directory:... Ibdata1

IB_Logfile0

Ib_logfile1

...

So I thought transactions might be working. I tried my app out and found that although I had set the table type to INNODB, transactions were, in fact, NOT working. Then I remembered Chris's comment and checked the my.cnf file. On Linux IT is usually located at: /etc/my.cnf

I checked but it isn n't there. So i search the whole computer: Find / -Name my.cnf -print

STILL NO Luck. OK, SO I'll Make My OWN. I copied my-large.cnf to /etc/my.cnf and change a few settings to fit my system as per the innoDB Reference Manual. Then i Started Up mysql Again Using The Red Hat Service Script ... Service MySQL Start

Nothing happened. Now on Red Hat 9.0, the mysql service script (located at /etc/rc.d/init.d/mysql) uses safe_mysqld. Safe_mysqld will not output any error messages to the console, they all get logged. So checking The ServerName.ERR log file (where servername is your server's name), i Found this error message: 040213 22:34:42 mysqld end

040213 22:34:48 mysqld started

InnoDB: error: log file / var / lib / mysql / ib_logfile0

IS of diffreent size 0 5242880 bytes

InnoDB: Than specified in the .cnf file 0 67108864 BYTES!

040213 22:34:48 can't init damases

040213 22:34:48 aborting

So now I know what the problem is ... The solution? Well I just moved those log files to ib_logfile0.bak, ib_logfile1.bak, etc. and started mysql again. Consequences This solution is not elegant but it works. At least it Worked for Me Because I Didn't Have Anyways InnoDB Tables ANYWAYS. INNODB TABLES All Transactions in It's Log Files SO BY MOVING THOSE, I PROBABLY ERASED All The Backups of My Transactions.

Transactions / InnoDB / My.cnf - by Chris Smith Transactions:

IF you are going to use the innodb table structure, i think the innodb

Entries in my.cnf will also need to be uncommeted and set to point points

EXISTING PATHS.

...

I'VE Included A DB Create Script That I'VE Used for MySQL and JPETSTORE

That Uses InnoDB Tables Where The Tables May Be Used in Transactions,

OtherWise Myisam Tables Are Used. The Script Started Out as The One ONE

Included in the JPETSTORE DISTRIBUTION But Modified to Enable Re-Running

WITHOUT Any Errors - I.E. Tables Always Dropped and recreated.

JPETSTORE-MySQL-Schema-Innodb.sql

---------------

Chris Smith

Pegasus Consultants (South West) Ltd

Http://pegasus-sw.com

Note: I use INNODB tables and upon checking my my.cnf file, I found that I did not have the INNODB sections uncommented Transactions appear to be working for me so those lines may just override some default settings in MySQL.In any case,. I'm Gonna Be Safe And Follow Chris's Advice.

Create User / Grant Usage - by Chris Smith Creation of The JpetStore User.mysql Provides for the Same User from Different Hosts Being Assigned

Different Privileges. this is done through the granting of rights, the

Mysql Manual Gives All The next..

http://www.mysql.com/doc/en/grant.html

The Following Extract of this page page details the usage:

In Order to Accommodate Granting Rights To Users from Arbitrary Hosts, MySQL

Supports specifying the user_name value in the form user @ Host. if you want

To Specify A User String Containing Special Characters (Such as `- '), or A

Host String Containing Special Characters or Wildcard Characters (SUCH AS)

`% '), you can quote the username or hostname (for example,

'Test-user' @ 'Test-hostname').

You can Specify Wildcards in The Hostname. For example, user@'%.loc.gov '

Applies to user for any host in the loc.gov domain, and user@'144.155.166.% '

Applies to User for any host in the 144.155.166 class c subnet.

The Simple Form User IS A Synonym for User @ "%".

If You Want a User Jpetstore to have access to the database from any host,

Just Define It with a wildcard to specify the Host

MySQL> Grant SELECT, INSERT, UPDATE, DELETE ON JPETSTORE. * to jPETSTORE @ "%"

Identified by 'Password';

)

To Verify from Which Hosts Have Access To your database from the jpetstore

User:

Mysql> USE Mysql;

Mysql> Select User, Host from User Where User = 'JPETSTORE';

--------- ----

| User | Host |

--------- ----

| JPETSTORE |% |

--------- ----

---------------

Chris Smith

Pegasus Consultants (South West) Ltd

Http://pegasus-sw.com

Access Denied / Grant Usage - by Marc Mulzer a Very Common Error Is To INSERT A New Error With Host = '%' And User = 'Some

User ', Thinking That this Will Allow you to specify localhost to connect

From The Same Machine. The Reason That this Doesn't Work Is That The Default

Privileges include an entry with host = 'localhost' and user = ''. Because That

Entry Has A Host Value 'Localhost' That Is More Specific Than '%, IT IS

Used in preference to the new entry when connecting from localhost! the

Correct Procedure Is To INSERT A Second Entry with Host = 'LocalHost' and

User = 'some_user', or to remove the entry with host = 'localhost' and user = ''.

http://www.mysql.com/doc/en/access_denied.html

I prefer to grant my users access on a Table-Level, Which Does Not Seem To

Have this Issue, Because there no default privileges defined on the

Table space itself.

So, Next Time Try Something Like

Grant SELECT, INSERT, UPDATE, DELETE ON SOMEDATABASE.SOMETABLE TO SOMEUSER

Identified by 'somepass';

You Should See That The Access Is Actually Stored in The Tables_Priv Table

WHEN You Grant On A Table Level. with no hostname specified, mysql associums

'localhost' and if Tomcat is Running on The Same System you shop Have No

PROBLEMS.

Works Much Better for Me Than Granting ON A Database Level, Is More Granular

And therefore more second.

Sidenote: Remember Thathen you mess with the access-level tables Directly,

You have to Issue a 'mysqladmin flush-privileges' to activate the permissions.

So, Always Stick with grant and revoke.

Give it a shot and let me know if it worked for you! ---------------

Marc Mulzer

Team LEAD

Maximus Server Provisioning

Dell Inc.

Linux Install - by George Entenman Well, I'm happy to say that someone finally sent me instructions on how to install JPetStore for Linux Thanks George Thank you for your wonderful guide to setting up jpetstore on windows!!.

I used it for my linux setup and weghty you'd like to know the changes

I had to make to get your setup to work.

First, I Had to Lowercase The Name of the Database from "jpetstore" to

"JPETSTORE" in these Three files:

JPETSTORE-MySQL-Schema-Innodb.sql

JPETSTORE-MySQL-DataLoad.sql

JPETSTORE-MySQL-CREATE-User.sql

Secondly, After Creating The User, I Had to Run:

mysqladmin -u root -p reeload

I hope this is of some use to you. Thanks so much for your help.

--ge (George Entenman, Chapel Hill, North Carolina, US)

Note: MySQL database url's on Solaris and Linux are apparently case-sensitive I would imagine that if you changed the SimpleUrl attribute in petstore.properties file to:. SimpleUrl = jdbc: mysql: // localhost: 3306 / JPETSTOREyou would not have to Change the SQL Files ... if anybody tests this out and it works, please let me know.

Solaris Install - by Christoph Kutzinski Christoph Got Jpetstore Working On Solaris, And Let Me Know ~ Thanks Christoph! ...

Now I Tried It On Solaris 9 Where I Got A "Table JPETSTORE" Not found

Found Message When Running JpetStore.

After Changing The JpetStore In The SQL-Scripts To Lowercase It Wort.

-ChristoPH Kutzinski

转载请注明原文地址:https://www.9cbs.com/read-54574.html

New Post(0)