Archive for the ‘J2EE’ Category
« Older EntriesPer-assembly filtering with the maven-assembly-plugin
Monday, January 18th, 2010
Posted in: filtering, maven assembly plugin J2EE, java, maven 2.
The maven assembly plugin is an extremely powerful tool when it comes to creating custom distributions (aka assemblies) of your artifacts for individual platforms etc. However, the ability to create multiple variants of an artifact within a single build conflicts with the standard maven approach of using multiple build profiles and executing a single build for each profile to generate artifact variants.
This also means that mavens resource filtering is not very useful for individual assemblies, since you can only replace placeholders such as ${someValue} with the same value for all assemblies (since resources are only filtered once, using the active profile(s), for all assemblies).
You can, however, configure the maven assembly plugin to use individual filter property files for each assembly using the <execution> section of the plugin configuration, like so:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>production</id>
<goals>
<goal>single</goal>
</goals>
<configuration>
<filters>
<filter>${project.basedir}/src/main/assembly/production.properties</filter>
</filters>
<finalName>${artifactId}-production-${version}</finalName>
<ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<phase>package</phase>
</execution>
<execution>
<id>integration</id>
<goals>
<goal>single</goal>
</goals>
<configuration>
<filters>
<filter>${project.basedir}/src/main/assembly/integration.properties</filter>
</filters>
<finalName>${artifactId}-integration-${version}</finalName>
<ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<phase>package</phase>
</execution>
</executions>
</plugin>
This snippet uses the same assembly descriptor (you can use any assembly descriptor, actually) to build individual artifacts for production and integration. Note that the ${project.basedir}/ prefix is a workaround for MASSEMBLY-150 and is nedded to avoid a nasty Failed to create assembly: Error filtering file ... Error loading property file 'src/main/...' error when executing the mojo from outside the module directory (say, for instance, in a mvn release:prepare…).
Filtering must be enabled in the assembly descriptor, like so:
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/xsd/assembly"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/xsd/assembly http://maven.apache.org/xsd/assembly-1.1.1.xsd">
...
<fileSets>
<fileSet>
<filtered>true</filtered>
...
</fileSet>
</fileSets>
</assembly>
Thanks to John Casey for suggesting this in MASSEMBLY-430!
No CommentsUsing RPC-style, encoded Axis 1 webservices with spring-remoting
Monday, October 12th, 2009
Posted in: Axis 1, Jax-ws, Spring-Remoting J2EE, System architecture, java, open source.
Preamble
When working with enterprise integration you will quite often deal with legacy systems integration.
I recently had the case where integration of webservices was requested, and much to my surprise there are huge issues when attempting to integrate old webservices (as in pre axis2 and pre jax-ws).
These webservices use outdated or unsupported methods, such as rpc-style/encoded communication, or even worce, outdated elements in the XML messages, for instance <multiref>’s. Having to integrate such services does of course imply that you cannot change anything on the server side, and thus such an outdated format must still be consumed.
This is a huge problem, since current WS implementations, such as the popular axis2 framework, do simply not support these formats.
What surprised me the most about this is that webservices are designed to make systems independent by defining a common communication and data format, which is the exact opposite of what is going on here – and these formats are not that old, we are probably talking 4-5 years.
Developers facing these problems are taking rather desperate measures to work around these problems, such as using on-the-fly XSLT transformation to convert incoming and outgoing WS messages. However, this binds your application even stronger to the outdated format and specific service data.
In my case I wanted to use Spring-remoting. Since the service was RPC-style, I wanted to use the JaxRpcPortProxyFactoryBean to create an on-the-fly proxy implementing the service interface. What I did not want to do is having to write any additional code to consume the service. Furthermore, I wanted the complex objects transferred by the services to be represented by standard JAVA beans, and not be generated using the wsdl2java axis1 tools. Here is how I got this to work.
Read the rest of “Using RPC-style, encoded Axis 1 webservices with spring-remoting”
Running mvn:release with Subversion 1.5.x
Monday, March 23rd, 2009
Posted in: J2EE, SCM, System engineering, java, maven 2, open source, subversion.
When attempting to prepare a release using maven and the maven-release-plugin, you are currently very likely to see your build fail with a message such as:
[INFO] Executing: svn --non-interactive copy --file /tmp/...commit . https://subversion..../tags/...
[INFO] Working directory: ...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Unable to tag SCM
Provider message:
The svn tag command failed.
Command output:
svn: Commit failed (details follow):
svn: File '...' already exists
If you do, you are using subversion 1.5.x which no longer supports tagging from a local working copy, thus causing the unfortunately very misleading error message.
This is a known issue of the subversion sourcecode management (SCM) and there is a simple workaround:
Read the rest of “Running mvn:release with Subversion 1.5.x”
Modular development with OSGI about to be very, very popular – finally.
Monday, March 2nd, 2009
Posted in: J2EE, JPA, OSGI, System architecture, eclipselink, java, open source, spring.
It’s quite exciting to see the tremendous progress in development tools, patterns, frameworks and libraries since the release of JAVA 1.0 in 1996.
Within just thirteen years, development improved from the first applets, from the dark ages of the first EJB standardization attempts and a lack of suitable development processes into an age where aspect oriented programming, dependency injection and a freely available range of lightweight yet extremely powerful frameworks, libraries and API’s finally permitted the humble programmer to do what he always wanted to do – analyze problems, and elegantly write them down without spending all of his precious time on the syntax.
I would even go as far as saying that there was no object orientation before programming crosscutting concerns and using dependency injection became established mechanisms.
Think about it: The original goal of OO is not to use inheritance, encapsulation, identity and polymorphism, but to express the real world of things – our reality – using an abstract world of things, while preserving most of the properties and relationships we observe in reality.
Before AOP, before being able to separate the description of things from creating, configurating and connecting concrete instances through dependency injection frameworks, this goal was hard to achieve.
Modules larger than classes with OSGI
Now however, we are about to reach a new stage in development of object orientation in JAVA: Developing modules that are larger than classes, modules which can, once properly identified, be developed independently using all the wonderful technology described beforehand. The technology used to achieve this has a name: OSGI. This technology has quite a long history of development, but a certain lack of elegance and light-weightiness barred this component model from becoming a real hit in the worldwide development community. This is about to change.
Read the rest of “Modular development with OSGI about to be very, very popular – finally.”
Maven, Surefire, remote debugging and the -javaagent switch
Monday, February 2nd, 2009
Posted in: J2EE, java, maven 2, spring.
When using maven surefire in conjunction with remote debugging (mvnDebug, for instance)
it seems necessary to disable forking of the test executions into separate processes, as the remote debugging works process wise. This is usually done by setting the the fork mode to never, e.g. by specifying -DforkMode=never on the command line.
This is, however, a misunderstanding. mvnDebug is there to enable debugging of the maven process and not of the surefire execution – and disabling forking may have various side effects. One of those is the use of Java agents. When using agents, e.g. for loadtime-weaving in the Spring Framework, one often specifies a -javaagent: as a JVM argument for surefire:
Read the rest of “Maven, Surefire, remote debugging and the -javaagent switch”
Solving the eclipselink (former toplink) issue with HSQLDB
Tuesday, August 12th, 2008
Posted in: J2EE, JPA, eclipselink, java.
When using the great hypersonic java database (hsql) with eclipselink 1.0, i stumbled upon a schema generation (ddl generation) issue. It appears as though eclipselink generates “CREATE TABLE…” statements containing UNIQUE keywords which are incompatible with HSQLDB.
As it turned out, there already is an issue filed for the problem (240618).
The resulting exceptions look like this:
[EL Warning]: 2008.08.12 11:01:13.134--ServerSession(28607378)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 1.0 (Build 1.0 - 20080707)): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Unexpected token: UNIQUE in statement [CREATE TABLE ... (ID INTEGER UNIQUE]
Error Code: -11
Read the rest of “Solving the eclipselink (former toplink) issue with HSQLDB”
Configuring Eclipse Ganymede with subversion in Ubuntu 8.04
Sunday, July 13th, 2008
Posted in: J2EE, SCM, System engineering, eclipse, java, subclipse, subversion, subversive, ubuntu.
After installing the all-new Eclipse ganymede (by downloading it from the eclipse site) under ubuntu 8.04 i ran into some trouble after installing version 1.4.1 of the subclipse subversion plugin.
Long story short, subclipse requires subversion 1.5, but ubuntu 8.04 provides 1.4.x.
If you still want to use subclipse with ganymede in ubuntu, there are only two ways two achieve this – both of which i cannot recommend because they are hacks or bad compromises.
Read the rest of “Configuring Eclipse Ganymede with subversion in Ubuntu 8.04″
Howto use acegi-security and the @Secured annotation for method interception
Friday, July 4th, 2008
Posted in: J2EE, System architecture, acegi, java, spring.
Acegi-security (now spring-security) provides a @Secured (org.acegisecurity.annotation.Secured) annotation.
Classes using this annotation can be processed by a suitable BeanPostProcessor, which will proxy the class so that calls to @Secured methods are intercepted and the required authentication is validated against the acegi security context. Note that the following is a configuration for acegi-security, things might be different with spring-security.
2008-07-12: Comment: It is indeed a lot simpler using spring-security, as Craig Walls demonstrates in this posting in his blog “Spring-Loaded”).
In order to activate the post processing for the @Secured annotations, a spring configuration such as the following is required:
Read the rest of “Howto use acegi-security and the @Secured annotation for method interception”
Why it’s better to integrate XML schema files into the classpath
Saturday, May 10th, 2008
Posted in: J2EE, System architecture, java, spring.
When using schema files in your XML configuration, it’s might happen that your XML parser will attempt to actually download the schema file using the configured schema URI.
This is the case when there is no mechanism for resolving the schema URI to a local schema file (as, for example the bean handler registration in spring) or when such a mechanism fails.
Read the rest of “Why it’s better to integrate XML schema files into the classpath”
OutOfMemoryException (PermGenSpace) with Eclipse JEE
Sunday, April 13th, 2008
Posted in: J2EE, eclipse, java.
The Eclipse JEE distribution Europa Winter appears to have a memory issue with the default JVM memory settings, causing an OutOfMemoryException of the PermGenSpace which makes the IDE hang up and / or exit.
This issue appears to be subject of several bug reports and discussions (see for example this discussion at EclipseZone) .
In general, the fix or workaround for the problem is assigning more memory to the PermGenSpace while increasing the amount of heapspace.
The following entries in the eclipse.ini (located in the eclipse installation root folder) did it for me:
-Xms40m
-Xmx512m
-XX:MaxPermSize=96m
Not that this workaround will only work with sun’s Java distribution (which is the most common), but not with IBM’s, since the latter does not support setting the maxPermSize with -XX:MaxPermSize.
No Comments « Older Entries