Raf's Lab

Wednesday Jun 02, 2010

Spring Source Roo and missing com.sun:tools:jar:1.4.2

If you are trying to get the latest version of SpringSource ROO working, with an x64 Java JDK, such as the latest JDK 1.6 update 20, there is unfortunately a missing tools.jar from the default lib\ directory of the JDK (tut tut tut Sun/Oracle). This will prevent Roo from working and therefore prevent Maven compilation. You would probably see an error similar to this:

Error message: Missing:
----------
1) com.sun:tools:jar:1.4.2

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.sun -DartifactId=tools -Dversion=1.4.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

----------
1 required artifact is missing.


To correct this error, install an additional x86 JDK, repoint the JAVA_HOME and the PATH to the new JDK and restart the mvn process

Tuesday Jun 01, 2010

Forcing Eclipse to use a different JVM

Eclipse, under windows, uses the Java Control panel located Java Virtual Machine by default. It does not obey nor look at the

JAVA_HOME

To force eclipse to use a different JVM set the following in the eclipse.ini
-vm
E:/dev/java/jdk-jre/jdk1.6.20-i586/jre/bin

Alternatively, if you are using Windows, you can force Eclipse to load a different JVM from the properties box for the eclipse.exe executable 

Thursday May 27, 2010

Achieving Log Rotate for Apache access files

If you would like to apply some form of date nomenclature to your Apache HTTPd log files (Apache Tomcat already includes decent filenames which include dates) and also apply a LogRotate, there is a very different approach from Apache 1.3 to Apache 2.2.
Apache 1.3 used to use the mod_logs_rotate module, but this has now been hived off into a separate application.
To achieve the same result use the following in your httpd.conf

CustomLog "|bin/rotatelogs access-logs.%Y-%m-%d-%H_%M_%S.log 5M" combined

If you look at the first portion, we have a | (pipe) to the binary application rotatelogs which should tell the program to send all output to the rotatelogs application (this is installed by default with an Apache HTTPd install). The last bit about 5M, tells Apache to ensure that the log files are maintained at 5 Mb and then rotated.
Further information can be found here http://httpd.apache.org/docs/2.0/programs/rotatelogs.html

w3c RDF Validator - single packaged WAR

The w3c provides an RDF Validator, but unfortunately, as with all public facing sites, you cannot validate internal non-public data using the validator. The w3c do provide the source for the RDF validator http://dev.w3.org/cvsweb/java/classes/org/w3c/rdf/examples/ARPServlet.java, but it is only available via CVS and does seem to be very specific to the w3c, including hardlinked URLs in the code!!
Having modified the code, html files and images, I made it available as a convenience to others that may find this a timesaver as a single packaged WAR file. All you need to do is place it into the Webapps directory of your favourite servlet server, and it should auto-extract with the correct paths and files. I've also included all additional libraries needed for it, including the correct version of Jena. All of the software has separate open source licence conditions, which I do not have the time to state, but will post later if asked.
Right click and Save As File the following link


Roller: maximum configured size exceeded

As sone of you may have realised, I am using Apache Roller http://roller.apache.org for this blog. It's fast and plugs very quickly into a J2EE/Servlet environment and above all else is Free.
However if you are trying to upload large files to it, even by increasing the maximum files uploadable settings within the server-wide settings, this will still fail, and you will most likely be presented with
To get around this, edit your

webapps/<roller-app-directory>/WEB-INF/classes/struts.properties

and add/change the following line
struts.multipart.maxSize=<max-file-size-in-bytes>

Ensuring you enter the maximum size you would like in bytes. Restart your Tomcat server
e.g
struts.multipart.maxSize=20000000
would set the max file upload size to 20Mb

This is a reported bug in https://issues.apache.org/jira/browse/ROL-1631

Wednesday May 19, 2010

Making XML look pretty

One of the main issues with pasting XML into a blogging tool or web page, is that the resulting HTML can become very difficult to read e.g.

<xsl:stylesheet xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ws="http://earth.google.com/kml/2.0" exclude-result-prefixes="ws" version="2.0">



<xsl:template match="/">

        
<mini>

                
<xsl:apply-templates />

        
</mini>

</xsl:template>



<xsl:template match="event/postcode">

    
<xsl:variable name="gglResponses">

            
<xsl:copy-of select="document( 'http://maps.google.com/maps/api/geocode/xml?address=CV344SA,UK&amp;sensor=false' )" />

    
</xsl:variable>

    

        
<xsl:value-of select="$gglResponses/GeocodeResponse/result/geometry/location/lat" />

        
<xsl:value-of select="$gglResponses/GeocodeResponse/result/geometry/location/lng" />

</xsl:template>

</xsl:stylesheet>



As compared to

<xsl:stylesheet xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ws="http://earth.google.com/kml/2.0" exclude-result-prefixes="ws" version="2.0">



<xsl:template match="/">

        
<mini>

                
<xsl:apply-templates />

        
</mini>

</xsl:template>



<xsl:template match="event/postcode">

    
<xsl:variable name="gglResponses">

            
<xsl:copy-of select="document( 'http://maps.google.com/maps/api/geocode/xml?address=CV344SA,UK&amp;sensor=false' )" />

    
</xsl:variable>

    

        
<xsl:value-of select="$gglResponses/GeocodeResponse/result/geometry/location/lat" />

        
<xsl:value-of select="$gglResponses/GeocodeResponse/result/geometry/location/lng" />

</xsl:template>

</xsl:stylesheet>

By making use of the XSLT transformation taken from http://www2.informatik.hu-berlin.de/~obecker/XSLT we can prettify our XML and make it much easier to read.

Regex: Removing class attributes from XML/XHTML

If you have ever needed to remove class attributes from xml/xhtml, then the following regex might save you some time


find: ( class="[\w-^"]*")
replace:

Please note that [\w^"] will fail, as the "-" dash character is not included, something I spent a little time on :O)

Tuesday May 18, 2010

Calling Web Services from XSLT

One of the little known features of XML and XSLT functions is the document() function, which allows a remote document to be loaded and its tree to be navigable as well as the main document. This allows the ability to call remote Web Services and automatically iterate through the result XML returned
e.g. Using the below Google GeoCoding Service allows us to send a Web Service call to Google and place their resultant result back into the document

<xsl:stylesheet xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ws="http://earth.google.com/kml/2.0" exclude-result-prefixes="ws" version="2.0">



<xsl:template match="/">

        
<mini>

                
<xsl:apply-templates />

        
</mini>

</xsl:template>



<xsl:template match="event/postcode">

    
<xsl:variable name="gglResponses">

            
<xsl:copy-of select="document( 'http://maps.google.com/maps/api/geocode/xml?address=CV344SA,UK&amp;sensor=false' )" />

    
</xsl:variable>

    

        
<xsl:value-of select="$gglResponses/GeocodeResponse/result/geometry/location/lat" />

        
<xsl:value-of select="$gglResponses/GeocodeResponse/result/geometry/location/lng" />

</xsl:template>

</xsl:stylesheet>



This obviously only works with Web Services that are GET based, and therefore wouldn't work on POST based requests, such as SOAP

Calendar

Search

Twitter

Feeds

Links

Navigation

Referrers