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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:37:54+00:00 2026-05-25T23:37:54+00:00

Can you please tell me how is best to do? How can I create

  • 0

Can you please tell me how is best to do?
How can I create a new instance of an entity on web application if I have only the interface..

I have :

  • EJB(3.1) Project
  • Web project

I have an EJB Project like:

User.java

@Entity
public class User {
    //variables.. getters and setters...
}

UserManagerBean.java

@Stateful
public class UserManagerBean implements UserManager {
    //getters and setters...
    //.......
    public void addUser(User user) {
        //implemented here
    }
    //.......
}

UserManager.java

@Local
@Remote
public interface UserManager {
    //methods here
}

In the web application(a standalone web application) I have this:

UserManager.java

public interface UserManager {
    //methods here
}

User.java

public interface User {
    //methods here
}

Now.. in a bean… I am trying to get from the remote context my beans and use them:

//ctx is created with the specific properties to access remote context..
InitialContext ctx = new InitialContext();
userManager = (UserManager)ctx.lookup("java:global/project/projectEJB/UserManagerBean");

User user = userManager.getUserById(1); //working

User new_user = (User)ctx.lookup("java:global/project/projectEJB/User"); //not working
//I know this is not supposed to work.. but how can I do this?

I know you can’t get an instance of an entity because it’s not an ejb…
Do I have to create a normal class of user having everying as on projectEJB? isn’t there a better solution?
What other solutions are there? I searched for google and it seems like everybody knows how to do this.. only I don’t…

Thank you in advance..

  • 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-25T23:37:55+00:00Added an answer on May 25, 2026 at 11:37 pm

    To create the User object you just create a regular Java instance with the ‘new’ operator and then invoke your EJB call.

    User myNewUser = new User();
    userManager.addUser(myNewUser);
    

    Both the client side (your web application) and the server side (EJB 3.1 project) must know how to serialize and deserialize the User object therefore each side must have access to the User class and the EJB interfaces.

    In terms of packaging you could bundle the EJB interface and User entity class all into a single JAR that is used by both the client and server sides.

    An alternative deployment would be to bundle the web app and EJB into a single application deployed inside the same JVM.

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

Sidebar

Related Questions

Can you please tell me which is the best tool that generate the pictorial
Can you please tell me your way or give me a reference to best
Did you know, the best MVC based stylesheet framework?. And, can please tell me
Can you please tell what are the best approaches for doing auto publishing of
Can somebody please tell me the best way to deal with different window sizes
Can please some tell me when does the above written error occurs. I just
Can someone please tell me what this means: 07-04 09:54:38.048: I/DetailActivity(15496): Title that is
Can anybody please tell me why the removeEventListener call is not working? this.addEventListener(Event.ENTER_FRAME, eventCall,
Can anyone please tell/suggest me how can i store and retrieve comments multiple/different values
Can someone please tell me why I'm getting the error object reference is required

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.