You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by arcy <rc...@pobox.com> on 2017/06/02 17:41:55 UTC

Attempting example for HTTP endpoint, using tomcat, netbeans & spring,

I'm attempting to follow an example from the camel.apache.org set of
examples.

tomcat 7.0.63
netbeans 8.0.2
spring 4.1.6
camel 2.16.0

It finally loads without error (I had to straighten out some version number
issues), but now my little web application loads (according to the logs) and
is running (according to Tomcat's manager app). However, I cannot get it to
respond to any URL I put in a browser for it.

localhost:8080/

produces the tomcat page; clicking on manager app there and entering the
username and password shows me a list of applications, and my CamelOne is
one of them. It says CamelOne is running.

There are no error messages about the running app in any of the logs; one of
them has a message indicating that something wasn't closed properly the last
time, but also has messages indicating that the app is deployed and running
after that.

As near as I can tell, the URL to invoke this application would be

localhost:8080/CamelOne/hello/something?name=rc

entering that, and in fact entering any url, produces no message of any kind
in any log file; the browser says the page is not available.

Here's the application's web.xml:

        <web-app version="1.1" 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">

            <listener>
               
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
            </listener>

            
            <servlet>
                <servlet-name>CamelServlet</servlet-name>
               
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
            </servlet>

            
            <servlet-mapping>
                <servlet-name>CamelServlet</servlet-name>
                <url-pattern>/camel/*</url-pattern>
            </servlet-mapping>

            <context-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>classpath:camel-config.xml</param-value>
            </context-param>

        </web-app>

Here is its pom.xml

    <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/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>

        <groupId>com.api</groupId>
        <artifactId>CamelOne</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>war</packaging>

        <name>CamelOne</name>

        <properties>
            <endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
           
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            <cxf-version>2.6.1</cxf-version>
            <camel-version>2.16.0</camel-version>
            <spring-version>4.1.6.RELEASE</spring-version>
            
        </properties>

        <dependencies>
            
            <dependency><groupId>org.apache.camel</groupId>    
<artifactId>camel-core</artifactId>     <version>${camel-version}</version>   
</dependency>
            <dependency><groupId>org.apache.camel</groupId>    
<artifactId>camel-spring</artifactId>   <version>${camel-version}</version>   
</dependency>
            <dependency><groupId>org.apache.camel</groupId>    
<artifactId>camel-servlet</artifactId>  <version>${camel-version}</version>   
</dependency>

            
            <dependency><groupId>org.springframework</groupId> 
<artifactId>spring-web</artifactId>     <version>${spring-version}</version>   
</dependency>

            
            
            
            

        </dependencies>

        <build>
            <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>
                        <compilerArguments>
                            <endorseddirs>${endorsed.dir}</endorseddirs>
                        </compilerArguments>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <configuration>
                        <failOnMissingWebXml>false</failOnMissingWebXml>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>2.1</version>
                    <executions>
                        <execution>
                            <phase>validate</phase>
                            <goals>
                                <goal>copy</goal>
                            </goals>
                            <configuration>
                               
<outputDirectory>${endorsed.dir}</outputDirectory>
                                <silent>true</silent>
                                <artifactItems>
                                    <artifactItem>
                                        <groupId>javax</groupId>
                                       
<artifactId>javaee-endorsed-api</artifactId>
                                        <version>6.0</version>
                                        <type>jar</type>
                                    </artifactItem>
                                </artifactItems>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>

                
                <plugin>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-codegen-plugin</artifactId>
                    <version>${cxf-version}</version>
                    <executions>
                        <execution>
                            <id>generate-sources</id>
                            <phase>generate-sources</phase>
                            <configuration>
                               
<sourceRoot>${basedir}/target/generated-sources/cxf/</sourceRoot>
                                <wsdlOptions>
                                    <wsdlOption>
                                       
<wsdl>${basedir}/src/main/webapp/WEB-INF/wsdl/report_incident.wsdl</wsdl>
                                    </wsdlOption>
                                </wsdlOptions>
                            </configuration>
                            <goals>
                                <goal>wsdl2java</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>

    </project>

And here is camel-config.xml:

        <beans xmlns="http://www.springframework.org/schema/beans"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xmlns:camel="http://camel.apache.org/schema/spring"
               xsi:schemaLocation="
                 http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
                 http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

          <camelContext xmlns="http://camel.apache.org/schema/spring">

            <route id="helloRoute">
              
              <from uri="servlet:hello"/>
              <choice>
                <when>
                  
                  <header>name</header>
                  
                  <transform>
                    <simple>Hi I am ${sysenv.HOSTNAME}. Hello ${header.name}
how are you today?</simple>
                  </transform>
                </when>
                <otherwise>
                  
                  <transform>
                    <constant>Add a name parameter to uri, eg
?name=foo</constant>
                  </transform>
                </otherwise>
              </choice>
            </route>

          </camelContext>

        </beans>

What could I be missing, or what else should I try?



--
View this message in context: http://camel.465427.n5.nabble.com/Attempting-example-for-HTTP-endpoint-using-tomcat-netbeans-spring-tp5801715.html
Sent from the Camel - Users mailing list archive at Nabble.com.