Part3 – Moving our EAP to Openshift can be found here
Part 2 – Deploying to JBoss EAP
Overview
For the last few days I have been getting to grips with JBoss Openshift, which is JBoss’ answer to PAAS – Platform as a Service.
Like all relatively new technologies (after all this kind of thing has only been around for about 10 years) there is a lack of good, working examples. My ultimate objective is to provide Web Service end points to a rule engine that analyzes Stock Market data and identifies stocks and shares that satisfy my own criteria for investment. These will then be reported back to myself for further, manual, consideration.
For now, my immediate challenge is to get Web Services exposed that integrate with Apache Camel on JBoss EAP.
Of the limited amount of information and examples that are available on the internet to work with OpenShift, I have recently encountered a set of videos put together byChristian Posta that are superb.
This blog is heavily based on one of Christian’s videos. It is not an attempt to steal his good work, but rather to add my own personal notes, to his work and then adapt the material to work with OpenShift.
I will also detail some of the problems I encountered and overcame en route.
Convert our Project to a War
Open the pom.xml file
Change the packaging type from jar to war
Force Developer Studio to add the Web App files
Right click on the project
Maven -> Update Project
Expand src/main
You should now see the webapp folder – however the webapp folder is empty
Right click on Deployment Descriptor
Generate Deployment Descriptor Stub
You will now see WEB-INF and WEB-INF/web.xml in the webapp folder
Map the CXF Bean up to a Servlet on the Servlet Container
edit the web.xml so that it looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>camel-cxf-contract-first</display-name>
<!-- location of Spring xml files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/META-INF/spring/*.xml</param-value>
</context-param>
<!-- the listener that kickstarts Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- CFX servlet -->
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
</servlet>
<!-- all our webservices are mapped under this URI pattern -->
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/soap/*</url-pattern>
</servlet-mapping>
<!-- original generated stub -->
<!--
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
-->
</web-app>
Note the following:
we are using Spring to load our application context
our existing CXF bean is being mapped up to a servlet that can be deployed into a servlet container
the CXFServlet will actually publish the endpoint onto the Servlet Container
The endpoint will be mapped to /soap/*
Add the Spring-Web Dependencies
in package explorer expand the Maven Dependencies folder
identify the version of spring that has been installed
Modify our Camel Endpoint to rely on the Servlet Container
edit camel-cxf.xml
change the entry to the following:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd">
<cxf:cxfEndpoint id="orderEndpoint"
address="/order"
serviceClass="camelinaction.order.OrderEndpoint"
wsdlURL="wsdl/order.wsdl"/>
</beans>
This changes the address entry to a relative path to the Servlet Container.
[…] Part2 – Deploying to EAP can be found here […]
[…] EAP Webservice with Camel on Openshift – part 2 […]
[…] Part2 – Deploying to EAP can be found here […]