I have facing some exception in My Spring project ..
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:data/data.xml]
Offending resource: class path resource [spring/application-config.xml]; nested exception is org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/tx
application-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config />
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<beans:property name="maxUploadSize" value="20000000"/>
</beans:bean>
<mvc:annotation-driven>
<mvc:message-converters>
<beans:bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<beans:property name="objectMapper">
<beans:bean class="com.danco.citiestalking.web.jackson.HibernateAwareObjectMapper" />
</beans:property>
</beans:bean>
</mvc:message-converters>
</mvc:annotation-driven>
<mvc:resources mapping="/resources/**" location="/content/" />
<context:component-scan base-package="com.app" />
<beans:bean id="companyFilter" class="com.aap.web.filters.CompanyFilter" />
<beans:import resource="classpath:data/data.xml" />
<beans:import resource="classpath:data/mail.xml" />
<!-- Ascpects -->
<aop:aspectj-autoproxy />
<beans:bean name="errorLogging" class="com.app.ErrorLoggingAspect"/>
<beans:bean name="debugLogging" class="com.app.DebugLoggingAspect"/>
<beans:bean name="traceLogging" class="com.danco.citiestalking.logging.TraceLoggingAspect"/>
<beans:bean class="com.danco.apns.service.Application" id="application">
<beans:constructor-arg type="String" value="${apns.sertificatePath}" />
<beans:constructor-arg type="String" value="${apns.sertificatePassword}" />
<beans:constructor-arg type="String" value="${apns.applicationName}" />
</beans:bean>
<context:component-scan base-package="com.danco.apns" />
<context:property-placeholder
location="classpath:asdasd.properties, classpath:asdasd.properties" ignore-unresolvable="true"/>
</beans:beans>
data.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<beans:bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="ignoreUnresolvablePlaceholders"
value="true" />
<beans:property name="location">
<beans:value>classpath:database.properties</beans:value>
</beans:property>
</beans:bean>
<beans:bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<beans:property name="sessionFactory" ref="sessionFactory"></beans:property>
</beans:bean>
<tx:annotation-driven transaction-manager="transactionManager"
order="100" />
<beans:bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="configLocation">
<beans:value>classpath:hibernate.cfg.xml</beans:value>
</beans:property>
<beans:property name="configurationClass">
<beans:value>org.hibernate.cfg.AnnotationConfiguration</beans:value>
</beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">${jdbc.dialect} </beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
</beans:beans>
jar using
spring-aop-3.2.9.RELEASE.jar
spring-beans-3.2.8.RELEASE.jar
spring-context-3.2.8.RELEASE.jar
spring-context-support-3.2.9.RELEASE.jar
spring-core-3.2.9.RELEASE.jar
spring-expression-3.2.8.RELEASE.jar
spring-jdbc-3.2.9.RELEASE.jar
spring-orm-3.2.9.RELEASE.jar
spring-tx-3.2.9.RELEASE.jar
spring-web-3.2.8.RELEASE.jar
spring-webmvc-3.2.8.RELEASE.jar
src/main/resource/spring/application-config.xml
src/main/resource/data/data.xml
Related
I am getting error
nested exception is java.lang.NoSuchMethodError:
javax/persistence/Table.indexes()[Ljavax/persistence/Index;
my controller-servlet.xml file is
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<!-- Resolves views selected for rendering by #Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/jsp/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<beans:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<beans:property name="url"
value="jdbc:oracle:thin:" />
<beans:property name="username" value="user" />
<beans:property name="password" value="123" />
</beans:bean>
<!-- Hibernate 4 SessionFactory Bean definition -->
<beans:bean id="hibernate4AnnotatedSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource" />
<beans:property name="annotatedClasses">
<beans:list>
<beans:value>com.company.bmdashboard.beans.BatchJob</beans:value>
</beans:list>
</beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
<beans:prop key="hibernate.hbm2ddl.auto">update</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
<beans:bean id="bMDashboardRepository" class="com.company.bmdashboard.repositories.BMDashboardRepositoryImpl">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
<beans:bean id="bMDashboardService" class="com.company.bmdashboard.services.BMDashboardServiceImpl">
<beans:property name="bMDashboardRepository" ref="bMDashboardRepository"></beans:property>
</beans:bean>
<context:component-scan base-package="com.company.bmdashboard" />
<tx:annotation-driven transaction-manager="transactionManager"/>
<beans:bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<beans:property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory" />
</beans:bean>
</beans:beans>
The jars file I have are
my RepositoryImpl is
#Repository
public class BMDashboardRepositoryImpl implements BMDashboardRepository{
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sf){
this.sessionFactory = sf;
}
#Override
public ArrayList<BatchJob> retrieveAllBatchJobs() {
// TODO Auto-generated method stub
System.out.println("Repository Impl: in retrieve all batch jobs");
Session session= sessionFactory.getCurrentSession();
#SuppressWarnings("unchecked")
List<BatchJob> allBatchJobs=session.createQuery("From BatchJob").list();
for(BatchJob bj:allBatchJobs)
{
System.out.println(bj.toString());
}
return (ArrayList<BatchJob>) allBatchJobs;
}
}
When I am publishing the code in webspehre, I am getting this error. I think there is some problem with jar files?
thanks in advance
I found the work around for this.
I was using WAS 8.5 which provides its own JDK which supports JPA 2.0 . #Table.indexes() method was introduced in JPA 2.1 .
Solution for this
1)Upgrade WAS to 9
2)Instead of using #Table annotation try using xml mapping . I used ClassName.hbm.xml.
This is my spring-context file:
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<beans:bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<beans:property name="basename" value="classpath:i18n/messages" />
<beans:property name="defaultEncoding" value="UTF-8" />
</beans:bean>
<annotation-driven/>
<resources mapping="/resources/**" location="WEB-INF/resources/" />
<context:component-scan base-package="com.softserve.edu.controller" />
<mvc:annotation-driven>
<mvc:argument-resolvers>
<ref bean="sortResolver"/>
<ref bean="pageableResolver" />
</mvc:argument-resolvers>
</mvc:annotation-driven>
<bean id="sortResolver" class="org.springframework.data.web.SortHandlerMethodArgumentResolver" />
<bean id="pageableResolver" class="org.springframework.data.web.PageableHandlerMethodArgumentResolver">
<constructor-arg ref="sortResovler" />
</bean>
...
When compiling I get
Element 'mvc:annotation-driven' must have no character or element information item [children], because the type's content type is empty
Why this error appear and how get this thing to work?
I'm sure that part with and is wrong, but I don't know how to fix this.
Try changing the schemaLocation to spring-mvc-3.2.xsd, it should work. But you have to use <bean class=""/> tag to register the resolvers. Bean reference won't work that way
May be try something like this:
<mvc:annotation-driven>
<mvc:argument-resolvers>
<beans:bean id="sortResolver"
class="org.springframework.data.web.SortHandlerMethodArgumentResolver" />
<beans:bean
class="org.springframework.data.web.PageableHandlerMethodArgumentResolver">
<beans:constructor-arg ref="sortResolver" />
</beans:bean>
</mvc:argument-resolvers>
</mvc:annotation-driven>
I have an application which I am developing Spring with Hibernate. Every thing went fine but when I try to test my transactions with the hibernate classes, it throwing an error saying "org.hibernate.HibernateException: No Session found for current thread". I can not find the error with me. Help would be really appreciated.
My main class :
public static void main(String[] args) {
Patient sac = new Patient();
sac.setPatient_Id("M2314");
sac.setPatient_Age(23);
sac.setPatient_Name("Sac");
sac.setPatient_Address("SGTY NY");
System.out.println("load context");
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("file:src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml");
PatientService patientService = (PatientService) context.getBean("patientService");
patientService.persistPatient(sac);
context.close();
}
Part of serviceImpl :
#Service("patientService")
public class PatientServiceImpl implements PatientService{
#Autowired
PatientDAO patientdao;
#Override
#Transactional
public void persistPatient(Patient patient) {
patientdao.persistPatient(patient);
}
Part of DAO class :
#Repository("patientdao")
public class PatientDAOImpl implements PatientDAO{
#Autowired
private SessionFactory sessionFactory;
#Override
#Transactional
public void persistPatient(Patient patient) {
sessionFactory.getCurrentSession().persist(patient);
}
My servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by #Controllers to .jsp resources
in the /WEB-INF/views directory -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.tela.pms" />
<beans:bean id="patientService" class="com.tela.pms.service.impl.PatientServiceImpl"/>
<beans:bean id="patientdao" class="com.tela.pms.dao.impl.PatientDAOImpl"/>
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
<beans:property name="url" value="jdbc:mysql://localhost:3306/test" />
<beans:property name="username" value="root" />
<beans:property name="password" value="root" />
</beans:bean>
<beans:bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<beans:property name="dataSource" ref="dataSource"></beans:property>
<beans:property name="annotatedClasses">
<beans:list>
<beans:value>com.tela.pms.domain.Patient</beans:value>
</beans:list>
</beans:property>
<beans:property name="hibernateProperties">
<beans:props>
<beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</beans:prop>
<beans:prop key="hibernate.show_sql">true</beans:prop>
</beans:props>
</beans:property>
</beans:bean>
<beans:bean id="transactionManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager"
p:sessionFactory-ref="sessionFactory">
</beans:bean>
</beans:beans>
In this case, I am not sure if you have enabled annotation-driven transaction management, as you have not provided the code for SpringBean.xml file.
You need to add this tag <tx:annotation-driven/> tag in your servlet-context.xml
In there also make sure to make it point to your transaction manager as follows
<tx:annotation-driven transaction-manager="transactionManager"/>
Rest of your code looks fine and this error should go away with above changes.
You have #Transactional the when and where but not the how. Add <tx:annotation-driven /> to enable annotation processing for #Transactional.
Adding will be a solution, but I got another related to that. So I had to do this chang in my servlet-context.xml (part of it is here):
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing
infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<tx:annotation-driven />
Changes :
add <tx:annotation-driven />. And notice that added http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd to the xsi:schemaLocation in beans:beans declaration. Then it will work fine.
I want to add webflow to a web. I have the webflow dependency in the pom.xml, I have started to add beans, but seems unable to find any tag, as I see in every tutorial. I have all my beans in servlet-context.xml, and this is it:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<mvc:annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by #Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<!-- <beans:bean class="my.package.Controllers.LoginController"></beans:bean>-->
<!-- <beans:bean class="my.package.Controllers.NewUserFormController"></beans:bean>-->
<!-- <beans:bean class="my.package.Controllers.QueEsController"></beans:bean>-->
<beans:bean class="my.package.Services.UsuarioServiceImp"></beans:bean>
<beans:bean class="my.package.Dao.UserDaoImp">
<beans:property name="dataSource" ref="dataSource"></beans:property>
</beans:bean>
<beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver"></beans:property>
<beans:property name="url" value="jdbc:mysql://localhost:3306/myschema"></beans:property>
<beans:property name="username" value="myusername"></beans:property>
<beans:property name="password" value="mypassword"></beans:property>
</beans:bean>
<beans:bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<beans:property name="dataSource" ref="dataSource"></beans:property>
</beans:bean>
<context:component-scan base-package="my.package" />
<beans:bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<beans:property name="mappings">
<beans:value>inicio.do=flowController</beans:value>
</beans:property>
<beans:property name="alwaysUseFullPath" value="true"></beans:property>
</beans:bean>
<beans:bean id="flowcontroller" class="org.springframework.webflow.mvc.servlet.FlowController">
<beans:property name="flowExecutor" ref="flowExecutor"></beans:property>
</beans:bean>
When I try to add any webflow tag, for example:
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry"/>
It show an error:
Multiple annotations found at this line:
- The prefix "webflow" for element "webflow:flow-executor" is not
bound.
Seems that he can't find any webflow-related tag, despite I have it in the schemaLocation.
Any help? Thank you.
EDIT: Im using 3.1.1-RELEASE version of Spring, as seen on the pom.xml:
<org.springframework-version>3.1.1.RELEASE</org.springframework-version>
Include webflow namespace as shown below:
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">
Any ideas, what could cause this error?
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate Spring NamespaceHandler for
XML schema namespace [http://www.springframework.org/schema/data/jpa]
Offending resource: ServletContext resource
[/WEB-INF/spring/appServlet/servlet-context.xml]
Here is my 'servle-context.xml' (there are some problems with the indents, but the file is too huge...):
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by #Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.epam.mvc3.model" />
<context:component-scan base-package="com.epam.mvc3.controller" />
<!-- JPA -->
<beans:bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<beans:property name="location">
<beans:value>resources/database.properties</beans:value>
</beans:property>
</beans:bean>
<beans:bean id="myDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<beans:property name="driverClassName">
<beans:value>${jdbc.driverClassName}</beans:value>
</beans:property>
<beans:property name="url">
<beans:value>${jdbc.url}</beans:value>
</beans:property>
<beans:property name="username">
<beans:value>${jdbc.username}</beans:value>
</beans:property>
<beans:property name="password">
<beans:value>${jdbc.password}</beans:value>
</beans:property>
</beans:bean>
<beans:bean id="myEmf"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<beans:property name="dataSource" ref="myDataSource" />
<beans:property name="persistenceUnitName" value="application" />
<beans:property name="persistenceXmlLocation"
value="classpath*:META-INF/persistence.xml" />
<beans:property name="jpaVendorAdapter" ref="hibernateVendor" />
<beans:property name="loadTimeWeaver">
<beans:bean
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"></beans:bean>
</beans:property>
</beans:bean>
<beans:bean id="hibernateVendor"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
</beans:bean>
<beans:bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<beans:property name="entityManagerFactory" ref="myEmf"></beans:property>
</beans:bean>
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- Spring Data configuration -->
<jpa:repositories base-package="com.epam.mvc3.repository"/>
</beans:beans>
As you can see, i specified the path to the jpa-schema. And I don't know what is the problem
Try to replace
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
by
http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
But if you still use Version 1.0-M1 then try to update first. DATAJPA-21
Make sure you have spring-data-jpa in your dependencies
If you use maven:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.7.0.RELEASE</version>
</dependency>
I fixed this by resolving the missing the spring-tx dependency in our project.
org.springframework:spring-tx
The issue is because the spring-jpa schema cannot be located . You might be having some old jar which does not contain the schema info .
I know this seems silly, but if you are using IDEA and Maven you should check to make sure you have Use plugin registry checked so that the server also has access to your jar files.
I would post a screen shot but I'm new on here and don't have enough reputation points. It does work though and I've verified with the support team at IntelliJ
After facing this same problem over a week, I found a solution. If you are using Spring MVC + JPA + Maven, use this dispatcher-servlet.xml
<?xml version="1.0" encoding="windows-1252"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- Use #Component annotations for bean definitions -->
<context:component-scan base-package="PACKAGE WHERE YOU CAN FIND YOUR SOURCE CODE"/>
<!-- Use #Controller annotations for MVC controller definitions -->
<mvc:annotation-driven />
<!-- Add JPA support -->
<bean id="emf" class=
"org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="loadTimeWeaver">
<bean class=
"org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>
</bean>
<!-- Add Transaction support -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="emf"/>
</bean>
<!-- Use #Transaction annotations for managing transactions -->
<tx:annotation-driven transaction-manager="transactionManager" />
<!-- View resolver -->
<bean class=
<!-- HERE YOU REPLACE PROPERTY VALUE TO MATCH YOUR VIEW FOLDER (JSP PAGES) -->
"org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/web/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
too late, but this solved my problem:
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.9.4.RELEASE</version>
</dependency>