Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8739413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:56:01+00:00 2026-06-13T10:56:01+00:00

I am trying to launch a Jetty server from a class. When I try

  • 0

I am trying to launch a Jetty server from a class. When I try to run it from eclipse it works fine. If I embed it to a JAR the jetty server starts, but when I make a request it return a 500 code response. Here is my class:

@GET
    @Path("test")
    @Produces(MediaType.APPLICATION_JSON)
    public String echo(@QueryParam("testParam")String test){
        return test;
    }

    private Server server; 

    public synchronized void start(int port) throws Exception {
        if (server != null) {
                throw new IllegalStateException("Server is already running");
            }

            ServletContextHandler context = new ServletContextHandler();
            context.setContextPath("/");
        Map<String,Object> initMap = new HashMap<String, Object>();
        initMap.put("com.sun.jersey.api.json.POJOMappingFeature", "true");
        initMap.put("com.sun.jersey.config.property.packages", "the.class.package");           
        context.addServlet(new ServletHolder(new ServletContainer(new PackagesResourceConfig(initMap))), "/*");

        this.server = new Server(port);
        this.server.setHandler(context);
        this.server.start();                   
    }

       public static void main(String[] args) throws Exception {
        if(args.length != 1) {
                System.out.println("AnnotatorServer <port>");
                System.exit(-1);
        }
        JettyServer server = new JettyServer();        
        server.start(Integer.parseInt(args[0]));
    }

When I try to launch it embedded in a JAR, the server starts, but when I access the method, I get the following exception:

    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 application/octet-stream was not found

Do you have any idea why is this happening?? Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:56:02+00:00Added an answer on June 13, 2026 at 10:56 am

    The problem was on the POM file. The dependency was overwriting some files in Meta-Inf/service. Found the solution to Jersey exception only thrown when depencencies assembled into a single jar

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to launch my client, but have an error. Server is already running
I'm trying to launch a server on my tomcat 7 on my eclipse indigo
I am trying to launch explorer programmatically from my .Net CF Window application. But
I'm trying to launch google maps from my iPhone application. The launching part works
I'm trying to launch VLC in dummy mode from a Node.js server script, however
I'm trying to launch an intent from an activity class: Intent i = new
I am trying to launch a dialogue from a non activity java class. Can
When trying to launch and run a flex/java project in eclipse I kept getting
I'm trying to launch Cygwin version of ruby.exe from a .NET application, but I'm
I'm trying to launch VB application from Java, but I'm getting runtime error: Exception

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.