SOCKET
Running in the Derby
The Derby database, of course. Going on general reports, recommendations from a colleague, and mutterings from my Auntie Fanny, the decision has been made to use Apache Derby as the back end for the jUDDI registry. The most obvious advantage is ease of deployment and portability. The whole of SOCKET can be wrapped up in a WAR with the derby.jar file nicely stowed away inside.
Derby is ridiculously straightforward to crank up, especially with the aid of the book, Apache Derby - Off to the Races - Includes Details of IBM Cloudscape, by Paul C. Zikopoulos, Dan Scott and George Baklarz out of IBM Press, Pearson (2006). This book is a real pleasure to fondle. Beautiful crisp, black, blue and white IBM theme with a blurred hossie on the front. A sturdy hardback, well laid out and good quality paper.
I provide below some jottings on how to start experimenting with the database under Java on Windows XP.
Get the latest stable release from http://db.apache.org/derby/derby_downloads.html. This is presently 10.1.2.1. The lib download is fine: db-derby-10.1.2.1-lib.zip.
Unzipping this download reveals a few derby jars plus some internationalization jars. For the moment, the two important ones here are derby.jar and derbytools.jar. derby.jar contains the database files while derbytools.jar has inside it 'ij', the Apache Derby JDBC scripting tool, using which you can execute SQL scripts against Derby databases.
Add these two files to your Java classpath by first opening the My Computer window, right-clicking and selecting Properties to summon the System Properties window. Select the Advanced tab and then the Environment Variables button. Make a new user variable called CLASSPATH. My value for this was
D:/derby/db-derby-10.1.2.1-lib/lib/derbytools.jar;D:/derby/db-derby-10.1.2.1-lib/lib/derby.jar
If there are already entries in the CLASSPATH variable, just tack these two soldiers on the end with semi-colon separators.
Now you can use the ij tool to create a database as shown below.
There is now a directory D:/JUDDI containing the Derby files for the JUDDI database. You can add a path to the directory when you create it.
Add dataEncryption=true;bootPassword=myBootPassword to encrypt the newly created database. In this case the bootPassword property of the connection object must be set to myBootPassword to gain access.
Now you can write a little Java program to access the database:
package derbytest;
import java.sql.*;
import javax.sql.*;
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
public class DerbyCranker {
public DerbyCranker() {
}
public static void main(String[] args) {
DerbyCranker derbyCranker1 = new DerbyCranker();
String DerbyDriver = "org.apache.derby.jdbc.EmbeddedDriver";
try {
Class.forName(DerbyDriver).newInstance();
System.out.println("Driver located and loaded.");
}
catch (Exception NoDriver) {
System.out.println("No driver: " + DerbyDriver);
System.exit(1);
}
String url = "jdbc:derby:D:/JUDDI";
Properties properties = new Properties();
properties.put("retrieveMessagesFromServerOnGetMessage", "true");
try {
Connection conn = DriverManager.getConnection(url, properties);
.
.
.
conn.close();
}
catch (SQLException se) {
String SQLState = se.getSQLState();
String SQLMessage = se.getMessage();
System.out.println("Error: " + SQLState);
System.out.println(SQLMessage);
}
}
}
Hours of fun.
Posted at 05:06PM May 19, 2006 by Brian Peter Clark in Misc technical |
jUDDI Installation
jUUDI Installation
The installation of jUDDI is fairly straight forward, however, there are some quirks...as with all things.
The quirks lie with installing jUUDI on Tomcat 5.5.x as opposed to 5.0.x and below. I'll shall come to this in a bit.
Firstly, download the jUDDI package into your home directory from:-
http://ws.apache.org/juddi/releases.html
Get the latest and greatest.
tar zxvf juddi.tar.gz
Then copy the .war file that resides within the jUDDI directory into your webapps directory
cp juddi/juddi.war /path/to/tomcat/webapps
MySQL - Database creation and population
You need to run 2 x .sql scripts that come with the jUDDI package. These are:-
/path/to/juddipackage/sql/mysql/create_database.sql
/path/to/juddipackage/sql/mysql/insert_publishers.sql
You can run these by doing the following:-
# mysql -u root -p < /path/to/juddipackage/sql/mysql/create_database.sql
password:
# mysql -u root -p juddi
< /path/to/juddipackage/sql/mysql/insert_publishers.sql
password:
You now need to populate the database with a user. Do this by logging into the MySQL console and running the following sql.
# mysql -u root -p
password:
mysql> use juddi;
INSERT INTO PUBLISHER (PUBLISHER_ID,PUBLISHER_NAME,IS_ADMIN,IS_ENABLED)
VALUES ('jdoe','John Doe','false','true');
Final tweaks
Finally, create a file called juddi.xml in /path/to/tomcat/server/Catalina/localhost and enter the following:-
<Context path="/juddi"
docBase="juddi" debug="5" reloadable="true"
crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_juddiDB_log" suffix=".txt"
timestamp="true"/>
<!-- the Resource element will probably work better for
you on Tomcat 5+ if you simply use a Resource only tag
with xml attributes as opposed to the nested ResourceParams and
parameter elements -->
<Resource name="jdbc/juddiDB" auth="Container"
type="javax.sql.DataSource" maxActive="100" maxIdle="30"
maxWait="10000"
username="juddi" password="******"
driverClassName="org.gjt.mm.mysql.Driver"
url="jdbc:mysql://localhost:3306/juddi?autoReconnect=true" />
</Context>
***this is code required for tomcat 5.5.x and is not stated in the official jUDDI docs. It is different for 5.0.x and below***
Amend as necessary to match your MySQL details, e.g. change the username and password.
To enable log4j, you need to create a file at juddi/WEB-INF/classes/log4j.properties. In that file enter:-
#
# set the log file to ${HOME}/juddi.log and not the ${PWD}/juddi.log
#
log4j.appender.LOGFILE.File=/opt/tomcat/logs/juddi.log
and amend the file juddi.properties at:-
/juddi/WEB-INF/judi.properties to suit e.g:-
# The UDDI Operator Name
juddi.operatorName =socket1.leeds.ac.uk
Then simply restart tomcat and browse to:-
http://localhost/juddi
click on 'validate' and see the output for any errors.
Posted at 03:54PM Apr 27, 2006 by Rob Garbutt in Misc technical |
Tomcat Installation
Tomcat Installation
Prerequisites: Java 1.5
Firstly download the latest and greatest Tomcat binary distribution from:-
http://tomcat.apache.org/download-55.cgi
The latest version at the time of this writing, is 5.5.16
Tomcat 5.5.x strictly requires Java 1.5, so this needs to be installed prior to installation.
so the commands:-
mv jakarta-tomcat-5.5.10.tar.gz /usr/local/jakarta-tomcat-5.5.10.tar.gz
cd /usr/local
tar zxvf jakarta-tomcat-5.5.x.tar.gz
Owing to the long name of the directory, you may want to rename this to simply tomcat, so:-
mv /usr/local/jakarta-tomcat-5.5.10 /usr/local/tomcat
To start tomcat:-
/usr/local/tomcat/bin/startup.sh
Then browse to:-
http://myIPaddress:8080, and you should see the famous cat!
To stop tomcat:-
/usr/local/tomcat/bin/shutdown.sh
Many instances of tomcat can run on the same server, simply change the http, https and shutdown port numbers in /usr/local/tomcat/conf/server.xml so that they don't clash.
Posted at 08:21AM Apr 27, 2006 by Rob Garbutt in Misc technical |
MySQL J Connector/J 3.1 Installation
MySQL Connector/J 3.1 installation
Download the connector from:-
http://dev.mysql.com/downloads/connector/j/3.1.html
http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-3.1.12.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/
tar zxvf mysql-connector-3.1.tar.gz
cd mysql-connector-3.1
Then copy the .jar file into either:-
cp mysql-connector-3.1.jar /path/to/jdk/jre/lib/ext
or
cp mysql-connector-3.1.jar /path/to/tomcat/common/lib
Posted at 09:24PM Apr 24, 2006 by Rob Garbutt in Misc technical | Comments[1]
MySQL Installation
MySQL Installation
To install MySQL version
4.0, 4.1 or 5.0 do the following...
as root:-
download stable mysql 4.0 binary release from:- http://www.mysql.com/downloads/download.php
tar zxvf mysqlbinary.tar.gz
mv mysqlbinary /usr/local/mysql (rename the untarred file 'mysql' and move it
into /usr/local)
bash#groupadd mysql
bash# useradd -g mysql mysql
bash# passwd mysql
password: mysqlpassword (give the mysql unix account password)
bash# cd /usr/local/mysql
bash# scripts/mysql_install_db
bash# chown -R mysql:mysql /usr/local/mysql/data
bash# bin/mysqld_safe --user=mysql &
to start the mysql daemon:
/usr/local/mysql/bin/mysqld_safe --user=mysql &
to add root password:
/usr/local/mysql /bin/mysqladmin -u root password 'new-password'
ln -s /usr/local/mysql/bin/mysql /usr/sbin/mysql or add to PATH to aid easy admin of MySQL
Posted at 09:14PM Apr 24, 2006 by Rob Garbutt in Misc technical |
Python Installation
Download Python from:- tar zxvf python.tgz cd /path/to/python ./configure --prefix=/path/to/desiredlocation
--enable-shared Flags to observe here are:-
To install the latest version
of Python.
make
make install.
--prefix=/path/to/desiredlocation
--enable-shared – this is required so that mod python can be loaded dynamically
into Apache.
Posted at 05:43PM Apr 24, 2006 by Rob Garbutt in Misc technical |
Mod Python Installation
The official docs for this
step are at:- http://moinmoin.wikiwikiweb.de/HelpOnInstalling/ApacheWithModPython Firstly download mod_python
from:- http://httpd.apache.org/modules/python-download.cgi • ./configure --with-apxs=/usr/local/apache/bin/apxs Then just make and make
install. Now it’s just a case
of amending the httpd.conf apache file to accommodate mod python. You need to add the line:- LoadModule python_module
modules/mod_python.so Which tells apache to load
the mod python module
This blog highlights the procedure to install
mod python and config httpd.conf so that moinmoin runs using the mod_python module.
http://www.modpython.org/live/current/doc-html/installation.html
untar it, then ./configure and make it. There are a few flags worth taking note
of in the docs, namely :-
• ./configure --with-python=/usr/local/bin/python2.3
• ./configure --with-flex=/usr/local/bin/flex
Posted at 05:40PM Apr 24, 2006 by Rob Garbutt in Misc technical | Comments[88]
Moinmoin Wiki Installation
Prerequisite -> The latest version
of Python to be installed. Docs for which can be found here:-
http://www.agbooth.com/SOCKETBlog/www.socketelf.org_8080/roller/page/socket?entry=mod_python_installation
OK, firstly, pull the latest
version of moinmoin down from:-
http://sourceforge.net/project/showfiles.php?group_id=8482
then:-
tar zxvf moinmoin-1.5.x.tgz
cd moinmoin-1.5.x
It would help to pull up the official docs at this point at:-
http://moinmoin.wikiwikiweb.de/HelpOnInstalling
The first stage of the install is called BasicInstallation.
Assuming your Python location is in your PATH, simply type:-
python -v setup.py --quiet install --record=install.log
This will install the relevant files into the home directory e.g. ~moinmoin
Then to test:-
> python
Python 2.3.4 (#1, May 29 2004, 17:05:23)
[GCC 3.3.3] on linux2
Type "help", "copyright", "credits" or "license"
for more information.
>>> import MoinMoin
>>>
easy as pie! Moinmoin is now installed…unless you see errors in the above.
The next step is to create an instance of a wiki.
Like it says in the docs, choose a location to put your wiki’s, e.g:-
~moinmoin/share/moin
and create a directory named after your wiki e.g.:-
~moinmoin/share/moin/socket
Then copy the following dir’s into that dir:-
data
underlay
wikiconfig.py
and the contents of ‘htdocs’
This was the flaw in the docs. As far as I could see as there was no mention of this step and thus the wiki fails to load correctly.
There are a couple of tweaks required to wikiconfig.py, namely change the location of the ‘data’ and ‘underlay’ dirs from relevant to absolute.
Change permissions as follows:-
chmod –R 777 data
chmod –R 777 underlay
The next step is to configure Mod Python which you can find at:-
Then add the following to your directive in httpd.conf:-
<Location /mywiki>
SetHandler python-program
# Add the path of your wiki directory
PythonPath "['/var/www/moin/mywiki'] + sys.path"
PythonHandler MoinMoin.request::RequestModPy.run
</Location>
obviously amend to suit your environment.
That’s basically it, a quick restart of apache, check of the error logs, and we’re ready to roll!!!
Simply go to your browser and browse to:-
http://youripaddress:yourport/yourwiki
Posted at 05:34PM Apr 24, 2006 by Rob Garbutt in Misc technical |
WSDL2Java
Some brief notes from Atif on using the WSDL2Java program.
You'll find the Axis WSDL-to-Java tool in "org.apache.axis.wsdl.WSDL2Java". The basic invocation form looks like this:
$> java -cp %AXISCLASSPATH% org.apache.axis.wsdl.WSDL2Java (WSDL-file-URL)
For example lets say we have a web service running at the following address:
http://localhost:8080/samples/services/Version
THEN we would invoke Axis WSDL-to-Java tool like THIS:
$> java -cp %AXISCLASSPATH% org.apache.axis.wsdl.WSDL2Java http://localhost:8080/samples/services/Version?wsdl
This will create java classes in the current directory.
LETS say we want the ouput of Axis WSDL-to-Java tool to go into certain directory THEN you need to use the -o option.
e.g. $> java -cp %AXISCLASSPATH% org.apache.axis.wsdl.WSDL2Java http://localhost:8080/samples/services/Version?wsdl -oC:\test
By default WSDL-to-Java tool will put the ouput classess into packages WHICH mirror the targetNamespace in the web service WSDL.
To change this default YOU need to use the following option: -p
e.g. $> java -cp %AXISCLASSPATH% org.apache.axis.wsdl.WSDL2Java http://localhost:8080/samples/services/Version?wsdl -pws.version
Posted at 04:26PM Apr 06, 2006 by Brian Peter Clark in Misc technical |
Installing Axis client
Some brief notes from Atif on installing Axis client.
The following software was used when installing Axis client.
* Java SE 1.5
* Axis 1.3
1. unzip axis-bin-1_3.tar to directory C:\DevTool\axis-1_3
2. Set variable AXIS_HOME to C:\DevTool\axis-1_3
3. Add an XML parser, acquire the JAXP 1.1 XML compliant parser (i.e. xalan) to $AXIS_HOME\lib
4. set variable AXIS_LIB to %AXIS_HOME%\lib
5. set variable AXISCLASSPATH to:
%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar;
%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;
%AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\xalan.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar;
%AXIS_LIB%\axis-schema.jar
To use Axis client code on the command line, you can select AXISCLASSPATH when invoking Java by entering
java -cp %AXISCLASSPATH% ...
or
java -cp "$AXISCLASSPATH" ...
depending on the platform. You may omit the quotes if your CLASSPATH doesn't have spaces in it.
Posted at 04:24PM Apr 06, 2006 by Brian Peter Clark in Misc technical |