"There is no persistence unit named" product "found"

I recently completed this tutorial: " http://static.springsource.org/docs/Spring-MVC-step-by-step/ ", but now I want it to work with Hibernate and annotations. I know that I am near, but I ended up at the checkpoint, and I can’t understand this. I posted my code on the Spring forums here . I would really appreciate any help. Thanks

I am trying to include annotations and hibernation in it, but I am having a problem and I cannot figure it out. I keep getting errors “There is no unit of duration with the name“ product found. ”ANY help would be greatly appreciated.

+7
source share
4 answers

You need META-INF/persistence.xml , with <persistence-unit name="product"> . Look here

(Usually I put it in WEB-INF/classes/META-INF . As noted in the comments, with maven you can put it in src/main/resources/META-INF )

+23
source

I ran into the same problem and had to manually reconfigure the web deployment assembly to specify / META -INF / persistence.xml to deploy to WEB-INF / classes / (the red box in the attached img was manually edited)

enter image description here

+2
source

this is an example persistence.xml file

 <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0"> <persistence-unit name="poduct" transaction-type="RESOURCE_LOCAL"> </persistence-unit> </persistence> 

create this file inside " src / main / resources / META-INF " if you are using a Maven project.

+1
source

I have the same problem. But when you use ide (e.g. eclipse) and configure your server in ide. When you advertise a piece and restart the server, it always has the same error, since a persistence block is detected, you need to delete this part of the server and perform the deployment in oldway. Log in to the console and set the world for your project and work!

And yet, when you check the diagnostics in wls, you need to indicate who the user owns jdbc, select and check (for example, AdminServer) and save and check again !!

: D

0
source

All Articles