Note that there are some explanatory texts on larger screens.

plurals
  1. POJava EE: EJB Entity, Web Standalone
    primarykey
    data
    text
    <p>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..</p> <p>I have :</p> <ul> <li>EJB(3.1) Project</li> <li>Web project</li> </ul> <p>I have an EJB Project like:</p> <p><i>User.java</i></p> <pre><code>@Entity public class User { //variables.. getters and setters... } </code></pre> <p><i>UserManagerBean.java</i></p> <pre><code>@Stateful public class UserManagerBean implements UserManager { //getters and setters... //....... public void addUser(User user) { //implemented here } //....... } </code></pre> <p><i>UserManager.java</i></p> <pre><code>@Local @Remote public interface UserManager { //methods here } </code></pre> <p>In the web application(a standalone web application) I have this:</p> <p><i>UserManager.java</i></p> <pre><code>public interface UserManager { //methods here } </code></pre> <p><i>User.java</i></p> <pre><code>public interface User { //methods here } </code></pre> <p>Now.. in a bean... I am trying to get from the remote context my beans and use them:</p> <pre><code>//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? </code></pre> <p>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...</p> <p>Thank you in advance..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload