Sheila's Blog

Software Development

Sheila's Blog header image 5

Entries Tagged as 'Uncategorized'

Using Chainsaw to tail your JBoss server log

April 7th, 2009 No Comments

Log4j is a logging library from Apache.  It consists of loggers (log events) and appenders (a destination for a log message).  There’s always a rootLogger defined, plus however many other loggers you require.  A logger can have several appenders attached to it which can format and write the message to the console or a file [...]

Tags:   · · ·

Loading a properties file in a java web app

March 31st, 2009 No Comments

You’ll often want to configure parameters in a properties file and read this into a class.
config.properties:
value.a=orange
value.b=apple
If you’re simply loading a file in a java program you can use:
Properties props = new Properties();
props.load(new FileInputStream(“config.properties”));
String value = props.getProperty(“value.a”);
But when loading a property file in a web application you should package the file in your deployed archive and [...]

Tags:   ·

Automated Build – Database scripts

March 25th, 2009 No Comments

When you’re developing a project, you put all your java code into source control.  You should also include database scripts in source control.  These scripts can be used by developers to keep their local copies of the database up to date in the same way as they get the latest code from source control.
As part [...]

Tags:   ·

Serving static external content in JBoss

March 10th, 2009 No Comments

To serve external static content in JBoss you need to add a Context element mapping the url eg. /application/test_data to the external folder as follows:
Edit /server/default/deploy/jbossweb-tomcat50.sar/server.xml and add a Context element just under the host tag.
<host name=”localhost”
autoDeploy=”false” deployOnStartup=”false” deployXML=”false”
configClass=”org.jboss.web.tomcat.security.config.JBossContextConfig”>

<Context path=”/app/test_data” appBase=”"
docBase=”C:/test_data”
debug=”99″ reloadable=”true”>
</Context>
Replace C:/test_data with the path to the folder on the server.
Redeploy the application to [...]

Tags:  

Use a different compiler with ant’s javac task

March 9th, 2009 No Comments

To ignore the JAVA_HOME settings and specify the compiler to use in ant’s javac task set the following properties:
build.properties:
# Set the jdk compiler properties
build.javac.executable=C:/Applications/Java/jdk1.5.0_13/bin/javac.exe

build.javac.compiler=javac1.5
Then in the build script use:
<javac srcdir=”${src.dir}” destdir=”${classes.dir}”
classpath=”${classpath}” debug=”${debug.flag}”
fork=”yes” executable=”${build.javac.executable}”
compiler=”${build.javac.compiler}”/>

Tags: