Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
Main
TextFormattingRules
WhatIsWiki




JSPWiki v2.2.33

[RSS]


Hide Menu

SandBox


Difference between version 318 and version 293:

At line 5 removed 1 line.
At line 8 changed 8 lines.
SqlRowSet rset = getJdbcTemplate().queryForRowSet(
"select id, name from mytest where id > ? and name < ?",
new Object[] {new Long(1), "Z"});
int i = 0;
while (rset.next()) {
i++;
System.out.println("Row" + i + " " + rset.getString(2));
}
import javax.naming.Context;
import javax.naming.InitialContext;
At line 17 changed 1 line.
}]
import junit.framework.TestCase;
At line 12 added 5 lines.
import org.mockejb.MockContainer;
import org.mockejb.SessionBeanDescriptor;
import org.mockejb.jndi.MockContextFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
At line 18 added 7 lines.
/**
* Parent TestCase class for testing EJBs using MockEJB
*
* @author mraible
*
*/
public abstract class MockEJBTestCase extends TestCase {
At line 26 added 8 lines.
/**
* This method sets up a MockContainer and allows you to deploy an EJB to
* it. Override <code>onSetUp()</code> to add custom set-up behavior.
*
* @see #onSetUp()
*/
protected final void setUp() throws Exception {
MockContextFactory.setAsInitial();
At line 35 added 11 lines.
Context ctx = new InitialContext();
ApplicationContext appCtx =
new ClassPathXmlApplicationContext(getConfigLocations());
ctx.bind("java:comp/env/jdbc/appDS", appCtx.getBean("dataSource"));
MockContainer mc = new MockContainer(ctx);
SessionBeanDescriptor dd = getDeploymentDescriptor();
mc.deploy(dd);
onSetUp();
}
At line 23 changed 2 lines.
If you are having problems with the root user account accessing mysql and setting up
the AppFuse database, the chances are you need to perform one of the following steps:
protected String[] getConfigLocations() {
return new String[] { "classpath:/applicationContext.xml" };
}
At line 26 changed 4 lines.
!Table of Contents
* [1] Set a password for root user
* [2] Your root account is not setup correctly
* [3] The grants for the test user account are not being setup properly
protected void onSetUp() throws Exception {}
At line 31 changed 1 line.
!!Set a password for root user [#1]
protected abstract SessionBeanDescriptor getDeploymentDescriptor();
}
At line 33 changed 2 lines.
To set a password for your mysql root user, edit the build.properties file and edit
these properties as neccesary:
}]
At line 58 added 2 lines.
[CreateDAO_zh]
[CreateDAO_sp]
At line 37 changed 9 lines.
{{{
#database.jar=${postgresql.jar}
#database.type=postgresql
#database.name=appfuse
#database.host=localhost
#database URL for creating other databases (doesn't work with pgsql)
#database.admin.url=jdbc:${database.type}://${database.host}/template1
#database.admin.username=postgres
#database.admin.password=postgres
[CreateManager_es]
At line 47 changed 4 lines.
#hibernate.dialect=net.sf.hibernate.dialect.PostgreSQLDialect
#database.driver_class=org.postgresql.Driver
#database.url=jdbc:${database.type}://${database.host}/${database.name}
}}}
[QuickStart Guide_es]
At line 52 changed 1 line.
!!Your root account is not setup correctly [#2]
[SpringControllerUnitTest]
At line 54 removed 4 lines.
When you login to mysql there are a number of databases available to you. One of
these databases is called mysql which is the 'system' database. Within the mysql
database, there is a table called 'users' which holds all the mysql user information,
along with their grants (their privileges).
At line 59 changed 112 lines.
The users table also contains a 'host' column. The root user needs a record entry
in the users table for each 'host' it is going to login from. ie. 'mypc', 'localhost'
and the wildcard '%'.
Both the grants, and the host columns need to be setup correctly for ant setup to
run smoothly.
These instructions tell you how to setup the root user with no password. Once you
have ant setup successfully, you can set a password on the root account.
(Please note: You do not have to setup the root account in this way, it is possible
to perform the following steps and give the root user a password, see [1]. But
the following steps should work for you.)
In this example, we will pretend your hostname is 'mypc'. Also, where ${MYSQL_HOME}
is shown, please replace that with the path to your mysql installation. At the end
of these steps, you should be able to login to your mysql database and see this:
$ mysql -u root
mysql> use mysql;
Database changed
mysql> select user, host, password from user where user = "root";
{{{
+------+-----------+----------+
| user | host | password |
+------+-----------+----------+
| root | localhost | |
| root | mypc | |
| root | % | |
+------+-----------+----------+
3 rows in set (0.00 sec)
}}}
and if you execute select * from user where user = "root"; we want to see Y's
on all the grant columns within the user table, which denotes that the root user
has all the neccesary grant options to be able to setup the appfuse database and
give the test user privileges on it.
First we want to stop the mysql db, so execute this command:
{{{
mysqladmin -u root -p shutdown
}}}
If mysql is still running (check the process on UNIX or use TaskManager on Windows),
then kill the process:
{{{
(UNIX) killall mysqld
(Windows) Use task manager or stop the mysqld service
}}}
Now we want to restart mysql but bypass the authentication tables so we can go in
and change the user database table, so now execute this command (UNIX command
given but for Windows, leaving out the ampersand):
{{{
${MYSQL_HOME}/bin/mysqld_safe --skip-grant-tables &
}}}
Now log back into mysql and remove any old root entries in your user table:
{{{
mysql -u root
use mysql;
delete from user where user='root';
commit;
FLUSH PRIVILEGES;
}}}
Now we want to setup the root user using the GRANT command, so execute the
following commands (Note you should change mypc to your hostname or hostname.domainname:
{{{
mysql -u root
use mysql;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'mypc' WITH GRANT OPTION;
FLUSH PRIVILEGES;
quit;
}}}
We now have the root user setup properly, lets restart mysql without bypassing
the authentication stuff.. Stop mysql using the instructions above once more.
Now, if you run ant setup you should be ok, if you are still getting errors,
it is likely you need to perform [Step 3|3].
!!The grants for the test user account are not being setup properly [#3]
If you are seeing an error message that says:
{{{
Invalid authorization specification message from server:
"Access denied for user: 'test@mypc' (Using password: YES)"
}}}
Then you need to change metadata/sql/mysql-create.sql to specify your hostname
(along with your domain name if you have one, else just your hostname).
Here is an example of what a modified file might look like if your hostname is 'mypc':
{{{
create database if not exists appfuse;
grant all privileges on appfuse.* to test@localhost identified by "test";
grant all privileges on appfuse.* to test@mypc identified by "test";
}}}
[δΈ­ζ–‡ζŒ‡ε—|Articles_zh]

Back to SandBox, or to the Page History.