2

I'm trying to build my java project using maven. While compiling I'm getting the following error -

package org.mortbay.http does not exist 
package org.mortbay.jetty does not exist 
package org.mortbay.jetty.servlet does not exist

I have added these dependencies at the last of my pom.xml file -

<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-server</artifactId>
    <version>9.3.15.v20161220</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-http -->
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-http</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mortbay.jetty/jetty-util -->
<dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty-util</artifactId>
    <version>6.1.25</version>
</dependency>

I'm using SocketListener listener = new SocketListener(); and ServletHttpContext classes. What changes do I need to make in my java class ?

bosari
  • 1,922
  • 1
  • 19
  • 38

2 Answers2

1

org.mortbay.jetty have been replaced by org.eclipse.jetty (see maven jetty - org.mortbay.jetty vs org.eclipse.jetty).

You should use the following dependencies :

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-server</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-http</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-util</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-servlets</artifactId>
    <version>9.4.11.v20180605</version>
</dependency>

and the packages :

  • org.eclipse.jetty.server
  • org.eclipse.jetty.http
  • org.eclipse.jetty.servlets

Also, try to avoid mixing different versions of Jetty artifacts.

norbjd
  • 10,166
  • 4
  • 45
  • 80
  • What changes will I have to make in my java classes ? – bosari Aug 17 '18 at 12:51
  • 2
    8 years have passed since the last version of `org.mortbay.jetty:jetty` (`6.1.26`), so the API and internals have quite changed. You can find more info in the [current documentation](http://www.eclipse.org/jetty/documentation/current/embedding-jetty.html), or you can find some guides to migrate. – norbjd Aug 17 '18 at 16:45
  • 1
    note: `jetty-servlet` (singular, support for javax.servlet) and `jetty-servlets` (plural, extra servlets for projects to use) are different things. – Joakim Erdfelt Aug 20 '18 at 16:08
0

I found the right version for the dependency that covers for all the errors that I was getting.

<dependency>
    <groupId>org.mortbay.jetty</groupId>
    <artifactId>jetty</artifactId>
    <version>4.2.9</version>
</dependency>

With this dependency I was able to build my project and export a jar out of it.

bosari
  • 1,922
  • 1
  • 19
  • 38