Friday, February 29, 2008

Vote for Gdynia!!!


Click the image above or go to http://www.monopolyworldvote.com/ in order to vote for the coolest city in Poland and one of the coolest cities in the World - Gdynia.

Friday, February 22, 2008

Maven + Artifactory + Continuum

All right then - so I set up my very own (i.e. my team's) Continuous Integration environment. I used:

I installed the whole environment on Linux machine with Java 5.0. I started with Maven 2 and Apache Tomcat 6.x.
Next I downloaded Artifactory and Continuum WAR's and changed their names to artifactory.war and continuum.war accordingly (basically I removed version info).
Then I copied those two WAR's wo TOMCAT_HOME/webapps directory.
Next I configured Atrifactory and Continuum according to their documentation pages - I didn't change anything. It's pretty straightforward.
I also created empty web application TOMCAT_HOME/webapps/projects whose goal is to serve deployed maven sites. This application should have configured WebDAV interface. In order to do this I created WEB-INF/web.xml file for this webapp with following contents:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">

<display-name>Webdav Content Management</display-name>
<description>
Webdav Content Management
</description>

<servlet>
<servlet-name>webdav</servlet-name>
<servlet-class>org.apache.catalina.servlets.WebdavServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>true</param-value>
</init-param>
<!-- Uncomment this to enable read and write access -->

<init-param>
<param-name>readonly</param-name>
<param-value>false</param-value>
</init-param>

<!--load-on-startup>1</load-on-startup-->
</servlet>

<!-- The mapping for the webdav servlet -->
<servlet-mapping>
<servlet-name>webdav</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<security-constraint>
<web-resource-collection>
<web-resource-name>The Entire Web Application</web-resource-name>
<url-pattern>/*</url-pattern>
<http-method>PUT</http-method>
<http-method>POST</http-method>
<http-method>DELETE</http-method>
<http-method>PROPFIND</http-method>
<http-method>PROPPATCH</http-method>
<http-method>MKCOL</http-method>
<http-method>COPY</http-method>
<http-method>MOVE</http-method>
<http-method>LOCK</http-method>
<http-method>UNLOCK</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>Tomcat Supported Realm</realm-name>
</login-config>

<security-role>
<description>
An example role defined in "conf/tomcat-users.xml"
</description>
<role-name>admin</role-name>
</security-role>
</web-app>


I also had to add tomcat user to TOMCAT_HOME/conf/tomcat-users.xml:

<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<user username="admin" password="your_password" roles="admin"/>
</tomcat-users>


Continuous Integration environment is almost ready.

My pom.xml contains following configuration:

<!-- Deployment config -->
<distributionManagement>
<repository>
<id>artifactory.internal</id>
<name>Internal Release Repository</name>
<url>dav:http://server_name:port/artifactory/libs-releases/</url>
</repository>
<snapshotRepository>
<id>artifactory.snapshots</id>
<name>Internal Snapshot Repository</name>
<url>dav:http://server_name:port/artifactory/libs-snapshots/</url>
</snapshotRepository>
<site>
<id>website</id>
<url>dav:http://server_name:port/projects/project_name-${pom.version}/</url>
</site>
</distributionManagement>


and Maven on the server side contains following configuration (MAVEN_HOME/conf/settings.xml):

<servers>
<server>
<id>artifactory.internal</id>
<username>admin</username>
<password>your_password</password>
</server>
<server>
<id>artifactory.snapshots</id>
<username>admin</username>
<password>your_password</password>
</server>
<server>
<id>website</id>
<username>admin</username>
<password>your_password</password>
</server>
</servers>


Please note that artifactory admin has albo be present in Tomcat's tomcat-users.xml configuration file.
In my configuration for Artifactory, Continuum and Tomcat administrator user name is admin and has the same password in all three cases. More so I configured WebDAV (XML snippet above) in a way that the Tomcat's user admin has to be in role admin - otherwise Continuum will not be able to deploy site using WebDAV protocol.

That's basically it - I hope this post will be useful for some of you.

And why I chose Artifactory? Because I didn't know about the other options :) If you hesitate and don't know what to choose this blog post can help you: Maven Repository Managers - why we chose Archiva.
I am very satisfied about Artifactory - it works out-of-the-box and is serviceless application.

PS. As blogger is not Wiki you are not allowed to change the contents of this post. Nevertheless if you find some bugs or irrelevant information I would be grateful for your comments. I'll then fix this post and correct the mistakes.

Thursday, February 07, 2008

Is it JavaScript... (appendix)

In this post I described the problem with transparent/translucent PNG files in MSIE < 7.

I found the solution to make all PNG images on your HTML page display correctly in MSIE using two lines of JavaScript code - see http://homepage.ntlworld.com/bobosola/index.htm.
I was very happy that I solved the problem - it looked perfect!

Unfortunately, pretty shortly, I found the issue that disqualifies this solution. More so I think that also Google Maps uses the same solution for their components (if you put PNG as a component on the Google Maps it is displayed correctly even in MSIE).

The problem is that you cannot apply <MAP> to the image if you use this solution. Well, <MAP> will be still working in the Firefox but in MSIE if you try to move mouse on your image areas you will not see cursor changing and you will not be able to click it.

If I find better solution I'll let you know :)

Tuesday, February 05, 2008

Yes! Yes! Yes! XWiki build Successful!

After one day hard thinking and trying to solve maven build issues I managed to build the whole XWiki project using:

mvn -Dmaven.test.skip=true install -Pall

As you see I disabled unit tests. That's because some of them failed and build was exiting on fail. And, honestly, I didn't want to search for the option just to ignore test failures - it's easier to disable them :)

I encountered following problems during the building process:

Checkstyle errors

(why the f**k the whole build fails on checkstyle error?)

[INFO] There are 2 checkstyle errors.
[WARNING] Unable to locate Source XRef to link to - DISABLED
[DEBUG] File C:\Dev\XWiki\xwiki-platform-plugins\application-manager\target\site/checkstyle.rss created...
[DEBUG] Configuring mojo 'org.apache.maven.plugins:maven-checkstyle-plugin:2.1:check' -->
[DEBUG] (f) failOnViolation = true
[DEBUG] (f) outputFile = C:\Dev\XWiki\xwiki-platform-plugins\application-manager\target\checkstyle-result.xml
[DEBUG] (f) outputFileFormat = xml
[DEBUG] -- end configuration --
[INFO] [checkstyle:check {execution: default}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] You have 2 checkstyle violations.
[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.BuildFailureException: You have 2 checkstyle violations.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:560)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoFailureException: You have 2 checkstyle violations.
at org.apache.maven.plugin.checkstyle.CheckstyleViolationCheckMojo.execute(CheckstyleViolationCheckMojo.java:96)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
... 16 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 35 seconds
[INFO] Finished at: Mon Feb 04 21:17:45 CET 2008
[INFO] Final Memory: 29M/53M
[INFO] ------------------------------------------------------------------------



My dummy workaround-solution was to disable (remove/comment out) checkstyle for buggy part :) i.e. xwiki-platform-plugins\application-manager\pom.xml


<plugins>
<plugin>
<!-- Apply the Checkstyle configurations defined in the top level pom.xml file -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<dependencies>
<dependency>
<groupId>com.xpn.xwiki.platform</groupId>
<artifactId>xwiki-build-verifications</artifactId>
<version>${platform.tools.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>



Non-existing directories (???)




[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] basedir C:\Dev\XWiki\xwiki-platform-web\standard\target\skin does not exist
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.IllegalStateException: basedir C:\Dev\XWiki\xwiki-platform-web\standard\target\skin does not exist
at org.codehaus.plexus.util.DirectoryScanner.scan(DirectoryScanner.java:550)
at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.getFilesToCopy(WarProjectPackagingTask.java:278)
at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.copyResources(WarProjectPackagingTask.java:229)
at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.handleWebResources(WarProjectPackagingTask.java:99)
at org.apache.maven.plugin.war.packaging.WarProjectPackagingTask.performPackaging(WarProjectPackagingTask.java:64)
at org.apache.maven.plugin.war.AbstractWarMojo.buildWebapp(AbstractWarMojo.java:364)
at org.apache.maven.plugin.war.AbstractWarMojo.buildExplodedWebapp(AbstractWarMojo.java:317)
at org.apache.maven.plugin.war.WarMojo.performPackaging(WarMojo.java:166)
at org.apache.maven.plugin.war.WarMojo.execute(WarMojo.java:130)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1 minute 46 seconds
[INFO] Finished at: Sun Feb 03 21:18:53 CET 2008
[INFO] Final Memory: 38M/63M
[INFO] ------------------------------------------------------------------------


and:


[INFO] [assembly:single {execution: default}]
[INFO] Reading assembly descriptor: C:\Dev\XWiki\xwiki-product-enterprise\database\hsqldb\src\assemble\database.xml
[DEBUG] FileSet[/] dir perms: 40755 file perms: 100644
[DEBUG] The archive base directory is 'null'
[DEBUG] No dependency sets specified.
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to create assembly: Error creating assembly archive: You must set at least one file.

[INFO] ------------------------------------------------------------------------
[DEBUG] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to create assembly: Error creating assembly archive: You must set at least one file.
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:564)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:480)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:459)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:311)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:278)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:143)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:333)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:126)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:282)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to create assembly: Error creating assembly archive: You must set at least one file.

at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:302)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:447)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:539)
... 16 more
Caused by: org.apache.maven.plugin.assembly.archive.ArchiveCreationException: Error creating assembly archive: You must set at least one file.
at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:107)
at org.apache.maven.plugin.assembly.mojos.AbstractAssemblyMojo.execute(AbstractAssemblyMojo.java:278)
... 18 more
Caused by: org.codehaus.plexus.archiver.ArchiverException: You must set at least one file.
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.createArchiveMain(AbstractZipArchiver.java:260)
at org.codehaus.plexus.archiver.zip.AbstractZipArchiver.execute(AbstractZipArchiver.java:242)
at org.codehaus.plexus.archiver.AbstractArchiver.createArchive(AbstractArchiver.java:513)
at org.apache.maven.plugin.assembly.archive.DefaultAssemblyArchiver.createArchive(DefaultAssemblyArchiver.java:103)
... 19 more
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28 seconds
[INFO] Finished at: Mon Feb 04 20:35:58 CET 2008
[INFO] Final Memory: 31M/56M
[INFO] ------------------------------------------------------------------------



The "solution" was the most stupid (and simplest) thing I could think about namely creating these directories.

Something is definitely wrong, especially as far as HSQLDB is concerned because database is empty... I didn't have time to check it (and fix it).

I'm now happy that I built the whole project :)

Environment


I was building the project on Windows XP SP2 using Maven 2.0.8.