Description Resource Path Location Type cvc-complex-type.2.4 - eclipse

hey guys when i write the tag in the applicationContext.xml i got error"Description Resource Path Location Type
cvc-complex-type.2.4.a: Invalid content was found starting with element 'property'" from eclipse i dont know why.
this is the applicationConext.xml :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="dao" class="org.gestion.bp.dao.BanqueDaoImp"></bean>
<bean id="metier" class="org.gestion.bp.metier.BanqueMetierImp"></bean>
<property name="dao" ref="dao"></property>
</beans>

Here:
<bean id="metier" class="org.gestion.bp.metier.BanqueMetierImp"></bean>
<property name="dao" ref="dao"></property>
</beans>
You have closed the 'bean' with </bean> before the property. It should be:
<bean id="metier" class="org.gestion.bp.metier.BanqueMetierImp">
<property name="dao" ref="dao"></property>
</bean>
</beans>

Related

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'batch- int:remote-chunking-slave'

sorry if this question has been already answered, I'm trying to build spring batch with remote chunking and a have an error with "cvc-complex-type.2.4.c" - I find so many answer cvc-complex-type.2.4.c:... but none of it say about "batch- int:remote-chunking-slave" about So here's my xml file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch-int="http://www.springframework.org/schema/batch-integration"
xmlns:int="http://www.springframework.org/schema/integration"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration
http://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<batch-int:remote-chunking-slave id="remote-chunking-slave" input-channel="requests" output-channel="replies"
item-processor="itemProcessor" item-writer="itemWriter"/>
<bean id="itemProcessor" class="io.spring.remotechunkingslave.processor.ImageProcessor">
<constructor-arg index="0" value="${unprocessed.images.dir}"/>
<constructor-arg index="1" value="200"/>
<constructor-arg index="2" value="150"/>
</bean>
<bean id="itemWriter" class="io.spring.remotechunkingslave.writer.ImageWriter">
<constructor-arg index="0" value="${processed.images.dir}"/>
<constructor-arg index="1" value="jpg"/>
</bean>
</beans>
And any have error in:
<batch-int:remote-chunking-slave id="remote-chunking-slave" input-channel="requests" output-channel="replies"
item-processor="itemProcessor" item-writer="itemWriter"/>
Can I get any advice on what's happening here?

xml schema for Springbatch3.0.1?

i am trying to accomplish spring batch in spring 3.0.1 and sufficient jars have been included in the class path.when i am trying to run the project with command line job runner i am getting a error that shows because of miss match xml schema for spring3.0.1. i have 3 differnt xml files as below
ApplicationContext.xml
<?xml version="1.0" encoding="UTF-8"?><?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
xsi:schemalocation="
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<import resource="JobRepository.xml" />
</beans>
jobConfiguration.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation="
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<import resource="ApplicationContext.xml" />
<bean abstract="true"
class="org.springframework.batch.core.step.tasklet.TaskletStep" id="taskletStep">
<property name="jobRepository" ref="jobRepository" />
<property name="transactionManager" ref="transactionManager" />
</bean>
<bean class="com.mypackage.HelloWorldTasklet" id="helloTasklet">
<property name="message" value="Hello World!" />
</bean>
<bean class="com.mypackage.HelloWorldTasklet" id="createdByTasklet">
<property name="message" value="Created By Harish On Java" />
</bean>
<bean class="org.springframework.batch.core.job.SimpleJob" id="mySimpleJob">
<property name="name" value="mySimpleJob" />
<property name="steps">
<list>
<bean parent="taskletStep">
<property name="tasklet" ref="helloTasklet" />
</bean>
<bean parent="taskletStep">
<property name="tasklet" ref="createdByTasklet" />
</bean>
</list>
</property>
<property name="jobRepository" ref="jobRepository" />
</bean>
</beans>
JobRepository.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
xsi:schemalocation="
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<bean
class="org.springframework.batch.core.repository.support.SimpleJobRepository"
id="jobRepository">
<constructor-arg>
<bean
class="org.springframework.batch.core.repository.dao.MapJobInstanceDao" />
</constructor-arg>
<constructor-arg>
<bean
class="org.springframework.batch.core.repository.dao.MapJobExecutionDao" />
</constructor-arg>
<constructor-arg>
<bean
class="org.springframework.batch.core.repository.dao.MapStepExecutionDao" />
</constructor-arg>
<constructor-arg>
<bean
class="org.springframework.batch.core.repository.dao.MapExecutionContextDao" />
</constructor-arg>
</bean>
<bean id="transactionManager"
class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
<bean class="org.springframework.batch.core.launch.support.SimpleJobLauncher"
id="jobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
</beans>
Java Code:
public class HelloWorldTasklet implements Tasklet {
private String message;
public void setMessage(String message) {
this.message = message;
}
#Override
public RepeatStatus execute(StepContribution contribution,
ChunkContext context) throws Exception {
// TODO Auto-generated method stub
System.out.println(message);
return RepeatStatus.FINISHED;
}
}
my lib contained following jars
com.springsource.org.aopalliance-1.0.0.jar
com.springsource.org.apache.commons.lang-sources-2.1.0.jar
com.springsource.org.apache.commons.logging-1.1.1.jar
com.springsource.org.apache.log4j-1.2.15.jar
commons-beanutils-1.8.3.jar
commons-codec-1.3.jar
commons-collections-3.2.jar
commons-digester-1.8.jar
commons-lang3-3.1.jar
commons-logging-1.1.1.jar
org.springframework.aop-3.0.1.RELEASE-A.jar
org.springframework.asm-3.0.1.RELEASE-A.jar
org.springframework.aspects-3.0.1.RELEASE-A.jar
org.springframework.beans-3.0.1.RELEASE-A.jar
org.springframework.context-3.0.1.RELEASE-A.jar
org.springframework.context.support-3.0.1.RELEASE-A.jar
org.springframework.core-3.0.1.RELEASE-A.jar
org.springframework.expression-3.0.1.RELEASE-A.jar
org.springframework.web-3.0.1.RELEASE-A.jar
org.springframework.web.servlet-3.0.1.RELEASE-A.jar
spring-batch-core-2.2.0.RELEASE.jar
spring-batch-infrastructure-2.2.0.RELEASE.jar
any response is appreciated greatly in advance.
You have the Spring Batch 2.2.0.RELEASE jars on your classpath, yet you aren't specifying that version in your schemas. Update to use the versions and you'll be fine.
As a side note, is there a reason you are not using the schemas in your configuration? While you're configuring batch components, you're doing it the hard way by not using the namespace or factory beans. For example, instead of:
<bean
class="org.springframework.batch.core.repository.support.SimpleJobRepository"
id="jobRepository">
<constructor-arg>
<bean
class="org.springframework.batch.core.repository.dao.MapJobInstanceDao" />
</constructor-arg>
<constructor-arg>
<bean
class="org.springframework.batch.core.repository.dao.MapJobExecutionDao" />
</constructor-arg>
<constructor-arg>
<bean
class="org.springframework.batch.core.repository.dao.MapStepExecutionDao" />
</constructor-arg>
<constructor-arg>
<bean
class="org.springframework.batch.core.repository.dao.MapExecutionContextDao" />
</constructor-arg>
</bean>
you can do this:
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="transactionManager" ref="transactionManager"/>
</bean>
We also have namespace support for the job configuration. Instead of:
<bean class="org.springframework.batch.core.job.SimpleJob" id="mySimpleJob">
<property name="name" value="mySimpleJob" />
<property name="steps">
<list>
<bean parent="taskletStep">
<property name="tasklet" ref="helloTasklet" />
</bean>
<bean parent="taskletStep">
<property name="tasklet" ref="createdByTasklet" />
</bean>
</list>
</property>
<property name="jobRepository" ref="jobRepository" />
</bean>
you should try this:
<batch:job id="mySimpleJob">
<batch:step id="step1" next="step2">
<batch:tasklet ref="helloTasklet"/>
</batch:step>
<batch:step id="step2">
<batch:tasklet ref="createdByTasklet"/>
</batch:step>
</batch:job>
The namespaces handle some niceties like auto wiring the job repositories and transaction managers, etc. I'd recommend you take a look at the Spring Batch documentation here: http://docs.spring.io/spring-batch/2.2.x/reference/html/index.html

How to create a bean which extends JpaRepository

