Hi,
I don’t think you need to call the camelHttpTransportServlet.init(new
ServletConfig() {…} there.
The init method can be called by the spring framework finally.
--
Willem Jiang
Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem
On August 28, 2014 at 3:11:10 AM, nickwong (nickwong...@gmail.com) wrote:
> Hey guys,
>
> Tomcat 7
> Java 7
> Camel 2.13.2
> Spring 4.0.6
>
> Spring Java Config enthusiast here. I am just starting out with Camel and
> I'd like to keep my projects as XML free as possible. I'm planning on doing
> an HTTP endpoint in the project and I've got a web.xml setting up the
> CamelHttpTransportServlet and a WebApplicationInitializer setting up the
> Spring Context through java config config scan. It's possible with Spring to
> setup a Dispatcher Servlet and add it dynamically in the
> WebApplicationInitializer, but setting up the CamelHttpTransportServlet
> requires a ServletConfig class. I set some of this stuff up, but ran into
> issues with the ContextLoaderListener trying to kick off Spring after the
> servlet initialized it already, then had other issues getting the Spring
> context to refresh at the right lifecycle so the servlet was part of the
> spring context, etc.
>
> Anyway, I figured I'd just ask if anyone had successfully gotten this
> working with Spring (since I'm having trouble finding any documentation on
> this).
>
> Code snipit in WebApplicationInitializer:
>
> @Override
> public void onStartup(final ServletContext servletContext) throws
> ServletException {
>
> ...
>
> CamelHttpTransportServlet camelHttpTransportServlet = new
> CamelHttpTransportServlet();
> camelHttpTransportServlet.init(new ServletConfig() {
> @Override
> public String getServletName() {
> return "CamelServlet";
> }
>
> @Override
> public ServletContext getServletContext() {
> return servletContext;
> }
>
> @Override
> public String getInitParameter(final String s) {
> return null;
> }
>
> @Override
> public Enumeration getInitParameterNames() {
> return null;
> }
> });
>
> // Create a new Servlet so we can listen for requests
> ServletRegistration.Dynamic appServlet = servletContext.addServlet(
> "CamelServlet",
> camelHttpTransportServlet );
>
> // Listen for request patterns
> appServlet.addMapping(SERVLET_MAPPING);
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/No-web-xml-CamelHttpTransportServlet-configuration-with-Spring-Java-Config-tp5755790.html
>
> Sent from the Camel - Users mailing list archive at Nabble.com.
>