Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

EntityManager persist not working

793919Nov 25 2009 — edited Nov 30 2009
Hi ,

A simple EntityManager persist method not working . Please help .
<persistence-unit name="SakshiPU"
		transaction-type="RESOURCE_LOCAL">
		<provider>org.hibernate.ejb.Hibernate	Persistence</provider>
		<class>urpack.Test</class>
		<properties>
			<property name="hibernate.connection.driver_class"
				value="oracle.jdbc.driver.OracleDriver" />
			<property name="hibernate.connection.url"
				value="jdbc:oracle:thin:@localhost:1521:ORCL" />
			<property name="hibernate.connection.username"
				value="system" />
			<property name="hibernate.connection.password"
				value="admin" />
		</properties>
	</persistence-unit>
This is my servlet using ContainerManaged EntityManager in it .
public class Getter extends HttpServlet {

	@PersistenceContext
	EntityManager manager;
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		
		manager.getTransaction().begin();

		
		Test ter = new Test();
		
		ter.setName("Sainath");
		
		manager.persist(ter);
		
		manager.getTransaction().commit();
		
	}
I am getting this Exception

java.lang.IllegalStateException: The method public abstract javax.persistence.EntityTransaction javax.persistence.EntityManager.getTransaction() cannot be invoked in the context of a JTA EntityManager.
* at weblogic.deployment.BasePersistenceContextProxyImpl.validateInvocation(BasePersistenceContextProxyImpl.java:110)*
* at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:86)*
* at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:89)*
* at weblogic.deployment.BasePersistenceContextProxyImpl.invoke(BasePersistenceContextProxyImpl.java:80)*
* at weblogic.deployment.TransactionalEntityManagerProxyImpl.invoke(TransactionalEntityManagerProxyImpl.java:24)*
* Truncated. see log file for complete stacktrace*


Upto my knowledge i am not using JTA Anywhere .

Please help

Edited by: raviprivate on Nov 25, 2009 7:40 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 28 2009
Added on Nov 25 2009
2 comments
1,357 views