meu applicationContext XML
<?xml version="1.0" encoding="UTF-8"?><bean id="AthenaDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="oracle.jdbc.OracleDriver" />
<property name="url" value="jdbc:oracle:thin:@localhost:1521:XE" />
<property name="username" value="restorant" />
<property name="password" value="brutal" />
</bean>
<util:list id="persistentXmlPaths">
<value>src/META-INF/persistence.xml</value>
</util:list>
<bean id="defaultPersistentUnitName" class="java.lang.String">
<constructor-arg value="AthenaPersistence" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
autowire-candidate="default">
<!-- <property name="persistenceUnitManager" ref="persistenceUnitManager"/>-->
<property name="persistenceUnitName" value="AthenaPersistence" />
</bean>
<util:map id="dataSources">
<entry key="AthenaDataSource">
<ref local="AthenaDataSource" />
</entry>
</util:map>
<context:component-scan base-package="br.com.restorant.service.impl" />
meu Persistence.xml
<?xml version="1.0" encoding="UTF-8"?> oracle.toplink.essentials.PersistenceProvider AthenaDataSourceimport org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import br.com.restorant.entity.Category;
import br.com.restorant.service.CategoryService;
public class Execute {
/**
* @param args
*/
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
CategoryService service = (CategoryService)context.getBean("CategoryServiceImpl");
for (Category c : service.findAll()){
System.out.println(c);
}
}
}
Ao executar ocorre esse erro
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [ApplicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'AthenaDataSource'; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial