7 Replies Latest reply on Nov 28, 2011 9:17 PM by Willem Jiang

    Route does not start in JBoss 5.1

    Jochen Lauer Novice

      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

        • 1. Re: Route does not start in JBoss 5.1
          Claus Ibsen Master

          Total 0 routes, of which 0 is started.

          Camel says there is 0 routes

           

          Do you use  to refer to your Java RouteBuilder classes by the bean id.

           

          Then it should work without any package scanning.

          • 2. Re: Route does not start in JBoss 5.1
            Willem Jiang Master

            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 ?

            • 3. Re: Route does not start in JBoss 5.1
              Willem Jiang Master

              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 ?

              • 4. Re: Route does not start in JBoss 5.1
                Jochen Lauer Novice

                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"></import>
                
                  <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"></constructor-arg>
                  </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>
                
                

                 

                • 5. Re: Route does not start in JBoss 5.1
                  Jochen Lauer Novice

                  The way using

                   

                  to refer to your Java RouteBuilder classes works fine.

                   

                  Thanks

                  labo

                  • 6. Re: Route does not start in JBoss 5.1
                    Claus Ibsen Master

                    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.

                    • 7. Re: Route does not start in JBoss 5.1
                      Willem Jiang Master

                      The camel context that you create in the TestConfigRoute configure method will not be used to load the route.

                       

                      Willem