camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Cook <ralph.c...@accesspointinc.com>
Subject RE: trouble with camel spring web example
Date Tue, 06 Jun 2017 11:33:05 GMT
We cannot use the latest Camel, nor 2.18.4; the latest states it requires Java 8, and running
with 2.18.4 gives the "major/minor version" error one gets when attempting to run class files
from different major Java versions. We aren't using Java 8 yet in our shop.

I attempted to follow instructions for the examples; when I do the first command "mvn package"
on them, they fail with the "major/minor version" error. So I was attempting to use the source
for the one example that looked most interesting for our application.

When I build and run with 2.17.7, it gives the same result I've been getting with 2.16.0.
It doesn't seem to have the Java 8 compatibility problem, but still doesn't work as I expect.
Is there a way to find out what's wrong with it?

rc

-----Original Message-----
From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
Sent: Tuesday, June 6, 2017 6:52 AM
To: users@camel.apache.org
Subject: Re: trouble with camel spring web example

Must you use so old version of Camel, 2.16.0 is EOL. Or at least upgrade to latest 2.16.x.

And you can try out the examples that is shipped, it should work.


On Tue, Jun 6, 2017 at 12:45 PM, Ralph Cook <ralph.cook@accesspointinc.com> wrote:
> Well, the web.xml as shown below has
>              <listener>
>                  <!-- listener-class>org.apache.camel.component.servletlistener.SimpleCamelServletContextListener</listener-class
-->
>                  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>              </listener>
>
> so it does have a spring context listener. I removed the comment line and tried again,
just in case the comment was causing some kind of problem, but the result is the same.
>
> I created a CamelHttpTransportServlet2 and pointed to it as CamelServlet, and pulled
in source from CamelHttpTransportServlet to see if I could see what was happening that way
(I'm not sure it is the correct version of the source). When the application starts, it hits
breakpoints at destroy() and init() and seems to behave as I would suspect; it also hits a
breakpoint at service() when I click on the link of the first page of the example; in that
method, it calls a deprecated method resolve(HttpRequest request), which returns null for
a variable called consumer, and calls the response method sendError from there.
>
> So it looks like somehow I don't have a consumer for the request that is supposed to
invoke the Camel route, perhaps? But I don't know why that would be. The init() method shows
that the 'contextConfigLocation' is being retrieved from the web.xml as 'classpath:camel-config.xml'
(though I had to put that param in a different place than the example code shows it for some
reason). What else is it that I need to do?
>
> -----Original Message-----
> From: Claus Ibsen [mailto:claus.ibsen@gmail.com]
> Sent: Tuesday, June 6, 2017 5:33 AM
> To: users@camel.apache.org
> Subject: Re: trouble with camel spring web example
>
> Its spring that is starting up Camel as you define Camel in the camel-context.xml file
which is a Spring <beans> file.
>
> So you need the spring context listener in the web.xml file so spring startup, and then
can start Camel.
> You should see in the log from tomcat, when Camel startup as it logs that. If you dont
see that, then Camel is not starting.
>
>
>
> On Mon, Jun 5, 2017 at 4:06 PM, Ralph Cook <ralph.cook@accesspointinc.com> wrote:
>> I am trying to work through an example from the camel website, namely camel-example-servlet-tomcat.
I want to get a web application working that takes input from a web service request and uses
it as the data with which to start a camel route. I am running Tomcat 7.0.63, Netbeans 8.02,
Windows 10 Pro. Java 1.7, Maven 3.0.4.
>>
>> I can build the application; when I run it the initial page appears, with the link
that's supposed to invoke the camel-based route; on clicking that link, or on entering any
variation of its URL, I get 404, resource not available.
>>
>> I tried copying the source for CamelHttpTransportServlet to another class and configuring
that one as CamelServlet, so that I could set breakpoints and see what is happening. I can
hit breakpoints there but still don't know why it isn't working.
>>
>> I do not understand what part of this invokes .start() on Camel, and wonder if I'm
missing some step that does that. One difficulty I have with the documentation is that it
seems to treat all the examples as a block, invoking parent poms and giving instructions on
compiling all of them together; I didn't want to do this but finally attempted it; it requires
not only a more recent version of Maven than we use in my shop but a more recent version of
Java, so that route is really frought. This example is so simple, surely someone can tell
me what I'm doing wrong.
>>
>> I have the following web.xml:
>>
>> ---
>>
>>         <web-app version="1.1"
>>                  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">
>>
>>             <context-param>
>>                 <param-name>contextConfigLocation</param-name>
>>                 <param-value>classpath:camel-config.xml</param-value>
>>             </context-param>
>>
>>             <listener>
>>                 <!-- listener-class>org.apache.camel.component.servletlistener.SimpleCamelServletContextListener</listener-class
-->
>>                 <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>
>>                 <!--init-param>
>>                         <param-name>contextConfigLocation</param-name>
>>                         <param-value>classpath:camel-config.xml</param-value>
>>                 </init-param  -->
>>
>>                 <load-on-startup>1</load-on-startup>
>>             </servlet>
>>
>>             <!-- all our webservices are mapped under this URI pattern -->
>>             <servlet-mapping>
>>                 <servlet-name>CamelServlet</servlet-name>
>>                 <url-pattern>/camel/*</url-pattern>
>>             </servlet-mapping>
>>
>>         </web-app>
>>
>> ---
>>
>> and the following 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">
>>               <!-- incoming requests from the servlet is routed -->
>>               <from uri="servlet:CamelServlet"/>
>>               <choice>
>>                 <when>
>>                   <!-- is there a header with the key name? -->
>>                   <header>name</header>
>>                   <!-- yes so return back a message to the user -->
>>                   <transform>
>>                     <simple>Hi I am ${sysenv.HOSTNAME}. Hello ${header.name}
how are you today?</simple>
>>                   </transform>
>>                 </when>
>>                 <otherwise>
>>                   <!-- if no name parameter then output a syntax to the user -->
>>                   <transform>
>>                     <constant>Add a name parameter to uri, eg ?name=foo</constant>
>>                   </transform>
>>                 </otherwise>
>>               </choice>
>>             </route>
>>
>>           </camelContext>
>>
>>         </beans>
>>
>> ---
>>
>> Here's the pom.xml as well; I don't think it's related but of course don't know.
>>
>>     <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>
>>             <!--log4j-version></log4j-version-->
>>         </properties>
>>
>>         <dependencies>
>>             <!-- Camel -->
>>             <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.apache.camel</groupId>   
 <artifactId>camel-servletlistener</artifactId>  <version>${camel-version}</version>
   </dependency>
>>             <!-- spring -->
>>             <dependency><groupId>org.springframework</groupId>
 <artifactId>spring-web</artifactId>     <version>${spring-version}</version>
   </dependency>
>>
>>             <dependency><groupId>javax.servlet</groupId>      
 <artifactId>javax.servlet-api</artifactId><version>3.1.0</version>
             </dependency>
>>
>>             <!-- logging -->
>>             <!--dependency><groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api           </artifactId>   <version>log4j-version</version>
<scope>runtime</scope>  </dependency-->
>>             <!--dependency><groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core          </artifactId>   <version>log4j-version</version>
<scope>runtime</scope>  </dependency-->
>>             <!--dependency><groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl    </artifactId>   <version>log4j-version</version>
<scope>runtime</scope>  </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.3</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>
>>
>>                 <!-- CXF wsdl2java generator, will plugin to the compile goal
-->
>>                 <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>
>>
>> The contents of this email and any attachments to it may contain Customer Proprietary
Network Information (CPNI) as defined by the FCC and/or privileged and confidential information
from Access Point, Inc. Any and all of this information is only for the viewing or use of
the intended recipient. If you are not the intended recipient, you are hereby notified that
any disclosure, copying, distribution or use of, or the taking of any action in reliance upon,
the information contained in this e-mail, or any of the attachments to this e-mail, is strictly
prohibited and that this e-mail and all of the attachments to this e-mail, if any, must be
immediately returned to Access Point, Inc. or destroyed and, in either case, this e-mail and
all attachments to this e-mail must be immediately deleted from your computer without making
any copies hereof. If you have received this e-mail in error, please notify Access Point,
Inc. by e-mail immediately.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>
> The contents of this email and any attachments to it may contain Customer Proprietary
Network Information (CPNI) as defined by the FCC and/or privileged and confidential information
from Access Point, Inc. Any and all of this information is only for the viewing or use of
the intended recipient. If you are not the intended recipient, you are hereby notified that
any disclosure, copying, distribution or use of, or the taking of any action in reliance upon,
the information contained in this e-mail, or any of the attachments to this e-mail, is strictly
prohibited and that this e-mail and all of the attachments to this e-mail, if any, must be
immediately returned to Access Point, Inc. or destroyed and, in either case, this e-mail and
all attachments to this e-mail must be immediately deleted from your computer without making
any copies hereof. If you have received this e-mail in error, please notify Access Point,
Inc. by e-mail immediately.



--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

The contents of this email and any attachments to it may contain Customer Proprietary Network
Information (CPNI) as defined by the FCC and/or privileged and confidential information from
Access Point, Inc. Any and all of this information is only for the viewing or use of the intended
recipient. If you are not the intended recipient, you are hereby notified that any disclosure,
copying, distribution or use of, or the taking of any action in reliance upon, the information
contained in this e-mail, or any of the attachments to this e-mail, is strictly prohibited
and that this e-mail and all of the attachments to this e-mail, if any, must be immediately
returned to Access Point, Inc. or destroyed and, in either case, this e-mail and all attachments
to this e-mail must be immediately deleted from your computer without making any copies hereof.
If you have received this e-mail in error, please notify Access Point, Inc. by e-mail immediately.
Mime
View raw message