Cannot locate spring namespace

When starting my OpenPatrician application from within Eclipse everything worked fine. But when using the assembly everything fell apart. The reason for this is simple, once figured out. I am creating an assembly of all the modules and their dependencies. Should it happen, that different dependencies provide the same resource, say like a manifest file, the first file will end up in the final jar file.

The different spring dependencies define several configurations which I had only part of in the final jar file. These are the files located in META-INF of the spring-…jar files:

  • spring.factories
  • spring.handlers
  • spring.tools
  • spring.schemas

Now all you have to do is, merge the contents into one file and make sure that is the file that ends up in the final jar file.

To do this I created an additional MetaData module, which is the first dependency in the assembly maven project. That way the files from the MetaData module get picked up.

See also http://blog.idm.fr/2009/09/maven-assembly-plugin-and-spring-namespace-handlers.html

 

 

Combining standalone application with Spring

When you are developing a standalone application, that you want to use with the SpringFramework, somewhere in your code you will have to load the application context. Potentially this results in chicken-egg problem, especially when you want to use a component in some class that is not a bean. This may have different causes:

  • It is the main class, that is used to start up the application
  • The constructor uses arguments that cannot be resolved with autowireing

There are different approaches to solve this, the most elegant one I will demonstrate. „Combining standalone application with Spring“ weiterlesen