Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » How to set up a JPA project to use Maven?
How to set up a JPA project to use Maven? [message #534374] Tue, 18 May 2010 21:34 Go to next message
Shelli Orton is currently offline Shelli Orton
Messages: 76
Registered: September 2009
Member
Hi,

I am looking for advice on how to set up an EJB/JPA project in Eclipse that uses Maven. I have Galileo with m2eclipse and WTP installed.

This is my first EJB3 project, so there's lots of learning happening.

I looked for a Maven archetype, but the only ones I could find were for JBoss/Hibernate and I am using Glassfish.

I created a new simple Maven project and then added these facets to it:

EJB Module 2.1
Java 6.0
Java Persistence 1.0

I was then able to use the JPA Tools to autogenerate entity classes from database tables. So I now have a project with this structure:
EJBProject\EJBProject
EJBProject\.classpath
EJBProject\.project
EJBProject\.settings
EJBProject\pom.xml

EJBProject\ejbModule
EJBProject\ejbModule\META-INF\MANIFEST.MF
EJBProject\ejbModule\META-INF\orm.xml
EJBProject\ejbModule\META-INF\persistence.xml
{deleted the ejb-jar.xml file}

EJBProject\src\main\java\my\project\Table1.java
EJBProject\src\main\java\my\project\Table2.java
EJBProject\src\main\java\my\project\Table3.java

EJBProject\src\main\resources

EJBProject\src\test\java
EJBProject\src\test\resources

EJBProject\target\classes
EJBProject\target\test-classes

I'm not sure what to with this project now to manage it with Maven. I came across this blog post:

http://famvdploeg.com/blog/2008/08/building-ejb3-application s-with-maven-2/

which created its project structure from scratch/manually. Would the "ejbModule" directory that Eclipse created be equivalent to the "ejb-jar" directory in the blog? Do I need to create "ear" and "war" directories (and respective pom files)?

Any direction in how to set up my project (directory structure and pom files) is greatly appreciated.
Re: How to set up a JPA project to use Maven? [message #534386 is a reply to message #534374] Tue, 18 May 2010 22:49 Go to previous messageGo to next message
Fred Bricon is currently offline Fred Bricon
Messages: 14
Registered: July 2009
Junior Member
You can take a look at the multi-javaee5-archetype at http://code.google.com/p/open-archetypes/ (screencast available at http://code.google.com/p/open-archetypes/wiki/M2EclipseDemo) and then add JPA support to the generated ejb project

Fred Bricon
Re: How to set up a JPA project to use Maven? [message #534574 is a reply to message #534386] Wed, 19 May 2010 15:06 Go to previous message
Shelli Orton is currently offline Shelli Orton
Messages: 76
Registered: September 2009
Member
Hi,

I added the Open Archetypes Snapshot remote catalog to my Maven Archetypes, but when I tried to create a project based on the
mulit-javaee5-archetype, I get the message:
Failed to create project.
java.lang.NullPointerException

java.lang.NullPointerException
at org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory.createArtifactRepository(DefaultArtifactRepositoryFactory.java:90)
at org.maven.ide.eclipse.internal.project.ProjectConfigurationManager.resolveArchetype(ProjectConfigurationManager.java:540)
at org.maven.ide.eclipse.internal.project.ProjectConfigurationManager.createArchetypeProject(ProjectConfigurationManager.java:463)
at org.maven.ide.eclipse.wizards.MavenProjectWizard$5.runInWorkspace(MavenProjectWizard.java:279)
at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:38)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)


I'm using the 0.10.0.201000209-0800 version of m2eclsipse.

[Updated on: Wed, 19 May 2010 15:14]

Report message to a moderator

Previous Topic:Debug JSP in Galileo broken?
Next Topic:Can Eclipse xsd / wsdl editors use a jax-ws-catalog.xml file?
Goto Forum:
  


Current Time: Thu Sep 18 01:41:37 GMT 2014

Powered by FUDForum. Page generated in 0.01909 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software