Some guy
Some guy

Reputation: 1208

MediaType.APPLICATION_JSON return type gives 500 Internal error

I'm facing a weird problem. I had a web project (java services) which i used to build with ANT. However due to some reason, the build system had to be changed to Maven.

After building with Maven, I deployed the war file onto tomcat and when i query for some service (enter the service URL in browser) for which the @Produces value is MediaType.APPLICATION_JSON, the response I get is "500 Internal Error" . The same thing worked well when i used ANT (the entire code is the same, just build system is different).

I wrote a dummy service which returns a String (MediaType.TEXT_PLAIN), it works as expected. Is there some configuration for application/json to be returned when built with Maven?

Update :

HTTP Status 500 - Internal Server Error
type : Status report

message : Internal Server Error

description : The server encountered an internal error that prevented it from fulfilling this request.

pom.xml

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com</groupId>
    <artifactId>test</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>2.10.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-bundle</artifactId>
            <version>1.17.1</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20090211</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm-all</artifactId>
            <version>3.1</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>ROOT</finalName>
    </build>
</project>

Upvotes: 0

Views: 1557

Answers (1)

Friso
Friso

Reputation: 1110

Check the two wars (ant vs Maven). Especially the WEB-INF/lib directory. Most likely the Maven version is missing something there. If so check the scope of your dependencies.

See what they mean here

Upvotes: 1

Related Questions