I am using Spring 3.1.1 with mule.
The versions of the jars used inside mule are 3.1.1 RELEASE.
Inside my configuration XML which is a mule flow,
I am getting following SAX parser exception.
Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'context:component-scan'. One of '{"http://www.mulesoft.org/schema/mule/core":annotations, "http://www.mulesoft.org/schema/mule/core":description, "http://www.springframework.org/schema/beans":beans, "http://www.springframework.org/schema/beans":bean, "http://www.springframework.org/schema/context":property-placeholder, "http://www.springframework.org/schema/beans":ref, "http://www.mulesoft.org/schema/mule/core":global-property, "http://www.mulesoft.org/schema/mule/core":configuration, "http://www.mulesoft.org/schema/mule/core":notifications, "http://www.mulesoft.org/schema/mule/core":abstract-extension, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-extension, "http://www.mulesoft.org/schema/mule/core":abstract-agent, "http://www.mulesoft.org/schema/mule/core":abstract-security-manager, "http://www.mulesoft.org/schema/mule/core":abstract-transaction-manager, "http://www.mulesoft.org/schema/mule/core":abstract-connector, "http://www.mulesoft.org/schema/mule/core":abstract-global-endpoint, "http://www.mulesoft.org/schema/mule/core":abstract-exception-strategy, "http://www.mulesoft.org/schema/mule/core":abstract-flow-construct, "http://www.mulesoft.org/schema/mule/core":flow, "http://www.mulesoft.org/schema/mule/core":sub-flow, "http://www.mulesoft.org/schema/mule/core":abstract-model, "http://www.mulesoft.org/schema/mule/core":abstract-interceptor-stack, "http://www.mulesoft.org/schema/mule/core":abstract-filter, "http://www.mulesoft.org/schema/mule/core":abstract-transformer, "http://www.mulesoft.org/schema/mule/core":processor-chain, "http://www.mulesoft.org/schema/mule/core":custom-processor, "http://www.mulesoft.org/schema/mule/core":invoke, "http://www.mulesoft.org/schema/mule/core":abstract-global-intercepting-message-processor, "http://www.mulesoft.org/schema/mule/core":custom-queue-store, "http://www.mulesoft.org/schema/mule/core":abstract-processing-strategy}' is expected.
My mule flow is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:core="http://www.mulesoft.org/schema/mule/core" version="CE-3.3.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/current/mule-jms.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">
<context:component-scan base-package="com.comviva.mfs.eig.logging.dataAccess" />
<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
I made sure that both xsi:schemaLocation and xmlns:context are declared.
Cannot figure out why sax parser exception is occurring.
Please Help me out.
Update:
Any Solution to Separate both the XML files will also work for me.
Please help me how to maintain separate ApplicationContext.xml for spring in our mule application.
I think you cannot use <context:component-scan> as a direct child of <mule>. Try the following:
<mule ...>
<spring:beans>
<context:component-scan ... />
</spring:beans>
</mule>
This is answer for the Update part of your question:
You can move <context:component-scan> alone to a new context file this way:
appnewcontext.xml:
<context:component-scan base-package="com.comviva.mfs.eig.logging.dataAccess" />
and import into the main one:
<beans:import resource="appnewcontext.xml"/>
You can ignore the resource is not defined error. That is a bug but doesn't impact your application from running.
Related
I'm exploring cache in spring mvc framework. Following the guide on internet like here or here, i'm configuring:
<?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:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p"
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/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.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven />
... other configuration are omitted....
</beans>
Before adding configuration for cache, my web app run normally, now, my web app start with error:
java.lang.NoClassDefFoundError: org/springframework/cache/interceptor/CacheInterceptor
Not sure what i did wrong?
A NoClassDefFoundError is simply an exception that is thrown when java can't find a certain class that another library uses.
All this means is that when it gets thrown you just need to get it on the classpath. You can make sure it's there by going to libraries-> maven dependencies(if you are using maven) -> and then go to the location of the noclassdef that is being thrown, in your case it would be at org/springframework/cache/interceptor/CacheInterceptor, this is just so you know why you are getting this error, you should not see it now.
As for how to solve it, this could be happening because of 3 things:
Your maven dependencies are not on the deployment assemblies(libraries are in the project, but not on the server), although probably spring wouldn't work at all if this was the case.
You don't have the dependency, add this to pom.xml:
org.springframework
spring-context
4.1.4.RELEASE
You have conflicting spring versions, make all version tags the same.
Spring-integration-kafka -
I am creating Spring-integration-kakfa application but while startup it gives me error, please find below error stack -
Caused by: org.xml.sax.SAXParseException; lineNumber: 24; columnNumber: 110; cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'int-kafka:inbound-channel-adapter'.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:203)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:396)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:327)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:284)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:452)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3230)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1911)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)
I can find couple of example with Java based configuration but need XML based configuration for Kafka producer and consumer. Can anyone please help me on this ?
kafka-inbound-channel.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:int="http://www.springframework.org/schema/integration"
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/kafka/
http://www.springframework.org/schema/integration/kafka/spring-integration-kafka-1.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd">
<int:channel id="inputFromKafka">
<int:dispatcher task-executor="kafkaMessageExecutor" />
</int:channel>
<task:executor id="kafkaMessageExecutor" pool-size="0-10"
keep-alive="120" queue-capacity="500" />
<int-kafka:inbound-channel-adapter kafka-consumer-context-ref="consumerContext" channel="inputFromKafka">
<int:poller fixed-delay="10" />
</int-kafka:inbound-channel-adapter>
<int-kafka:consumer-context id="consumerContext"
consumer-timeout="4000" zookeeper-connect="zookeeperConnect">
<int-kafka:consumer-configurations>
<int-kafka:consumer-configuration
group-id="default" value-decoder="deccoder" key-decoder="deccoder"
max-messages="5000">
<int-kafka:topic id="FppTopic1" streams="4" />
<int-kafka:topic id="FppTopic2" streams="4" />
</int-kafka:consumer-configuration>
</int-kafka:consumer-configurations>
</int-kafka:consumer-context>
<int-kafka:zookeeper-connect id="zookeeperConnect"
zk-connect="sd-dc1b-b0ce:2181"
zk-connection-timeout="6000"
zk-session-timeout="6000"
zk-sync-time="2000"/>
<bean id="deccoder" class="org.springframework.integration.kafka.serializer.common.StringDecoder" />
</beans>
Other configuration is plain Spring MVC application configuration in dispatcher servlet importing resource as 'kafka-inbound-channle.xml' but after import statement it gives this error
You should show your XML config, indeed. Otherwise it is really hard to help just having a coffee dust.
You can find some samples in the project's tests: https://github.com/spring-projects/spring-integration-kafka/tree/master/src/test/java/org/springframework/integration/kafka/config/xml
On the other hand, sometimes this is an error in the IDE. Consider to use Spring-compliant one. For example IntelliJ IDEA or STS.
Since moving to Spring Security 3.2.5.RELEASE and Spring 4.1.1.RELEASE we are getting a Spring Bean Validation warning in Eclipse (Luna).
The exact warning is:
Class 'org.springframework.security.core.authority.AuthorityUtils' is abstract
Here is the header to this Spring 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:tx="http://www.springframework.org/schema/tx" xmlns:springsecurity="http://www.springframework.org/schema/security"
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.1.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.1.xsd">
The offending portion of configuration is as follows (meaning that if I remove this section the error goes away. Specifically, if I remove the springsecurity:authentication-provider stanza:
<springsecurity:authentication-manager alias="authenticationManager">
<springsecurity:authentication-provider>
<springsecurity:user-service>
<springsecurity:user name="john" password="john"
authorities="ROLE_USER" />
<springsecurity:user name="admin" password="admin"
authorities="ROLE_USER, ROLE_ADMIN" />
<springsecurity:user name="guest" password="guest"
authorities="ROLE_GUEST" />
</springsecurity:user-service>
</springsecurity:authentication-provider>
</springsecurity:authentication-manager>
Any ideas on the root cause of this? Our project doesn't put up with spurious warnings and I don't want to disabled Spring bean validation.
This is a bug in version 3.6.0 of the Spring Tool Suite, as Luke Taylor pointed out. The bug report is at https://issuetracker.springsource.com/browse/STS-3875, and won't be fixed before STS version 3.6.3. You can examine the code for this class at http://www.docjar.com/html/api/org/springframework/orm/jpa/SharedEntityManagerCreator.java.html
[Edit] The bug report notes that this bug is now fixed. The fix is in version 3.6.4
I tried everything I can think of, but nothing seems to work.
I am using the current version of Spring Framework (3.2) in my java web application.
Every time I start my project I get the following error:
cvc-elt.1: Cannot find the declaration of element 'beans'
this is my applicationContext.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-3.0.xsd"
</beans>
I tried to :
change the version of the schema (3.2, 2.0...)
copy the schema from the jar into WEB-INF
change unix EOL into windows EOL
and nothing seems to work, except using the DTD declaretion instead of the XSD.
What should I do?
Spring is having trouble finding the xsds. Take a look at this SO post. If you are sure you have the required spring-beans jar in your classpath, you may have a corrupted META-INF/spring.schemas file. The spring.schemas file tells spring which classpath to use to find the corresponding xsd file in the spring jars. I have had this occur when using the maven-shade plugin improperly configured.
The xsd came down fine for me when I pasted it in the browser.
This one works fine for me:
<?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: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/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:annotation-config/>
<context:component-scan base-package="example"/>
</beans>
Here is the context for Spring Batch:
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:b="http://www.springframework.org/schema/batch"
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-2.5.xsd
http://www.springframework.org/schema/batch
http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
<b:job id="bar" job-repository="my-job-repository">
<b:step id="foo">
<b:tasklet transaction-manager="my-transaction-manager">
<b:chunk reader="itemReader" writer="itemWriter"/>
<b:tasklet>
</b:step>
</b:job>
</beans:beans>
This is what Spring Batch says:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found
starting with element 'b:tasklet'. One of
'{"http://www.springframework.org/schema/batch":transaction-attributes,
"http://www.springframework.org/schema/batch":no-rollback-exception-classes,
"http://www.springframework.org/schema/batch":listeners,
"http://www.springframework.org/schema/beans":bean,
"http://www.springframework.org/schema/beans":ref}' is expected.
What's wrong with my XML?
ps. I'm using org.springframework.batch:spring-batch-core:2.1.7.RELEASE
You forgot to close the tasklet tag. probably copied from here and replicated the mistake