DoTaL

My repository for development tidbits, and a few personal anecdotes

Archive for September, 2007

Mulitple PropertyPlaceholderConfigurer configurations

Posted by doubleA on September 14, 2007

I ran into an issue today when adding a second Spring propertyConfigerer to my application build. My application uses a multi module Maven build system.

A little background on the Maven config: The modules are configured with a core, a web, and a parent. The web module depends on the parent. I originally had a single propertyConfiguer in the web project and it worked without any issues.

Yesterday, I added a propertyConfigurer to the core project to control some email settings. The configurer works fine when I run the Maven build for only the core module. However, when I run the build and tests from the web module, I was receiving the following error:

org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'userSearch' defined in URL [file:/"path to my applicationContext-wicket.xml file"]: Could not resolve placeholder 'ldap.basedn'

This error is referring to the ldap properties file I have configured in my web project, and I knew that the configuration for the web project had not changed.

After doing some research, I found this post on the spring forums and the fix mentioned worked perfectly.

The fix involves editing the first application context file that is loaded. For my build, this is the core module because it is the lowest level in my build. My updated applicationContext.xml file in my core project looks like this

  1.     <bean id="mailProps" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">

  2.         <property name="location" value="classpath:mail.properties"/>

  3.         <property name="ignoreUnresolvablePlaceholders" value="true"/>

  4.     </bean>	

After making the change to set ignoreUnresolvablePlaceholders=true, my build and tests completed successfully.

I found another forum post that mentions a different fix, but I did not try it out because the first fix worked for me. But here is the link in case it helps.

Posted in Java Development, Maven | 2 Comments »

Maven antrun plugin classpath issue

Posted by doubleA on September 4, 2007

Last week, I setup Selenium in my multi module maven project according to this Raible Designs post. All was working well as long as I built my project from the functional-tests module.

As soon as I ran a full project build from the parent POM, I saw the following error:

Selenium Server started
[INFO] [antrun:run {execution: launch-selenium}]
[INFO] Executing tasks
[taskdef] Could not load definitions from resource selenium-ant.properties. It could not be found.
[INFO] ————————————————————————
[ERROR] BUILD ERROR
[INFO] ————————————————————————
[INFO] Error executing ant tasks

Embedded error: Could not create task or type of type: selenese.

Ant could not find the task or a class this task relies upon.

This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
– You have misspelt ’selenese’.
Fix: check your spelling.
– The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
– The task is an Ant optional task and the JAR file and/or libraries
implementing the functionality were not found at the time you
yourself built your installation of Ant from the Ant sources.
Fix: Look in the ANT_HOME/lib for the ‘ant-’ JAR corresponding to the
task and make sure it contains more than merely a META-INF/MANIFEST.MF.
If all it contains is the manifest, then rebuild Ant with the needed
libraries present in ${ant.home}/lib/optional/ , or alternatively,
download a pre-built release version from apache.org
– The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
– The task is not an Ant core or optional task
and needs to be declared using .
– You are attempting to use a task defined using
or but have spelt wrong or not
defined it at the point of use

Remember that for JAR files to be visible to Ant tasks implemented
in ANT_HOME/lib, the files must be in the same directory or on the
classpath

Please neither file bug reports on this problem, nor email the
Ant mailing lists, until all of these causes have been explored,
as this is not an Ant bug.
[INFO] ————————————————————————
[INFO] For more information, run Maven with the -e switch
[INFO] ————————————————————————
[INFO] Total time: 2 minutes 9 seconds
[INFO] Finished at: Tue Sep 04 07:08:47 MDT 2007
[INFO] Final Memory: 19M/34M
[INFO] ————————————————————————

After digging into the Selenium jars and trying to find the properties file in question, I stumbled acrosss this Jira issue for the plugin. The last comment from 7/3/07 gave me a new hope.

Based on the comment, I looked at my POMs and found the first instance the reactor would be using in the multi-module build. I added the Selenium dependencies :

  1. <dependencies>

  2. 	<dependency>

  3. 		<groupId>ant</groupId>

  4. 		<artifactId>ant</artifactId>

  5. 		<version>1.6.5</version>

  6. 	</dependency>

  7. 	<dependency>

  8. 		<groupId>ant</groupId>

  9. 		<artifactId>ant-nodeps</artifactId>

  10. 		<version>1.6.5</version>

  11. 	</dependency>

  12. 	<dependency>

  13. 		<groupId>org.openqa.selenium.server</groupId>

  14. 		<artifactId>selenium-server</artifactId>

  15. 		<version>0.9.2-SNAPSHOT</version>

  16. 		<exclusions>

  17. 		        <exclusion>

  18. 				<artifactId>org.apache.ant</artifactId>

  19. 				<groupId>ant</groupId>

  20. 			</exclusion>

  21. 		</exclusions>

  22. 	</dependency>

  23. </dependencies>

Presto, the build worked. It turns out the classpath or loading process for the plugin was getting confused when 2 modules defined the antrun plugin. My core module uses the antrun plugin to copy configuration files for each server environment. The functional-test module uses antrun for Selenium. It’s a little quirky to add the Selenium dependencies to my core module POM that doesn’t use Selenium, but with a healthy dose of comments, it’s manageable and best of all, it works.

Posted in Java Development, Maven | Leave a Comment »