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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:59:45+00:00 2026-05-31T09:59:45+00:00

I have a RESTful service which injects an EJB(3.0) using the @EJB annotation. This

  • 0

I have a RESTful service which injects an EJB(3.0) using the @EJB annotation. This injection does not work as I get a NullPointerException when I try access the greeting() method on the bean.

This exact code works on Glassfish 3.1 and now on WAS8.0.2 it fails. The injection however works in the same application when referenced from a servlet using the exact same approach

@Stateless
@Path("/hello")
public class HelloRestService {

@EJB
public HelloInterface helloImpl;

}

My Bean looks like this

package impl;

@Stateless
@Local
public class HelloImpl implements iface.HelloInterface {

@Override
public String greeting() {

    return "Hello developer";
}

}

I have tried to do a lookup for the Implementation using the jndi name that gets printed out during server startup

helloimpl = (HelloImpl) new InitialContext().lookup("java:global/REST_EAR/REST_WAR/HelloImpl!iface.HelloInterface");

this however causes a ClassCastException

java.lang.ClassCastException: iface.EJSLocal0SLHelloImpl_f8ca883b incompatible with impl.HelloImpl

Can I read much into this..?

Now I am currently using Wink as my JAX-RS 1.1 implementation. I had previously used Jersey with the same results.

Does anyone know if this is a JAX-RS / WAS issue causing the DI to fail..? It definitely has something to do with REST as said previously the @EJB injection works from a Servlet

  • 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-31T09:59:46+00:00Added an answer on May 31, 2026 at 9:59 am

    I managed to solve the issue in question, but was unable to use any other JAX-RS implementation than the default one in WAS 8. I had to extend javax.ws.rs.core.Application from every RESTful resource and in my web.xml I registered my servlet as

    <servlet>
        <servlet-name>javax.ws.rs.core.Application</servlet-name>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>javax.ws.rs.core.Application</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
    

    I also had to have the ibm-web-bnd.xml and the ibm-web.ext.xml in my WEB-INF folder in the web project. I have a empty beans.xml file in there too, this is required for CDI, but I cannot recall if this was essential.

    I hope this helps people sort out this issue as I have seen many online that cannot solve this.

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

Sidebar

Related Questions

I have a restful web service which can deal with DTOs in json format
I have a ReSTful web service which needs to parse locale-sensitive data from the
I'm trying to do an ajax (restful service) call using $.get. It works perfectly
READ FIRST before answering! I have a RESTful service which wraps around the Entity
I have a RESTful web service which represent processes and activities. Each activity is
We have developed a RESTful web service which expects an XML string to arrive
I have to create a RESTful webapplication/Web service which performs CRUD operations where I
Assume I have a RESTful web service, which holds information about an object that
I have a RESTful WCF service (.NET 3.5), which has a function that is
I have a CXF RESTful service which is working just fine. Problem is when

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.