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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:15:07+00:00 2026-06-04T17:15:07+00:00

First, the problem is when I invoke the ejb from the rest servlet, the

  • 0

First, the problem is when I invoke the ejb from the rest servlet, the ejb is always null.

I have a rest web service developed in jersey + spring 3.0.5. And an EJB 3.1 for services.

I have package the war and jar in an ear so my application looks like (I’m using maven for dependency):

+ear
++war
++jar

I was wondering how I could call the services in the jar file from my classes in the war file. As far as I remember it’s through JNDI and I need to expose the ejb apis? How should I do that?

I’m sure the EJB are created successfully because I can see the log in the server like this:
Portable JNDI names for EJB UserServiceBean :
[java:global/demo-cg-ear-0.0.1-SNAPSHOT/demo-cg-ejbs/UserServiceBean!com.demo.cg.service.user.UserServiceBeanLocal,
java:global/demo-cg-ear-0.0.1-SNAPSHOT/demo-cg-ejbs/UserServiceBean]|#]

But the problem is when I invoke it in the rest jersey servlet, it’s always null:

@Path("/payment")
@Stateless
public class PaymentService {

@Path("/payment")
@Stateless
public class PaymentService {

    @EJB
    private UserServiceBeanLocal userServiceBean;

    @GET
    @Path("/hello")
    public Response savePayment() {

        String result = userServiceBean.getName();
        return Response.status(200).entity(result).build();

        /* return Response.status(200).entity("hello edward").build(); */
    }

}

My applicationContext.xml file

<context:annotation-config />
    <context:component-scan base-package="com.sido" />
    <context:property-placeholder location="WEB-INF/build.properties" />

    <!-- <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor"> 
        <property name="alwaysUseJndiLookup" value="true" /> </bean> -->

    <jee:jndi-lookup id="userServiceBean"
        jndi-name="java:global/sido-cg-ear-0.0.1-SNAPSHOT/sido-cg-ejbs/UserServiceBean"
        resource-ref="true" lookup-on-startup="true"
        expected-type="com.sido.cg.service.user.UserServiceBeanLocal"
        proxy-interface="com.sido.cg.service.user.UserServiceBeanLocal"></jee:jndi-lookup>

UserBean class

@Interceptors(SpringBeanAutowiringInterceptor.class)
@Stateless
public class UserServiceBean implements UserServiceBeanLocal {
    private String name;

    public UserServiceBean() {
        name = "edward";
    }

    @PostConstruct
    private void init() {
        name = "edward";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

}

Thanks,

czetsuya

  • 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-04T17:15:09+00:00Added an answer on June 4, 2026 at 5:15 pm

    For those who are interested this is how I did it: http://czetsuya-tech.blogspot.com/2012/05/how-to-call-stateless-ejb-from-spring.html

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

Sidebar

Related Questions

I just solved the first problem from Project Euler in JavaFX for the fun
i have an almost simular problem as posted before. My first problem has been
Currently developing a PHP framework and have ran into my first problem. I need
New to StackOverflow here. I'm working on the first Euler problem and have run
Based on some standard web searching, I have narrowed down my problem to this:
I have 2 programs (written by me). The first one called MAN will invoke
Team: I need to invoke a WF activity (XAML) from a WF service (XAMLX)
I have a weird problem where, the first time you start the app, it
hi i have problem with logging, first i registered user in database,this works ok!
(I have a workaround for this problem, but it's not the first time I've

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.