don't put persistence.xml in war folder, put it here:

${basedir}/src/main/resources/META-INF/persistence.xml

When you build, maven will make sure it goes in the classes dir of your
webapp (i.e. app.war!/WEB-INF/classes/persistence.xml)


On Tue, Nov 3, 2009 at 3:03 PM, Yaakov Chaikin <[email protected]>wrote:

>
> Hi,
>
> I am trying to get hosted mode to work in Eclipse 3.4 with GWT plugin
> 1.7 on Windows...
>
> Here is what I have:
>
> 1) Maven folder structure, as I use maven to compile/deploy the whole
> thing.
> 2) 3 separate modules (eclipse projects): Persistence, Model, and Web
> (this is the GWT project).
> 3) Model has JPA annotated POJOs
> 4) Persistence has Spring annotated DAOs like this:
> @Service
> @Transactional
> public UserDAOImpl implements UserDAO
> {
>   @PersistenceContext(unitName="testUnit")
>   private EntityManager manager;
>
>   public User getUser(String userName)
>   {
>      // some JPA code
>   }
> }
>
> 5) The Persistence module has persistence.xml in
> src/main/resource/META-INF which looks like this:
> <.... standard header stuff...>
>  <persistence-unit name="testUnit" transaction-type="RESOURCE_LOCAL">
>     <class>test.User</class>
>     <properties>
>        <property name="toplink.jdbc.driver"
> value="oracle.jdbc.driver.OracleDriver" />
>        <property name="toplink.jdbc.url"  value="oracle URL" />
>        <property name="toplink.jdbc.user" value="user" />
>       <property name="toplink.jdbc.password" value="password" />
>   </properties>
> </persistence-unit>
>
> 6) In my Web module, I load this Spring configuration:
>
> <... standard header stuff....>
>  <bean id="entityManagerFactory"
>          class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
>   <property name="persistenceUnitName" value="testUnit">
>  </bean>
>  .....
>  there are other things defined here
>  .....
>
>
> I think it is #6 where things are getting stuck... When I try to start
> Eclipse GWT in Hosted mode, the console spits out "error creating bean
> with name 'entityManagerFactory' defined in class path resource
> test-context.xml: Invocation of init method failed; nested exception
> is java.lang.IllegalArgumentException: No persistence unit with name
> 'testUnit' found
>
> I have no idea why this is happening... I already tried to create a
> directory under my 'war' directory in the Web module called META-INF
> and place the persistence.xml there, but it still says it can't find
> the persistence unit with name 'testUnit'...
>
> My maven dependencies bring the following into classpath (besides the
> other 2 modules this one depends on and besides the usual gwt ones):
> <dependency>
>  <groupId>java.persistence</groupId>
>  <artifactId>persistence-api</artifactId>
>  <version>1.0</version>
> </dependency>
> <dependency>
>  <groupId>oracle</groupId>
>  <artifactId>jdbc</artifactId>
>  <version>1.4</version>
> </dependency>
> <dependency>
>  <groupId>oracle</groupId>
>  <artifactId>oracle.toplink.essentials</artifactId>
>  <version>2.1-b60e-fcs</version>
> </dependency>
> <dependency>
>  <groupId>commons-dbcp</groupId>
>  <artifactId>commons-dbcp</artifactId>
>  <version>1.2.2</version>
> </dependency>
>
> Obviously, there is more, but the bottom line is, for some reason, it
> refuses to recognize my persistence unit... This is very frustrating
> as I can't imagine having to redeploy every time I need to make GUI
> update... One of the biggest points of GWT basically is out the
> window.
>
> I tried following what this blog pointed out (which is basically what
> I've described above, but still have the same issues):
>
> http://codetrips.blogspot.com/2009/05/gwt-spring-and-jpa-not-really-friendly.html
>
> I can't imagine no one has used GWT with Spring and JPA and I am the
> first one, so whoever knows the magic solution for this, please help
> me out. I'd really appreciate it.
>
> Thanks,
> Yaakov.
>
> >
>


-- 
Zeno Consulting, Inc.
home: http://www.zenoconsulting.biz
blog: http://zenoconsulting.wikidot.com
p: 248.894.4922
f: 313.884.2977

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to