Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Eclipse: JPA and EJB in one project

 
Matt Morten
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to create a project in Eclipse which uses Session and Entity beans (EJB3) using Glassfish v3 prelude. However, I can't seem to find a way of fusing the two - there seems to be no way of adding a JPA facet to an EJB project, or and EJB context to a JPA project.

....or do you advise instead to have two separate projects which are dependent on each other, and run inside the same container?

Thanks!
Matt
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18014
47
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JPA is part of the EJB3 spec, although JPA is also also available for non-EJB environments like Hibernate. So if your EJB facet includes EJB3 support, you shouldn't need to additionally request an explicit JPA facet.
 
Matt Morten
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm, no good. OK, so my steps are:

1) Create new EJB project (specifying EJB v3)
3) Name it GlassFishBeans
2) Right click on project, New Entity
3) When asked which project to add the new entity, no projects are in the list.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you create the EJB project, on the New EJB Project dialog, click the Modify button next to Configuration. Then select Java Peristence on the Project Facets dialog.

Or, go to the project properties, click on Project Facets and then click Java Persistence.

Then try creating the entity again.
 
Matt Morten
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent, all working now! Thanks!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic