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 7802121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:09:57+00:00 2026-06-02T01:09:57+00:00

I have this service with RESTeasy: @GET @Path(/{name}) @Produces(image/jpeg) public BufferedImage get(@PathParam(name) String name)

  • 0

I have this service with RESTeasy:

@GET
@Path("/{name}")
@Produces("image/jpeg")
public BufferedImage get(@PathParam("name") String name) {

    Monitor m = Monitor.getMonitor(name);

    if (m == null) {
        return null;
    }

    return m.getImage();
}

then I get after request

Could not find MessageBodyWriter for response object of type: java.awt.image.BufferedImage of media type: image/jpeg

Is there any “direct way” to get the image into the response ?


Thanks to @Robert for directions. Here working code:

@GET
@Path("/{name}")
@Produces("image/jpeg")
public byte[] get(@PathParam("name") String name) {

    Monitor m = Monitor.getMonitor(name);

    if (m == null) {
        return null;
    }

    ByteArrayOutputStream bo = new ByteArrayOutputStream(2048);
    try {
        ImageIO.write(m.getImage(),"jpeg",bo);
    } catch (IOException ex) {
        return null;
    }

    return bo.toByteArray();
}
  • 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-02T01:09:58+00:00Added an answer on June 2, 2026 at 1:09 am

    You should try to

    • encode the BufferedImage as JPG. Take a look at class javax.imageio.ImageIO
    • declare your method to return a byte[]
    • make sure that your application will always run on a server that is not started with java.awt.headless=true (i.e. no graphics subsystem)

    Please let us know if that works, cause I have no idea if it will and can’t try it myself right now.

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

Sidebar

Related Questions

So, I have a REST application and looks like this: @GET @Produces(MediaType.APPLICATION_JSON) @Path(/getpartners) public
i have this thread which run as a service: public void run() { try
I have this code that describes a service: public class navigation_web extends Service {
I have something like this: MathServiceLibrary (WCF Service Library) [ServiceContract] public interface IMathService {
I'm using cxf 2.4.4 to make RESTful webservices I have this service: @WebService public
I have this service: public class AAAService extends Service { private Intent requestService; private
ok, my file have this structure. <system.serviceModel> <services> <service name=ManyaWCF.ServiceManya behaviorConfiguration=ServiceBehaviour> <!-- Service Endpoints
I am trying to get my first Android service to work. I have this
I have this web service : using System.Web.Services; namespace Contracts { [WebService(Namespace = http://tempuri.org/)]
i have this IntentService code which run a service once: protected void onHandleIntent(Intent intent)

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.