Upgrading maven-jetty-plugin for Jetty 8 to use Servlet 3.0
When moving from Jetty 6 to Jetty 8, one of the biggest changes is the jump from Servlet version 2.5 to version 3.0. There is also a change in the JSP version which was 2.0 in Jetty 6.x while it is JSP 2.1 in Jetty 8.x.
Keeping that in mind, the dependency for the servlet api needs to be configured to use Servlet 3.0 jars.
This should have been sufficient if it wasn't for a change in "maven-jetty-plugin" also. Up to versions 6.x of the maven-jetty-plugin are available under the artifactId of "maven-jetty-plugin". So running,
with the following in your pom.xml would be sufficient.
But if you try to do that with Servlet 3.0, you would end up with a
This is because for jetty 7 and above, the artifactId for the plugin is "jetty-maven-plugin" instead of "maven-jetty-plugin". And if you try to fetch the artifact for "maven-jetty-plugin", the highest version maven will be able to fetch will be a 6.x version. So, the plugin configuration needs to be like this:
For more details read through the following article.
http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin
Keeping that in mind, the dependency for the servlet api needs to be configured to use Servlet 3.0 jars.
This should have been sufficient if it wasn't for a change in "maven-jetty-plugin" also. Up to versions 6.x of the maven-jetty-plugin are available under the artifactId of "maven-jetty-plugin". So running,
mvn jetty:run
with the following in your pom.xml would be sufficient.
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>
But if you try to do that with Servlet 3.0, you would end up with a
java.lang.ClassNotFoundException
for javax.servlet.ServletRegistration$Dynamic.class
This is because for jetty 7 and above, the artifactId for the plugin is "jetty-maven-plugin" instead of "maven-jetty-plugin". And if you try to fetch the artifact for "maven-jetty-plugin", the highest version maven will be able to fetch will be a 6.x version. So, the plugin configuration needs to be like this:
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
</plugin>
For more details read through the following article.
http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin
Thank you.
ReplyDelete