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

  • Home
  • SEARCH
  • 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 7005045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:16:44+00:00 2026-05-27T21:16:44+00:00

I’m wondering why ejb injection into JAX-RS resource (RestEasy on JBoss7) is not working.

  • 0

I’m wondering why ejb injection into JAX-RS resource (RestEasy on JBoss7) is not working. EJBs are not part of war but its own EJB jar but I supposed this should not be the problem. I’m forced to do the ctx.lookups “workaround”, which are not pretty. Am I missing something or it is really not supported to inject EJB like that? Example below does not work with JBoss, but works with Glassfish (sadly I gotta run my application on JBoss)

Path("x")
@RequestScoped
public class UserResource {

    @Inject // CDI not working too
    private Service service1;
    @EJB
    private Service service2;

    private Service service3;


    @GET
    @Path("y")
    public Response authenticate(@Context HttpHeaders headers) {
         System.out.println("null == " + service1);
         System.out.println("null == " + service2);

         service3 = annoyingLookup(Service.class);
         System.out.println("null != " + service3);
    }

    private <T> T annoyingLookup(Class<T> clazz) {
       ...
       ctx.lookup("java:app/module/" + classzz.getSimpleName());
    }
  • 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-27T21:16:45+00:00Added an answer on May 27, 2026 at 9:16 pm

    The following is working for me.

    RESTEasy root context:

    package com.foo.rest;
    
    import javax.ws.rs.ApplicationPath;
    import javax.ws.rs.core.Application;
    
    @ApplicationPath("/rest")
    public class RestServiceLocator extends Application {
    
    }
    

    STLS bean:

    package com.foo.rest;
    
    import javax.ejb.EJB;
    import javax.ejb.Local;
    import javax.ejb.LocalBean;
    import javax.ejb.Stateless;
    import javax.ws.rs.Path;
    import javax.ws.rs.core.Response;
    import javax.ws.rs.GET;
    import javax.ws.rs.Produces;
    
    @Path("/foo")
    @Stateless
    @LocalBean //Note: @Local(FooResource.class) does not let RESTEasy to load EJB!
    public class FooResourceBean implements FooResource {
    
        @EJB 
        private FooResourceBean h; // Works!
    
        /**
         * http://localhost:8080/webapp/rest/foo/baa
         *  
         */
        @GET
        @Path("/baa")
        @Produces("application/json")
        @Override
        public Response baa() {
    
            String json = "{ \"baa\" : [ " +
                          "             { \"icon\":\"source1.png\" , \"description\":\"Source 1\" }, " +
                          "             { \"icon\":\"source2.png\" , \"description\":\"Source 2\" }, " +
                          "             { \"icon\":\"source3.png\" , \"description\":\"Source 3\" } " +
                          "          ]}\";";
    
            return Response.ok(json).build();
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT

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.