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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:15:46+00:00 2026-05-25T16:15:46+00:00

I am working on an enterprise project that has an EJB module and a

  • 0

I am working on an enterprise project that has an EJB module and a web project running on GlassFish v3.1, Weld v1.1 and Jersey. In the EJB I have defined an entity class Manufacturer and generated a session facade ManufacturerFacade.

In the web project I wish to expose Manufacturer instances through REST. To do so, I created the following resources:

The ManufacturersResource is a container resource that returns a list of all manufacturers stored in the database. It does so by injecting the ManufacturerFacade and calling the findAll() method. Abbreviated code:

@RequestScoped
@Path("/manufacturer")
public class ManufacturersResource {

    @Inject
    private ManufacturerFacade manufacturerFacade;

    @GET
    @Produces("application/xml")
    public List<Manufacturer> getManufacturers() {
        return manufacturerFacade.findAll();
    }
}

This resource also has a sub-resource:

@Path("{id}")
public ManufacturerResource getManufacturer(@PathParam("id") String id) {
    return ManufacturerResource.getInstance(id, manufacturerFacade);
}

The ManufacturerFacade looks as follows:

public class ManufacturerResource {

    @Inject
    private ManufacturerFacade manufacturerFacade;

    private long id;

    private ManufacturerResource(String id) {
        this.id = Long.parseLong(id);
    }

    public static ManufacturerResource getInstance(String id,) {
        return new ManufacturerResource(id);
    }

    @GET
    @Produces("application/xml")
    public Manufacturer getManufacturer() {
        return manufacturerFacade.find(id);
    }

}

We are in a different class however, and the ManufacturerResource is not being instantiated by the framework and thus does not have the ManufacturerFacade injected.

I know I can simply pass the facade from the container resource (ManufacturersResource) to the item resource (ManufacturerResource) through the constructor but is it possible to somehow get DI working on them as well or is passing it through the constructor a perfectly fine solution here?

Thanks!

  • 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-05-25T16:15:47+00:00Added an answer on May 25, 2026 at 4:15 pm

    You should be able to use ResourceContext for this and pass the id using a setter. Please file a bug if it does not work (http://java.net/jira/browse/JERSEY).

    @Context
    private ResourceContext resourceContext;
    
    @Path("{id}")
    public ManufacturerResource getManufacturer(@PathParam("id") String id) {
        ManufacturerResource r = resourceContext.getResource(ManufacturerResource.class);
        r.setId(id);
        return r;
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you're working on an enterprise project in which you have to get management
I've got a project that I'm working Enterprise Library logging into, and that application
I am working on a web application with an existing code base that has
Right now a project I'm working on has reached a level of complexity that
We are working on a C# windows project with enterprise library 1.0 that needs
I have a project I am working that will search all loaded assemblies for
i am new in project for company that have bigger enterprise/accounting system based on
I have just been informed that a Rails 3 project I've been working on
I am working on a legacy Java Enterprise server project, trying to set up
I am going to change my working sphere from Enterprise Web Applications written for

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.