简体   繁体   中英

Call an ejb entity class from an independent web application (netbeans)

I'm making a small webshop application for school in Netbeans. I have a Customer entity class in an EJB module together with a local session bean and a remote session bean.

Next I have an independent web application, which can of course call the remote session bean.

From the application I can call a method in the remote session bean to give me all customers. But what should the session bean return?

  • It can return a list of Customers but my application does not know the customer class. Should I add a jar of my ejb module in the application?
  • I could return a list of lists with all information of the customers but this is not very nice.
  • I have read something here about having a Customer interface in the web application but I don't understand how this works.
  • Would it help making a Enterprise application and adding both the jar of the ejb module and the war of the web application?

What's the best choice?

(Oh and I'm using wicket as framework, if that has anything to do with this)

EDIT:

So my setup is like this :

  • a library containing the entity class and the interface of the remote bean
  • a ejb module containing the remote bean and a facade of the entity class, it also has the library above
  • a web application: also has the library
  • a enterprise application containing the ejb-jar and the war.

It's not working though. When I deploy the ear, I get this error:

Error in annotation processing: java.lang.NoClassDefFoundError: shop2/database/customer/CustomerBeanRemote

I'm not sure where to put the persistence file. Now it is in the ejb module. But I don't think this is actually the problem.

Can you maybe guide me through how to make the project. It is the first time I work with EJB and Java EE.

Thanks!

You must create a client project contain all your entities and interfaces, and use this project in the EJB module and web project.

In this case you can return a list of customer to the web project by using the remote interface

Of course, you must deploy the ejb project + the client project in an ear project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM