1

I am trying to connect to MySQL db using JPA and Spring. I am new to Spring.

I have added this to my config file where all the beans are defined:

<jee:jndi-lookup id="myEmf" jndi-name="hello-world"/>

<bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
   <property name="dataSource" ref="myEmf"/>
   <property name="loadTimeWeaver">
   <bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>
</bean>

Also Here is my persistence.xml, my persistence unit name is "hello-world".

<persistence-unit name="hello-world" transaction-type="RESOURCE_LOCAL">

org.hibernate.ejb.HibernatePersistence

When I try to instantiate the object, it throws me error.

Thanks, Sara.

Update, error:

2012/08/28 23-25-56,993:8a4cd57fec4d0:ERR:ERROR[Error parsing XML: XML InputStream(1) A pseudo attribute name is expected.] 2012-08-28 23:25:56,994 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/sara].[jsp]:704] : Servlet.service() for servlet jsp threw exception javax.persistence.PersistenceException: Unable to configure EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34) at com.paypal.sara.sara.web.sample.mvc.Main.getPoints(Main.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) at java.lang.reflect.Method.invoke(Method.java:599) at org.apache.commons.el.ArraySuffix.evaluate(ArraySuffix.java:314) at org.apache.commons.el.ComplexValue.evaluate(ComplexValue.java:145) at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:263) at org.apache.commons.el.ExpressionEvaluatorImpl.evaluate(ExpressionEvaluatorImpl.java:190)

Slava Semushin
  • 14,904
  • 7
  • 53
  • 69
Sara
  • 2,417
  • 7
  • 35
  • 52

1 Answers1

1

I found out what the problem was! Such a simple one but took my time.

I had <?xml version="1.0" encoding="UTF-8"> instead I should have had <?xml version="1.0" encoding="UTF-8"?>.

Thanks for your time.

Sara
  • 2,417
  • 7
  • 35
  • 52