Error when executing “jetty:run” with jetty-maven-plugin version 9 : java.lang.UnsupportedClassVersionError Unsupported major.minor version 51.0

Dev-Bookmarks Logo

Save up to a workweek a year by efficiently managing your dev bookmarks, on Share your favorites with the community and they will be published on Github - Star

Tools involved

  • JDK 1.6/1.7
  • Eclipse Kepler
  • Maven 3.1.1
  • m2e – Maven Integration for Eclipse plugin
  • Jetty 9
  • Windows 7 / 64 bit


When trying to execute execute the “jetty:run” maven goal from within Eclipse

Execute jetty:run from Eclipse

Execute jetty:run from Eclipse

I am getting the following error:

Error injecting: org.eclipse.jetty.maven.plugin.JettyRunMojo
java.lang.TypeNotPresentException: Type org.eclipse.jetty.maven.plugin.JettyRunMojo not present
	at org.eclipse.sisu.plexus.PlexusLifecycleManager.onProvision(
	at org.eclipse.sisu.inject.LazyBeanEntry.getValue(
	at org.eclipse.sisu.plexus.LazyPlexusBean.getValue(
	at org.codehaus.plexus.DefaultPlexusContainer.lookup(
	at org.codehaus.plexus.DefaultPlexusContainer.lookup(
	at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(
	at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(
	at org.apache.maven.DefaultMaven.doExecute(
	at org.apache.maven.DefaultMaven.execute(
	at org.apache.maven.cli.MavenCli.execute(
	at org.apache.maven.cli.MavenCli.doMain(
	at org.apache.maven.cli.MavenCli.main(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(
	at java.lang.reflect.Method.invoke(
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(
	at org.codehaus.classworlds.Launcher.main(
Caused by: java.lang.UnsupportedClassVersionError: org/eclipse/jetty/maven/plugin/JettyRunMojo : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(
	at java.lang.ClassLoader.defineClass(
	at Method)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(
	... 42 more

I have to mention I had just did an upgrade to JDK 1.7 (without removing the previous JDK 1.6). I thought I did everything right, so here are the steps I took after installing the JDK 1.7:

  1. set environemnt variables
    • add JAVA_HOME in environment variables and make it point to the new JDK  (e.g. C:\Java\jdk1.7.0_45)
    • add %JAVA_HOME%/bin to the PATH environment variable
  2. made sure Eclipse uses the right JDK: <div id="attachment_1065" style="width: 310px" class="wp-caption alignnone"> Choose the correct JRE

    Eclipse Menu -> Window -> Preferences -> Java – > Installed JREs

    • pointed to the correct JRE in eclipse.ini <pre class="lang:default mark:18,19 decode:true" title="eclipse.ini">-startup plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar –launcher.library plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20130521-0416 -product org.eclipse.epp.package.standard.product –launcher.defaultAction openFile –launcher.XXMaxPermSize 256M -showsplash org.eclipse.platform –launcher.XXMaxPermSize 256m –launcher.defaultAction openFile –launcher.appendVmargs -vm C:/Java/jdk1.7.0_45/bin/javaw.exe -vmargs -Dosgi.requiredJavaVersion=1.6 -XX:MaxPermSize=512m -Xms128m -Xmx1024m</pre>

    • made sure the external Maven installation used “sees” the correct JDK by issuing “mvn –version” on the command line: <pre class=”lang:default mark:3,4 decode:true” title=”” mvn=”” –version=”” output=”“>Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 17:22:22+0200) Maven home: C:\Java\apache-maven-3.1.1 Java version: 1.7.0_45, vendor: Oracle Corporation Java home: C:\Java\jdk1.7.0_45\jre Default locale: en_US, platform encoding: Cp1252 OS name: “windows 7”, version: “6.1”, arch: “amd64”, family: “windows” <br></pre></ol>

## Solution

The jetty plugin configuration seemed also to be correct in the `pom.xml` file:

<pre class="lang:default decode:true" title="jetty-maven-plugin configuration in pom.xml">&lt;project xmlns="" xmlns:xsi="" xsi:schemaLocation=""&gt; .................................................
&lt;/build&gt; &lt;/project&gt;</pre>

Then what was the problem? Well, thanks to <a title="java.lang.UnsupportedClassVersionError Unsupported major.minor version 51.0 [duplicate]" href="" target="_blank">Stackoverflow</a> I found out the error happens because of a higher JDK during compile time and lower JDK during runtime. But I thought I compiled and executed everything with Java 7&#8230;

When checking the JDK compliance for the project:

<div id="attachment_1071" style="width: 304px" class="wp-caption alignnone">
  <a href=""><img class="size-medium wp-image-1071" src="" alt="Check project JDK compliance" width="294" height="300" srcset=" 294w, 741w" sizes="(max-width: 294px) 100vw, 294px" /></a>

  <p class="wp-caption-text">
    Project -> Properties -> Java Compiler

the default was on 1.5, which should be no problem for Java 7&#8230;

After looking again in the console it struck me:

<div id="attachment_1072" style="width: 310px" class="wp-caption alignnone">
  <a href=""><img class="size-medium wp-image-1072" src="" alt="Console output" width="300" height="177" srcset=" 300w, 1024w" sizes="(max-width: 300px) 100vw, 300px" /></a>

  <p class="wp-caption-text">
    Console output

&#8230;it was indeed using the older JDK (1.6) at execution time. This was caused by using an Alternate JRE (which was set to `jdk1.6.0_39`), in the setup of the **Run Configuration**:

<div id="attachment_1073" style="width: 310px" class="wp-caption alignnone">
  <a href=""><img class="size-medium wp-image-1073" src="" alt="run configuration JRE" width="300" height="215" srcset=" 300w, 1024w, 1289w" sizes="(max-width: 300px) 100vw, 300px" /></a>

  <p class="wp-caption-text">
    Eclipse Menu -> Run -> Run configurations

After selecting the &#8220;Workspace default JRE (jdk1.7.0_45)&#8221; everything worked as expected.

I hope you could learn something from this as I did.

<div id="about_author" style="background-color: #e6e6e6; padding: 10px;">
  <img id="author_portrait" style="float: left; margin-right: 20px;" src="" alt="Podcastpedia image" />

  <p id="about_author_header">
    <strong>Adrian Matei</strong>

  <div id="author_details" style="text-align: justify;">
    Creator of <a title=", knowledge to go" href="" target="_blank"></a> and <a title="CodepediaOrg, share code knowledge" href="" target="_blank"></a>, computer science engineer, husband, father, curious and passionate about science, computers, software, education, economics, social equity, philosophy - but these are just outside labels and not that important, deep inside we are all just consciousness, right?

  <div id="follow_social" style="clear: both;">
    <div id="social_logos">
       <a class="icon-twitter" href="" target="_blank"> </a> <a class="icon-facebook" href="" target="_blank"> </a> <a class="icon-linkedin" href="" target="_blank"> </a> <a class="icon-github" href="" target="_blank"> </a>

    <div class="clear">

Discover a collection of more than 10k curated dev bookmarks

We have recently reached a second major milestone on There are now more than 10k curated public dev bookmarks available. There are resources for programming languages like java, rust, go, python, for query language like sql, graphql to exotics like genetic-algorithms and astronomy Continue reading

New dev bookmarks in february 2019

Published on March 10, 2019