|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.
Aspose.Total for .NET is the most complete package of all file format APIs for .NET as offered by Aspose. It empowers developers to create, edit, render, print and convert between a wide range of popular document formats within any .NET, C#, ASP.NET and VB.NET applications. Aspose compiles all .NET APIs on a daily basis to ensure that it contains the most up to date versions of each of Aspose .NET APIs. If a new .NET API or a new version of existing APIs is released during the subscription peri...
Jul. 30, 2016 02:30 PM EDT Reads: 1,043
Security, data privacy, reliability, and regulatory compliance are critical factors when evaluating whether to move business applications from in-house, client-hosted environments to a cloud platform. Quality assurance plays a vital role in ensuring that the appropriate level of risk assessment, verification, and validation takes place to ensure business continuity during the migration to a new cloud platform.
Jul. 30, 2016 02:00 PM EDT Reads: 502
SYS-CON Events announced today that 910Telecom 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. Housed in the classic Denver Gas & Electric Building, 910 15th St., 910Telecom is a carrier-neutral telecom hotel located in the heart of Denver. Adjacent to CenturyLink, AT&T, and Denver Main, 910Telecom offers connectivity to all major carriers, Internet service providers, Internet backbones and ...
Jul. 30, 2016 01:30 PM EDT Reads: 966
Ovum, a leading technology analyst firm, has published an in-depth report, Ovum Decision Matrix: Selecting a DevOps Release Management Solution, 2016–17. The report focuses on the automation aspects of DevOps, Release Management and compares solutions from the leading vendors.
Jul. 30, 2016 01:00 PM EDT Reads: 1,853
Continuous testing helps bridge the gap between developing quickly and maintaining high quality products. But to implement continuous testing, CTOs must take a strategic approach to building a testing infrastructure and toolset that empowers their team to move fast. Download our guide to laying the groundwork for a scalable continuous testing strategy.
Jul. 30, 2016 01:00 PM EDT Reads: 2,122
Adding public cloud resources to an existing application can be a daunting process. The tools that you currently use to manage the software and hardware outside the cloud aren’t always the best tools to efficiently grow into the cloud. All of the major configuration management tools have cloud orchestration plugins that can be leveraged, but there are also cloud-native tools that can dramatically improve the efficiency of managing your application lifecycle. In his session at 18th Cloud Expo, ...
Jul. 30, 2016 12:00 PM EDT Reads: 1,352
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.
Jul. 30, 2016 11:30 AM EDT Reads: 1,390
StackIQ has announced the release of Stacki 3.2. Stacki is an easy-to-use Linux server provisioning tool. Stacki 3.2 delivers new capabilities that simplify the automation and integration of site-specific requirements. StackIQ is the commercial entity behind this open source bare metal provisioning tool. Since the release of Stacki in June of 2015, the Stacki core team has been focused on making the Community Edition meet the needs of members of the community, adding features and value, while ...
Jul. 30, 2016 11:00 AM EDT Reads: 627
Qosmos has announced new milestones in the detection of encrypted traffic and in protocol signature coverage. Qosmos latest software can accurately classify traffic encrypted with SSL/TLS (e.g., Google, Facebook, WhatsApp), P2P traffic (e.g., BitTorrent, MuTorrent, Vuze), and Skype, while preserving the privacy of communication content. These new classification techniques mean that traffic optimization, policy enforcement, and user experience are largely unaffected by encryption. In respect wit...
Jul. 30, 2016 11:00 AM EDT Reads: 535
For basic one-to-one voice or video calling solutions, WebRTC has proven to be a very powerful technology. Although WebRTC’s core functionality is to provide secure, real-time p2p media streaming, leveraging native platform features and server-side components brings up new communication capabilities for web and native mobile applications, allowing for advanced multi-user use cases such as video broadcasting, conferencing, and media recording.
Jul. 30, 2016 10:45 AM EDT Reads: 1,090
SYS-CON Events announced today that Venafi, the Immune System for the Internet™ and the leading provider of Next Generation Trust Protection, will exhibit at @DevOpsSummit at 19th International Cloud Expo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. Venafi is the Immune System for the Internet™ that protects the foundation of all cybersecurity – cryptographic keys and digital certificates – so they can’t be misused by bad guys in attacks...
Jul. 30, 2016 10:15 AM EDT Reads: 1,514
SYS-CON Events announced today the Kubernetes and Google Container Engine Workshop, being held November 3, 2016, in conjunction with @DevOpsSummit at 19th Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA. This workshop led by Sebastian Scheele introduces participants to Kubernetes and Google Container Engine (GKE). Through a combination of instructor-led presentations, demonstrations, and hands-on labs, students learn the key concepts and practices for deploying and maintainin...
Jul. 30, 2016 10:15 AM EDT Reads: 1,047
The cloud market growth today is largely in public clouds. While there is a lot of spend in IT departments in virtualization, these aren’t yet translating into a true “cloud” experience within the enterprise. What is stopping the growth of the “private cloud” market? In his general session at 18th Cloud Expo, Nara Rajagopalan, CEO of Accelerite, explored the challenges in deploying, managing, and getting adoption for a private cloud within an enterprise. What are the key differences between wh...
Jul. 30, 2016 10:00 AM EDT Reads: 2,182
ReadyTalk has expanded the capabilities of the FoxDen collaboration platform announced late last year to include FoxDen Connect, an in-room video collaboration experience that launches with a single touch. With FoxDen Connect, users can now not only engage in HD video conferencing between iOS and Android mobile devices or Chrome browsers, but also set up in-person meeting rooms for video interactions. A host’s mobile device automatically recognizes the presence of a meeting room via beacon tech...
Jul. 30, 2016 10:00 AM EDT Reads: 531
Deploying applications in hybrid cloud environments is hard work. Your team spends most of the time maintaining your infrastructure, configuring dev/test and production environments, and deploying applications across environments – which can be both time consuming and error prone. But what if you could automate provisioning and deployment to deliver error free environments faster? What could you do with your free time?
Jul. 30, 2016 09:45 AM EDT Reads: 521