Forum Home » Fuse Distributions » Fuse Mediation Router

Thread: Route does not start in JBoss 5.1

 
This question is answered.


Permlink Replies: 7 - Last Post: Nov 29, 2011 2:17 AM Last Post By: njiang
labo32

Posts: 96
Registered: 02/18/11
Route does not start in JBoss 5.1
Posted: Nov 25, 2011 11:40 AM
 
  Click to reply to this thread Reply
Hello,

I have a camel route as war file which runs fine in jetty and tomcat
but when I deploy it to a JBoss server the route does not start

12:34:19,087 INFO  [TomcatDeployment] deploy, ctxPath=/camel-route
12:34:19,268 INFO  [[/camel-route]] Initializing Spring root WebApplicationContex
t
12:34:19,519 INFO  [CamelNamespaceHandler] OSGi environment not detected.
12:34:20,739 INFO  [SpringCamelContext] Apache Camel 2.8.2 (CamelContext: camel-
1) is starting
12:34:20,740 INFO  [SpringCamelContext] JMX enabled. Using ManagedManagementStra
tegy.
12:34:20,851 INFO  [AnnotationTypeConverterLoader] Found 3 packages with 15 @Con
verter classes to load
12:34:20,875 INFO  [DefaultTypeConverter] Loaded 163 core type converters (total
 163 type converters)
12:34:20,881 INFO  [AnnotationTypeConverterLoader] Loaded 4 @Converter classes
12:34:20,888 INFO  [DefaultTypeConverter] Loaded additional 22 type converters (
total 185 type converters) in 0.012 seconds
12:34:20,926 INFO  [SpringCamelContext] Total 0 routes, of which 0 is started.
12:34:20,926 INFO  [SpringCamelContext] Apache Camel 2.8.2 (CamelContext: camel-
1) started in 0.187 seconds
12:34:20,956 INFO  [CamelHttpTransportServlet] Initialized CamelHttpTransportSer
vlet[CamelServlet]


The same war file shows
SpringCamelContext INFO Total 1 routes, of which 1 is started.
in jetty and tomcat.

I read about some issues in camel < 2.7 but since I am using 2.8.2 the problems should be solved.
(route contains cxf and freemarker)

I tried the setup with the camel-jboss (org.apache.camel.extra) package for older camel versions without success.

Any hints are welcome......

Thanks
labo
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Route does not start in JBoss 5.1
Posted: Nov 25, 2011 2:47 PM   in response to: labo32 in response to: labo32
Correct
  Click to reply to this thread Reply
Total 0 routes, of which 0 is started.
Camel says there is 0 routes

Do you use <package> to scan for RouteBuilder classes? If so that's the piece that does not work well in JBoss. So you would need to setup the jboss specific class resolver.

Alternatively setup your route in the XML file

<bean id="myRoute" class="...MyRoute"/>

And then use
<routeBuilder ref="myRoute"/>
inside the <camelContext> to refer to your Java RouteBuilder classes by the bean id.

Then it should work without any package scanning.
labo32

Posts: 96
Registered: 02/18/11
Re: Route does not start in JBoss 5.1
Posted: Nov 28, 2011 9:29 AM   in response to: davsclaus in response to: davsclaus
 
  Click to reply to this thread Reply
The way using
<bean id="myRoute" class="...MyRoute"/>

and then
<routeBuilder ref="myRoute"/>
inside the <camelContext>
to refer to your Java RouteBuilder classes works fine.

Thanks
labo
njiang

Posts: 572
Registered: 09/17/07
Re: Route does not start in JBoss 5.1
Posted: Nov 28, 2011 3:02 AM   in response to: labo32 in response to: labo32
 
  Click to reply to this thread Reply
I just released the camel-extra 2.8.0 which is based on Camel 2.8.3.
You can find the mvn repo here

Can you give it a try ?
njiang

Posts: 572
Registered: 09/17/07
Re: Route does not start in JBoss 5.1
Posted: Nov 28, 2011 3:07 AM   in response to: labo32 in response to: labo32
 
  Click to reply to this thread Reply
I just released the camel-extra 2.8.0 which is based on Camel 2.8.3.
You can find the mvn repo here

Can you give it a try ?
labo32

Posts: 96
Registered: 02/18/11
Re: Route does not start in JBoss 5.1
Posted: Nov 28, 2011 8:35 AM   in response to: njiang in response to: njiang
 
  Click to reply to this thread Reply
The route does not start with the new camel-jboss

My implementation class looks like

package test.camel;
 
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.spi.PackageScanClassResolver;
import org.apache.camel.spring.Main;
import org.apachextras.camel.jboss.JBossPackageScanClassResolver;
 
public class TestConfigRoute extends RouteBuilder {
 
    public static void main(String[] args) throws Exception{
        new Main().run(args);
    }
 
    public void configure() {
    	PackageScanClassResolver jbossResolver = new JBossPackageScanClassResolver();
   		CamelContext context = new DefaultCamelContext();
   		context.setPackageScanClassResolver(jbossResolver);
   	
        from("cxfrs://bean://rsServer")
        .to("bean:metaDataBean?method=getMetaData")
        .to("freemarker:configFreemarker.ftl")
        .to("log:IN?showHeaders=true");
    }
}


and my applicationContext

