|By Ken Fogel||
|December 21, 2013 12:33 PM EST||
This is an update to the blog post of just a few days ago. Never to leave well enough alone I have continued examining how to use Maven effectively in Eclipse. As such I have discovered some unneeded steps and some new details.
Without the excess wording this time here are the instructions.
Download and install (unzip into the folder of your choice) the Eclipse IDE for Java EE Developers from http://eclipse.org . The version, as of this writing, is 4.3.1. Since the introduction of version 4.3, also known as Kepler, the m2eclipse plugin for Maven is part of the distribution.
You must choose between a 32 and 64 bit version of this download. Here is a recent article on this subject: http://www.javacodegeeks.com/2012/12/should-i-use-a-32-or-a-64-bit-jvm.html . I use the 64 bit JVM.
Download and install (unzip into the folder of your choice) TomEE from http://tomee.apache.org/downloads.html . There are three versions but it does not matter which one you choose. I use the web profile version.
Run Eclipse and create a new workspace. Eclipse stores its settings inside of the workspace. This is why you need to reconfigure Eclipse whenever you create a new workspace. Since we must create a specialized configuration we need to create a new workspace. We will then be able to create as many web profile projects as we want in this workspace.
Inform Eclipse of the existence of TomEE. You do this by selecting Window -> Preferences -> Server -> Runtime Environment.
Select Add and in the list box select Apache Tomcat v7.0 and click on Next.
Browse to the directory into which you install TomEE. I also change the name of the server to Apache TomEE 1.6.0. Click on Finish and then OK.
The server we just defined now must be added to the workspace. Look for the Servers view usually found on a tab in a panel below the editor window. There is a link that reads “No servers are available. Click this link to create a new server…” Click on this link.
In the dialog that appears select the Apache Tomcat v7.0 Server. The server name and runtime should refer to the TomEE server you defined in the previous step. Click on Finish.
Now you are ready to create a Maven Web Project
Use File -> New -> Maven Project. If you don’t see Maven Project then select Other and you will find the Maven choices. Eclipse will eventually place Maven Project on the New listing.
At the first dialog make sure you check “Create a simple project (skip archetype selection)” and click on Next.
Now you come to the Configure project dialog. This defines the basic information in the pom.xml file and the directory structure of the project.
Group Id: This is typically the root package name. I require that you use com.yourname such as com.kenfogel. I need you to do this so I know whose project I am looking at when I am grading. If you are reading this and not a student use whatever you feel is appropriate.
Artifact Id: This becomes the project name. When using Maven to package your code into the repository it will use the Group Id and Artifact Id as the location of your jar file. In this example I am using WebProfileExample so the full package style name will be com.kenfogel.WebProfileExample.
The package names you use for your classes does not have to be the same as the Groups Id and Artifact Id but most programmers choose to do so.
You can ignore Version.
Packaging cannot be ignored. The packaging you choose determines the directory structure of the project. If it says jar then pull down the combo box and change it to war.
Name and Description are field added to the pom.xml for informative purposes.
Click on Finish.
Here is what the Project Explorer should look like:
Step 7 – UPDATE:
The default Maven pom.xml file is minimal. It must have additional elements to allow you to successfully create code for the web profile of Java EE 6.
Currently it looks like:
<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.kenfogel</groupId> <artifactId>WebProfileExample</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>Web Profile Example</name> <description>Tutorial Eclipse and TomEE project</description> </project>
Minimally it should look like this assuming you want to use Java 1.7 and JUnit 4:
<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.kenfogel</groupId> <artifactId>WebProfileExample</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging> <name>Web Profile Example</name> <description>Tutorial Eclipse and TomEE project</description> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.openejb.maven</groupId> <artifactId>tomee-maven-plugin</artifactId> <version>1.6.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <failOnMissingWebXml>false</failOnMissingWebXml> </configuration> </plugin> </plugins> </build> </project>
After updating the pom.xml file you must update the project. Save the updated pom.xml file. Right mouse click on the project and select Maven -> Update Project. Your project should appear with a check next to it in the dialog so all you need to do is click OK.
I am also working with NetBeans for the same purpose. Since NetBeans interacts with the server differently from Eclipse its pom.xml file requires additional lines that allows NetBeans to deploy the application. I will test to determine if the same Maven pom.xml can be used in both IDEs.
The old step 8 is no required. So there is now one less step.
There are more steps necessary for coding Java Server Faces and Servlets but this is the starting point. A quick test is to create a simple HTML file in the src/main/webapp folder.
Right mouse click on the file and select Run As… -> Run on Server.
Click on Finish and you should see:
Now you are ready for the good stuff!
WebContent becomes src/main/webapp
When using Eclipse without Maven you use the Dynamic Web Project to create a web profile application. Such a project has a WebContent folder that contains WEB-INF, META-INF and other items found in this part of a site. A Maven war project requires that such parts of the application are placed in src/main/webapp. This folder will be created but it will be empty. You will need to create the WEB-INF and META-INF folders in this directory. If you right mouse click on Deployment Descriptor in the project and choose Generate Deployment Descriptor Stub it will create the WEB-INF and a web.xml file for you.
This is still an area that I am fuzzy on. In Eclipse the Run As command does not invoke a Maven build. This means that it is necessary to first do a Maven Build and then a Run As. When doing this you are asked for the Goals. I came across the following that seems to do the trick:
Now I perform a Maven Build and then Run As and the project executes.
Complete Internet of Things (IoT) embedded device security is not just about the device but involves the entire product’s identity, data and control integrity, and services traversing the cloud. A device can no longer be looked at as an island; it is a part of a system. In fact, given the cross-domain interactions enabled by IoT it could be a part of many systems. Also, depending on where the device is deployed, for example, in the office building versus a factory floor or oil field, security ha...
Sep. 27, 2016 11:34 AM EDT
“We're a global managed hosting provider. Our core customer set is a U.S.-based customer that is looking to go global,” explained Adam Rogers, Managing Director at ANEXIA, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
Sep. 27, 2016 11:30 AM EDT Reads: 2,958
SYS-CON Events announced today that SoftLayer, an IBM Company, has been named “Gold Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. SoftLayer, an IBM Company, provides cloud infrastructure as a service from a growing number of data centers and network points of presence around the world. SoftLayer’s customers range from Web startups to global enterprises.
Sep. 27, 2016 11:15 AM EDT Reads: 948
The vision of a connected smart home is becoming reality with the application of integrated wireless technologies in devices and appliances. The use of standardized and TCP/IP networked wireless technologies in line-powered and battery operated sensors and controls has led to the adoption of radios in the 2.4GHz band, including Wi-Fi, BT/BLE and 802.15.4 applied ZigBee and Thread. This is driving the need for robust wireless coexistence for multiple radios to ensure throughput performance and th...
Sep. 27, 2016 11:00 AM EDT Reads: 1,588
SYS-CON Events announced today that Secure Channels will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. The bedrock of Secure Channels Technology is a uniquely modified and enhanced process based on superencipherment. Superencipherment is the process of encrypting an already encrypted message one or more times, either using the same or a different algorithm.
Sep. 27, 2016 11:00 AM EDT Reads: 1,625
I’m going to cry tonight, long and hard. I’ll do so as I remember and mourn Jeremy Geelan. I knew Jeremy for almost 20 years, from the time he showed up one day at Cloud Expo’s headquarters in Bergen County, New Jersey, and went to work. The show wasn’t called Cloud Expo then, of course – it was still known as Java Edge, a pioneering event that grabbed developers, architects, and enterprise IT users alike for twice-yearly confabs. Jeremy didn’t have a job there, or even a job offer. He was s...
Sep. 27, 2016 11:00 AM EDT Reads: 3,746
SYS-CON Events announced today that Commvault, a global leader in enterprise data protection and information management, has been named “Bronze Sponsor” of SYS-CON's 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Commvault is a leading provider of data protection and information management solutions, helping companies worldwide activate their data to drive more value and business insight and to transform moder...
Sep. 27, 2016 11:00 AM EDT Reads: 2,686
Let’s face it, embracing new storage technologies, capabilities and upgrading to new hardware often adds complexity and increases costs. In his session at 18th Cloud Expo, Seth Oxenhorn, Vice President of Business Development & Alliances at FalconStor, discussed how a truly heterogeneous software-defined storage approach can add value to legacy platforms and heterogeneous environments. The result reduces complexity, significantly lowers cost, and provides IT organizations with improved efficienc...
Sep. 27, 2016 10:45 AM EDT Reads: 3,406
DevOps at Cloud Expo – being held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real results. Am...
Sep. 27, 2016 10:30 AM EDT Reads: 4,520
Fifty billion connected devices and still no winning protocols standards. HTTP, WebSockets, MQTT, and CoAP seem to be leading in the IoT protocol race at the moment but many more protocols are getting introduced on a regular basis. Each protocol has its pros and cons depending on the nature of the communications. Does there really need to be only one protocol to rule them all? Of course not. In his session at @ThingsExpo, Chris Matthieu, co-founder and CTO of Octoblu, walk you through how Oct...
Sep. 27, 2016 10:30 AM EDT Reads: 2,185
SYS-CON Events announced today that CDS Global Cloud, an Infrastructure as a Service provider, will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. CDS Global Cloud is an IaaS (Infrastructure as a Service) provider specializing in solutions for e-commerce, internet gaming, online education and other internet applications. With a growing number of data centers and network points around the world, ...
Sep. 27, 2016 10:30 AM EDT Reads: 2,852
SYS-CON Events announced today that LeaseWeb USA, a cloud Infrastructure-as-a-Service (IaaS) provider, will exhibit at the 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. LeaseWeb is one of the world's largest hosting brands. The company helps customers define, develop and deploy IT infrastructure tailored to their exact business needs, by combining various kinds cloud solutions.
Sep. 27, 2016 10:15 AM EDT Reads: 3,152
"We have several customers now running private clouds. They're not as large as they should be but it's getting there. The adoption challenge has been pretty simple. Look at the world today of virtualization vs cloud," stated Nara Rajagopalan, CEO of Accelerite, in this SYS-CON.tv interview at 18th Cloud Expo, held June 7-9, 2016, at the Javits Center in New York City, NY.
Sep. 27, 2016 10:00 AM EDT Reads: 2,301
WebRTC is bringing significant change to the communications landscape that will bridge the worlds of web and telephony, making the Internet the new standard for communications. Cloud9 took the road less traveled and used WebRTC to create a downloadable enterprise-grade communications platform that is changing the communication dynamic in the financial sector. In his session at @ThingsExpo, Leo Papadopoulos, CTO of Cloud9, discussed the importance of WebRTC and how it enables companies to focus...
Sep. 27, 2016 10:00 AM EDT Reads: 2,178
Big Data has been changing the world. IoT fuels the further transformation recently. How are Big Data and IoT related? In his session at @BigDataExpo, Tony Shan, a renowned visionary and thought leader, will explore the interplay of Big Data and IoT. He will anatomize Big Data and IoT separately in terms of what, which, why, where, when, who, how and how much. He will then analyze the relationship between IoT and Big Data, specifically the drilldown of how the 4Vs of Big Data (Volume, Variety,...
Sep. 27, 2016 10:00 AM EDT Reads: 1,038