3

Me and group just took over a development project from some guys that didn't have the time to continue. The project consist of a RESTful server using jersey and jetty, and a java client. Unfortunately, they're unavailable, and we're stuck trying to deploy the server.

They've been using eclipse for development, and for the server project maven has been used to take care of dependencies. They did not use maven for deploying the .jar files though, they only extracted them through eclipse.

We'ce used both maven-install to create a jar-file and just exporting through Eclipse. In both cases we manage to get it up and running, but when we start the client we get the following error on the server:

Caused by: com.sun.jersey.api.MessageException: A message body writer for Java class java.lang.String, and Java type class java.lang.String, and MIME media type text/plain was not found

The same happens if we try to access the webservices through a regular browser.

However, when running the project through Eclipse as in "Run As"->"Java Application" it works.

I've already read a lot of posts, including A message body writer for Java class ... and MIME media type text/html was not found, and I've added the jersey-json dependency, but the same error occurs.

The resources are defined in this manner:

@Path("/{token}/users")
public class Users {

@GET
@Path("/show/{username}")
@Produces("text/plain")
public String getUser(@PathParam("username") String username, 
                      @PathParam("token") String token) {
(...)

}

We haven't studied the actual HTTP requests/responses yet, but might do that if someone thinks any information from those would be interesting.

Thanks for any help! Any input is appreciated!

EDIT: Using maven-assembly to deploy, and the POM-file contains this (and more):

 <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <configuration>
        <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
        <archive>
            <manifest>
                <mainClass>no.abakus.backup.abacash.webservice.AbaCashCoreLauncher</mainClass>
            </manifest>
        </archive>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Community
  • 1
  • 1
Skovly
  • 234
  • 1
  • 8
  • 22

1 Answers1

5

Try changing your jersey-dependencies to one dependency: jersey-bundle. It seems there is a problem using mvn assembly:single with jersey files.

Solution found here: Jersey exception only thrown when depencencies assembled into a single jar

Community
  • 1
  • 1
  • Thanks! It works! I didn't change to maven-shade but just changed one dependency: jersey-server into jersey-bundle – Skovly Oct 02 '12 at 11:19
  • Thank you so much for sharing the fix!! I noticed something was up when my unit tests were working but when deployed and running it was throwing this error. Knew it had to be something with dependencies, but had no idea to try this. – Dean Poulin Jan 31 '14 at 02:24