I want to write a unit test for a DAO. But in our project, we have more than 200 DAO and 200 model classes. And we use jpaRepository to write DAO. But I have a problem when I run my unit test. I take a lot of time to create application context. I have an idea. I only create a bean DAO which I want to test instead of creating all DAO. But DAO of jpa:repository is interface, so I can not create a bean with class is interface. If creating a bean which extend jpa:reponsitories is imposible, can you suggest me other ways to run unit faster.
my unit test:
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(locations = {"classpath:META-INF/spring/testContext.xml"})
#TransactionConfiguration(defaultRollback = true)
// Importance, as the transaction will be rollback for each test
// give us a clean state.
#Transactional
public class CommunicationDetailDAOTest
{
#Autowired
CommunicationDetailDAO communicationDetailDAO;
#Test
public void testSomeThing()
{
System.out.println("helloworld");
}
}
file testContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="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.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:META-INF/spring/properties/prism_local_persistence_test.properties"/>
</bean>
<bean id="entityManager" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="persistenceXmlLocation" value="/META-INF/persistence.xml"/>
<property name="persistenceUnitName" value="mobilePersistenceUnit"/>
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"></bean>
</property>
</bean>
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${db.driver}"/>
<!--using postgres driver-->
<property name="url" value="${db.url}"/>
<property name="username" value="${db.username}"/>
<property name="password" value="${db.password}"/>
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="dataSource" ref="dataSource"></property>
<property name="entityManagerFactory" ref="entityManager"/>
</bean>
<!-- Spring Data Jpa setup -->
<jpa:repositories
base-package="com.discorp.model.dao"
entity-manager-factory-ref="entityManager"
transaction-manager-ref="transactionManager"></jpa:repositories>
<tx:annotation-driven transaction-manager="transactionManager"/>
<!--<context:component-scan base-package="com.qsoft"/>-->
</beans>
and file persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
<persistence-unit name="mobilePersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.discorp.model.common.Address</class>
<class>com.discorp.model.common.Application</class>
.... more than 200 model classes
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.show_sql" value="false"/>
<!--<property name="hibernate." value="false"/> -->
</properties>
</persistence-unit>
</persistence>
Make different config files for different tests an include only the dao(s) needed by the test:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xmlns:repository="http://www.springframework.org/schema/data/repository"
...
xsi:schemaLocation="http://www.springframework.org/schema/beans
...
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
http://www.springframework.org/schema/data/repository
http://www.springframework.org/schema/data/repository/spring-repository.xsd
...">
...
<jpa:repositories base-package="path.to.your" >
<repository:include-filter type="assignable" expression="path.to.your.Repository"/>
</jpa:repositories>

Conflicting persistence unit definitions

Spring 3.1.1
Maven 3.0.4
JPA
Eclipse wtp indigo
Hello,
I am getting the following exception on server startup. I have just one persistence.xml in my project. Any ideas? Thanks Eric
Caused by: java.lang.IllegalStateException: Conflicting persistence unit definitions for name 'cassandra_pu': file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/cassandra/WEB-INF/classes/, file:/C:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/cassandra/WEB-INF/classes/
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:362)
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:326)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:235)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1514)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 62 more
My context file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<context:component-scan base-package="hamacher.cassandra.controller" />
<context:component-scan base-package="hamacher.cassandra.dao" />
<context:component-scan base-package="hamacher.cassandra.service" />
<context:annotation-config />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="packagesToScan" value="hamacher.cassandra.entity"/>
<property name="persistenceUnitName" value="cassandra_pu"/>
</bean>
<tx:annotation-driven />
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
</beans>
My persistence.xml file is in META-INF where it should be:
<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="cassandra_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<properties>
<property name="kundera.nodes" value="localhost"/>
<property name="kundera.port" value="9160"/>
<property name="kundera.keyspace" value="KunderaExamples"/>
<property name="kundera.dialect" value="cassandra"/>
<property name="kundera.client.lookup.class" value="com.impetus.client.cassandra.pelops.PelopsClientFactory" />
<property name="kundera.cache.provider.class" value="com.impetus.kundera.cache.ehcache.EhCacheProvider"/>
<property name="kundera.cache.config.resource" value="/ehcache-test.xml"/>
</properties>
</persistence-unit>
</persistence>
Try adding,
<bean
class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean id="emf-p"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<!-- <property name="persistenceXmlLocation" value="/WEB-INF/classes/META-INF/persistence.xml" /> -->
<property name="persistenceUnitManager" ref="pum"/>
<property name="persistenceUnitName" value="personnel_cass_pu" />
<property name="loadTimeWeaver">
<bean
class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver" />
</property>
</bean>
To define your persistence.xml location with Spring bean.
You can also refer:
https://github.com/xamry/twitample/blob/master/src/main/resources/appContext.xml
for persistence.xml specific configuration.

How do I make this spring class not found error go away?

Will someone please explain why I'm getting this build error, when the class is obviously there. Here's the error -
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-servlet.xml]; nested exception is java.lang.NoClassDefFoundError: org/springframework/aop/scope/ScopedProxyUtils
and here's my spring-servlet.xml file -
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<context:annotation-config />
<context:component-scan
base-package="com.website" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<value>/WEB-INF/messages/messages</value>
</property>
<property name="cacheSeconds" value="60" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
</beans>
I also have the aop jar on my classpath-
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/org.springframework.aop-sources-3.0.5.RELEASE.jar"/>
That is the sources jar...
path="WebContent/WEB-INF/lib/org.springframework.aop-sources-3.0.5.RELEASE.jar"
Get the binary release version.