<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:ctx="http://www.springframework.org/schema/context" 
	xmlns:cxf="http://camel.apache.org/schema/cxf"
	xmlns:jaxrs="http://cxf.apache.org/jaxrs" 
	xmlns:osgi="http://www.springframework.org/schema/osgi"
	xmlns:osgix="http://www.springframework.org/schema/osgi-compendium"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
						http://www.springframework.org/schema/beans/spring-beans.xsd         
						http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd         
						http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd         
						http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd      
						http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd          
						http://www.springframework.org/schema/osgi-compendium http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd      
						http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd       
						">
 
  <import resource="classpath:META-INF/cxf/cxf.xml" />
 
  <cxf:rsServer id="rsServer" serviceClass="test.camel.TestConfigService"></cxf:rsServer>
 
  <camelContext trace="false" xmlns="http://camel.apache.org/schema/spring">
    	<package>test.camel</package>
  </camelContext>
    
  <bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
    .....
  </bean>
 
  <bean id="metaDataBean" class="de.uit.eai.camel.MetaDataBean">
        <constructor-arg ref="dataSource" />
  </bean>
 
</beans>


web.xml

<?xml version="1.0" encoding="ISO-8859-1"?>
 
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
 
  
    <!-- location of spring xml files -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/applicationContext.xml</param-value>
    </context-param>
 
    <!-- the listener that kick-starts Spring -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    <servlet>
        <servlet-name>cxf</servlet-name>
        <servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
     <!-- Camel servlet -->
  <servlet>
    <servlet-name>CamelServlet</servlet-name>
    <servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
 
  <!-- Camel servlet mapping -->
  <servlet-mapping>
    <servlet-name>CamelServlet</servlet-name>
    <url-pattern>/camel/*</url-pattern>
  </servlet-mapping>
    
    
    <servlet-mapping>
        <servlet-name>cxf</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>


</web-app>


pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 
  <modelVersion>4.0.0</modelVersion>
 
  <groupId>test.camel</groupId>
  <artifactId>camel-test</artifactId>
  <version>1.0-SNAPSHOT</version>
 
  <name>Camel-Config</name>
 
  <packaging>war</packaging>
  
  <properties>
		<spring.version>3.0.5.RELEASE</spring.version>
		<camel.version>2.8.3</camel.version>
	</properties>
 
  <dependencies>
 
    <!-- Camel Dependencies -->
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
      <version>${camel.version}</version>
      <scope>compile</scope>
    </dependency>
   
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-spring</artifactId>
      <version>${camel.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
    	<groupId>org.apache.camel</groupId>
    	<artifactId>camel-servlet</artifactId>
    	<version>${camel.version}</version>
      <scope>compile</scope>
	</dependency>
 
	<dependency>
		<groupId>org.apache.camel</groupId>
		<artifactId>camel-freemarker</artifactId>
		<version>${camel.version}</version>
		<scope>compile</scope>
   </dependency>
 
     <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-cxf</artifactId>
            <version>${camel.version}</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-jackson</artifactId>
            <version>${camel.version}</version>
            <scope>compile</scope>
        </dependency>
 
    <!-- Spring Web -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
	   <groupId>org.springframework</groupId>
	   <artifactId>spring-jdbc</artifactId>
	   <version>${spring.version}</version>
	   <scope>compile</scope>
	</dependency>
     
    <!-- logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.6.1</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>log4j</groupId> 
      <artifactId>log4j</artifactId> 
      <version>1.2.16</version>
      <scope>compile</scope> 
    </dependency>
    
    <dependency>
    	<groupId>com.oracle</groupId>
    	<artifactId>ojdbc6</artifactId>
    	<version>11.2.0.2.0</version>
    	<scope>compile</scope>
	</dependency>
	
	<dependency>
		<groupId>org.apache-extras.camel-extra</groupId>
		<artifactId>camel-jboss</artifactId>
		<version>2.8.0</version>
		<scope>compile</scope>
   </dependency>
 
  </dependencies>
  
  
  <repositories>
		<repository>
  <id>camel-extra-release</id>
  <name>Camel Extra Maven repository of releases</name>
  <url>http://svn.codespot.com/a/apache-extras.org/camel-extra/maven2/releases</url>
</repository>
	</repositories>
  
 
  <build>
    <defaultGoal>install</defaultGoal>
 
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      
      <!-- plugin so you can run mvn jetty:run -->
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>7.4.5.v20110725</version>
        <configuration>
          <webAppConfig>
            <contextPath>/</contextPath>
          </webAppConfig>
          <scanIntervalSeconds>10</scanIntervalSeconds>
        </configuration>
 
      </plugin>
    </plugins>
  </build>
 
</project>
davsclaus

Posts: 1,893
Registered: 10/14/08
Re: Route does not start in JBoss 5.1
Posted: Nov 28, 2011 11:35 AM   in response to: labo32 in response to: labo32
 
  Click to reply to this thread Reply
You should configure the jboss class resolver in the Spring applicationContext.xml file as documented here
http://camel.apache.org/camel-jboss.html

Then remove the jboss related code your inserted in the RouteBuilder as its not needed.
njiang

Posts: 572
Registered: 09/17/07
Re: Route does not start in JBoss 5.1
Posted: Nov 29, 2011 2:17 AM   in response to: labo32 in response to: labo32
 
  Click to reply to this thread Reply
The camel context that you create in the TestConfigRoute configure method will not be used to load the route.

Willem