CroftSoft /
Library /
Tutorials
Program D Setup on JBoss
David Wallace Croft
2006 Dec 20 Wed
These are my notes on setting up a
Program D chatbot on a
JBoss 4
application server. These instructions use version 4.7 of Program D, which
has not been released yet and is still under development.
For an example of working software,
please see the
CroftSoft Client.
Modifying the Build
Checkout the source code for Program D from the CVS repository.
The main Ant build file is "build.xml" in the root directory.
Run target "war" of the Ant build.
If it fails to compile, you might need to exclude a couple of source
files from the javac command in target "compile" since they are still
under development.
<target name="compile" ...>
<javac ...>
<exclude name="org/aitools/programd/graph/DBGraphmapper.java"/>
<exclude name="org/aitools/programd/graph/DBNodemapper.java"/>
...
</javac>
</target>
Building and Installing the Distribution
Run the Ant build target "clean" first and then "war-distribs". This will
create a "programd-4.7-war.zip" file in the "distrib" directory.
Upload the zip file to a temporary directory on your server and unzip it.
It will create a "ProgramD" directory containing a WAR file and two
subdirectories, "conf" and "resources". Create a "/var/programd" directory
on your server and move the "conf" and "resources" subdirectories into it.
Move the WAR file into your JBoss deploy directory. Remove the files in
the temporary directory.
scp programd-4.7-war.zip root@croftsoft.com:/tmp
ssh root@croftsoft.com
cd /tmp
unzip programd-4.7-war.zip
mkdir /var/programd
mv /tmp/ProgramD/conf /var/programd
mv /tmp/ProgramD/resources /var/programd
mv /tmp/ProgramD/programd.war /opt/jboss/server/default/deploy
rm -rf /tmp/ProgramD
rm /tmp/programd-4.7-war.zip
Installing the AIML
Create an "aiml" subdirectory in the /var/programd directory on the server.
Download the Annotated ALICE AIML files from the Program D website
and upload them to the new "aiml" subdirectory on the server. Unzip the
AIML files to create an "aaa" subdirectory under "aiml". Delete the
AIML archive file that you just unzipped. Edit the bots configuration file
to use the new AIML files by unremarking the learn command for the "aaa"
directory. Note that you might need to change "AAA" to "aaa".
scp aaa-2006-05-11.tar.gz root@croftsoft.com:/var/programd
ssh root@croftsoft.com
cd /var/programd
mkdir aiml
mv aaa-2006-05-11.tar.gz aiml
cd aiml
gunzip aaa-2006-05-11.tar.gz
tar xvf aaa-2006-05-11.tar
rm aaa-2006-05-11.tar
vi /var/programd/conf/bots.xml
Pruning the AIML
The ALICE AI Foundation has an
article describing the Annotated ALICE AIML files.
After reading the article, you might decide to delete some of the AIML
files that you just installed. Here is a list of the ones that I delete.
cd /var/programd/aiml/aaa
rm AI.aiml
rm Alice.aiml
rm Drugs.aiml
rm Philosophy.aiml
rm Politics.aiml
rm Religion.aiml
rm Sex.aiml
rm Sports.aiml
rm Wallace.aiml
Setting the Properties
The bottom of the
article
describing the Annotated ALICE AIML files also describes bot properties
used by those files and provides example values. Edit the example
properties file that comes with Program D to provide values for your bot.
vi /var/programd/conf/properties.xml
Confirming Installation
Test the web-based interface at this URL:
http://CroftSoft.com:8080/programd
Test the servlet at this URL:
http://CroftSoft.com:8080/programd/GetBotResponse?input=hi
If the the GetBotResponse servlet does not work but the web
interface does, you might need to rebuild the WAR file to ensure that class
is included. If you are going to use the web interface instead of the
servlet, you do not need the servlet. If you are going to install
CroftSoft Client for Program D, you will need the servlet.
Changing the Logging Configuration
Chat with the chatbot and confirm that it is logging the conversation to
this file:
/var/log/programd/activity.log
If you want to change the logging configuration, you do not modify the
log4j.xml file in the /var/programd/conf directory. This file is not used.
Instead, the log4j.xml file included in the WEB-INF/classes directory of
the programd.war file is read upon application initialization. If you want
to change this file, you will need to do so before you build the WAR file.
I have seen a webpage describing how an application can override the
default initialization to load a logging configuration log4j.xml
from a different path other than the root of the classpath. If implemented
in Program D in the future, this might permit the log4j.xml file in the
/var/programd/conf file to be used.
Fixing Logging
You will see the following in the JBoss server.log:
ERROR [STDERR] log4j:WARN Please initialize the log4j system properly.
This is because JBoss gets confused about whether to use the Log4j classes
deployed with programd.war or the ones that come with JBoss. Tomcat
probably does not have this problem. See
Log4j Configuration Help at apache.org for more on this.
You can probably just ignore this error and skip the rest of this section.
I tried fixing this by adding a jboss-web.xml file like the following to
the WEB-INF directory as suggested in the jboss.org webpage
Class Loading Configuration. This did not work for me, however,
although I am not sure why.
<jboss-web>
<class-loading java2ClassLoadingCompliance="false">
<loader-repository>
org.apache.log4j:loader=programd.war
<loader-repository-config>java2ParentDelegation=false</loader-repository-config>
</loader-repository>
</class-loading>
</jboss-web>
As an alternative to including a jboss-web.xml file, you might need to
instead change the following line in target "war" of the Ant build to
exclude the Log4j classes deployed with the application:
<lib dir="${webapp.lib.dir}"/>
Change it to the following:
<lib dir="${webapp.lib.dir}">
<exclude name="log4j*.jar"/>
</lib>
Now the JBoss Log4j classes are being used instead. Because of this, you
must configure the JBoss master log4j.xml file as the log4j.xml file in
programd.war WEB-INF/classes directory is no longer read. The JBoss master
log4j.xml file is in this directory:
/opt/jboss4/server/default/conf/
Add the following to the JBoss master log4j.xml file to enable basic
logging:
<appender name="programd_activitylog"
class="org.apache.log4j.RollingFileAppender">
<param name="File" value="/var/log/programd/activity.log" />
<param name="MaxFileSize" value="10MB" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%d{ISO8601}] %p: %m%n" />
</layout>
</appender>
<logger name="programd">
<level value="debug"/>
<appender-ref ref="programd_activitylog" />
</logger>
Logging to a Database
Setting up chat logging to a database on JBoss is not easy as it requires
that you add some Program D classes to the JBoss main library if you are
going to use the JBoss master log4j.xml file. It might work if you use
the log4j.xml file in WEB-INF/classes but I have not tried it yet.
Fixing the Manifest
I was getting some warnings in the JBoss server.log file about the
programd.war manifest referring to JAR files JBoss could not locate.
To fix this, I changed the "Classpath:" entry in the manifest file to an
empty string. I think you can simply ignore the warnings instead of
changing the manifest file.
Bot Configuration
Edit this file:
cd /var/programd/conf
vi bots.xml
Database Configuration
Change the database password in this file:
/var/programd/conf/core.xml
To connect to the database:
mysql --user=programd --password=yourpassword programdbot
To add a user to the database:
insert into users values('user0','password0','SampleBot');
To confirm the entry:
select * from users;
To add a predicate to the database:
insert into predicates values('user0','SampleBot','topic','politics');
To exit the database:
exit
|