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:
<!– 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>
<!– all our webservices are mapped under this URI pattern –>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/soap/*</url-pattern>
</servlet-mapping>
<version>1.0.0-SNAPSHOT</version>
<groupId>com.skills421</groupId>
<artifactId>camel-cxf-contract-first</artifactId>
<name>[TODO]Camel CXF Contract First Example</name>
<description>Creates a web service using the WSDL contract first</description>
<!– allows the route to be ran via ‘mvn camel:run’ –>
<plugin>
<groupId>org.apache.camel</groupId>
<artifactId>camel-maven-plugin</artifactId>
<version>2.12.0.redhat-610379</version>
</plugin>
</plugins>
</build>
<packaging>war</packaging>
</project>
[/code]
Modify our Camel Endpoint to rely on the Servlet Container
edit camel-cxf.xml
change the entry to the following:
[code language=”xml”]
<?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.
–>
I don’t think there are many people who would dispute that moving to the cloud is a good thing. The benefits are many, and if your migration is managed professionally, then the return on investment can be quite substantial. But, …
2 Comments