Home > Java, Spring > Apache Camel namespaces

Apache Camel namespaces

I am running into some weird issues when I integrate Camel 1.6.0 into my Spring project.

The project was started by my 6 months ago or so and I created a prototype complete with junit tests and mock implementations using Camel as main integration framework.

The structure of the project is as follows:

  • Portal frontend (BEA weblogic 10.2)
  • Spring Business layer (POJI & mock implementations & camel based implementations)
  • Integration layer (Camel routing in & out transformations)
  • Multiple endpoints (Webservices, CGI scripts, GET)

After the first proof of concept, the project was taken over by the developers and I was reallocated on a different project. Now all of a sudden, the project doesn’t seem to build anymore. The developer mentioned a schema problem.

I investigated the issue and my initial thought was that the camel-spring.jar was missing from the maven dependencies. Since we use Spring 2, the concepts of spring.handlers and spring.schemas were added so third party libs can ship the XSD files within the library. But of course, this would be too simple of this was the issue.

The dependencies seemed to be ok but I still got errors from eclipse mentioning:

Description    Resource    Path    Location    Type
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘camelContext’.

When looking into the details, I got the message:

expecting namespace ‘http://activemq.apache.org/camel/schema/spring’ but the target namespace of the schema document is ‘http://camel.apache.org/schema/spring’.

First problem was regarding the fact that camel namespace was not correctly loaded into the spring configurations. So I figured that by solving issue 2, the first would be resolved as well.

As the second problem already defines, the issue arises because camel has recently updated the namespaces to camel.apache.org/schema/spring. The strange thing is that I haven’t updated the dependencies since 1.6 should still be within the same namespace.

Checking the spring.handlers and spring.schemas content of camel-spring.jar, I saw the following content:

========================================================

http\://camel.apache.org/schema/spring=org.apache.camel.spring.handler.CamelNamespaceHandler

========================================================

========================================================

http\://activemq.apache.org/camel/schema/spring/camel-spring.xsd=camel-spring.xsd

http\://activemq.apache.org/camel/schema/spring/camel-spring-1.0.0.xsd=camel-spring.xsd
http\://activemq.apache.org/camel/schema/spring/camel-spring-1.1.0.xsd=camel-spring.xsd
http\://activemq.apache.org/camel/schema/spring/camel-spring-1.2.0.xsd=camel-spring.xsd
http\://activemq.apache.org/camel/schema/spring/camel-spring-1.3.0.xsd=camel-spring.xsd
http\://activemq.apache.org/camel/schema/spring/camel-spring-1.4.0.xsd=camel-spring.xsd
http\://activemq.apache.org/camel/schema/spring/camel-spring-1.5.0.xsd=camel-spring.xsd
http\://activemq.apache.org/camel/schema/spring/camel-spring-1.6.0.xsd=camel-spring.xsd

http\://activemq.apache.org/camel/schema/spring/camel-spring-1.6.1.xsd=camel-spring.xsd

========================================================

The handlers was refering to the Xml handler written for spring integration, the second should map all the xsd files to a classpath resource. In my case this should be refering to ‘camel-spring.xsd’.

I checked the XSD content in the camel-spring jar and in the first line, it shows:

<xs:schema elementFormDefault=”qualified” version=”1.0″ targetNamespace=”http://activemq.apache.org/camel/schema/spring” xmlns:tns=”http://activemq.apache.org/camel/schema/spring” xmlns:xs=”http://www.w3.org/2001/XMLSchema”>

Having walked through multiple articles and forums, I still cannot explain why the problem exists. So basically my current solutions is to switch over the dependencies in maven to Camel version 2.0-M1. Since the xsd and spring properties are all using the same namespace, I have switched over to the new namespace in my configurations and this solved the issue. Though I cna live with the upgrade and a milestone release, I am puzzled what the cause is of the issue. My guess is that somehow, the camel-spring.xsd cannot be found in the classpath and it downloads the file from the public internet, refering to the latest version. This might cause the namespace problem.

But accoring to spring, the spring.schemas should solve this problem. Though I am very annoyed with issue, I decided to leave the matter as I already spent too much time investigating the issue (including blogging about it :) ). You know what caused this issue, let me know. It would really ease my troubled mind :)

Used maven dependencies:
<properties>
<spring.version>2.5.6</spring.version>
</properties>
……………

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>1.6.0</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.1.0</version>
</dependency>

……….

Categories: Java, Spring

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.