In one package within the same project, I use #Autowired to grab an element from my appcontext.xml, and it works fine. A bean defined in that same appcontext, to then be #Autowired, is created successfully, but there is no attempt to inject the bean.
I feel as though I may be missing something relating to classpaths. For now, I've been trying to add <context:component-scan /> in my appcontext, but that only gives me this error:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan'.
part of my AppContext.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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context/spring-context-2.5.xsd"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<context:component-scan base-package="org.jasig.cas.web.flow"/>
With the beans defined further below it.
Any noticeable flaws, or is there some other configuration I should change?
Line xmlns:context="http://www.springframework.org/schema/context/spring-context-2.5.xsd"
should simply be xmlns:context="http://www.springframework.org/schema/context"
Related
I have the following spring-config xml file, which is generating the exception shown in the title of my post:
<?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:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-jpa="http://www.springframework.org/schema/integration/jpa"
xmlns:int-sftp="http://www.springframework.org/schema/integration/sftp"
xmlns:file="http://www.springframework.org/schema/integration/file"
xmlns:int-xml="http://www.springframework.org/schema/integration/xml"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/jpa
http://www.springframework.org/schema/integration/jpa/spring-integration-jpa.xsd
http://www.springframework.org/schema/integration/sftp
http://www.springframework.org/schema/integration/sftp/spring-integration-sftp.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schema/integration/file/spring-integration-file.xsd
http://www.springframework.org/schema/integration/xml
http://www.springframework.org/schema/integration/xml/spring-
integration-xml.xsd">
<int-jpa:inbound-channel-adapter
id="resultsProcessor"
channel="responseChannel"
auto-startup="true"
named-query="OpenRecords"
expect-single-result="true"
delete-after-poll="false"
entity-class="foo.Request">
<int:poller
id="responsePoller"
fixed-rate="5000"
max-messages-per-poll="10">
</int:poller>
</int-jpa:inbound-channel-adapter>
</beans>
The code I provide above has other elements removed from it, and some of the fields renamed to simplify the example. That is why you see some schema and namespace information at the top that does not apply to the example as presented.
The error actually takes place at the line corresponding to entity-class="foo.Request">, but I don't know that there is anything inherently wrong with that line, but simply that is where the termination ">" is. In other words, if I removed that line and put the ">" after delete-after-poll="false", the error would be there instead.
Am I perhaps missing a namespace and/or schema location definition? Alternatively, could it be a missing deployment dependency? Grateful for any ideas. Thank you.
Please add org.springframework.integration:spring-integration-jpa to your dependencies. You simply missing a jar in your classpath
I am having an issue with the xml schema for spring jpa repository.
I have tried all the suggestions available online but do not seem to resolve it.
please help.
getting this error in the application-context.xml for the repository.
Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'repository:repositories'.
- cvc-complex-type.2.4.a: Invalid content was found starting with element 'repositories'. One of '{"http://www.springframework.org/schema/
beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://
www.springframework.org/schema/beans"]}' is expected.
my application context looks like this
<?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"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:repository="http://www.springframework.org/schema/data/repository"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository-1.7.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<jdbc:embedded-database id="dataSource" type="H2" />
<tx:annotation-driven transaction-manager="transactionManager" />
<repositories base-package="com.company.repositories" />
<context:component-scan base-package="com.company.*" />
</beans>
We generally recommend to refer to the schema files that don't have version numbers in them as this will make sure you pick up the version form the dependency in your classpath.
The reason for this is that XSD doesn't know any kind of version concept. This means that spring-beans.xsd and spring-beans-3.0.xsd are completely unrelated to XSD which in turn means that if you happen to import both of them (I'll get to that in a second), this will create errors as XSD considers the types declared in them to be declared twice.
The reason you might accidentally import a non-versioned XSD is that the Spring Data XSDs actually refer to them to make sure we pick up the latest version (to be forward compatible).
Long story short: remove the explicit versions from the names and you should be good.
after a lot of trial and error the following application context doesn't seem to have any errors.
<?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"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
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/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/data/repository http://www.springframework.org/schema/data/repository/spring-repository-1.7.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<jdbc:embedded-database id="dataSource" type="H2" />
<tx:annotation-driven transaction-manager="transactionManager" />
<jpa:repositories base-package="com.company.repositories" />
<context:component-scan base-package="com.company.*" />
</beans>
It beyond me why it didn't resolve the errors when I tried it earlier.
I was getting the following error.
Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans-3.0.xsd).
I did the following, preferences > general > network connection > cache --> deleted the caches xsd.
Then I clicked on the problems view and deleted the problem and cleaned the project. Don't have the error now. Anybody who understands this better is welcome to answer.
We using spring 3.2.3 in a jsf-based web app. I'm tasked with implementing spring cache WITHOUT using annotations. here's my cache-context:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
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-3.1.xsd
http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
<cache:advice id="cacheProvider" cache-manager="cacheManager">
<cache:caching cache="findUsers">
<cache:cacheable method="findByUser" key="#userId"/>
<cache:cache-evict method="add" all-entries="true"/>
<cache:cache-evict method="delete" all-entries="true"/>
</cache:caching>
</cache:advice>
When tomcat 6 starts, I get this error: ...org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'cache:advice'.
I don't understand why, am I missing something in my pom or xml declaration? Please help
Try to change spring-beans.xsd from http://www.springframework.org/schema/beans/spring-beans.xsd to http://www.springframework.org/schema/beans/spring-beans-3.1.xsd.
If it doesn't help show all dependencies (including version) of your application.
I have an issued on my spring-ws-servlet.xml
when i start the ws i receive this error:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ws:interceptors'.
this is the line with error (spring-ws-servlet.xml):
<ws:interceptors><bean class="com.nin.fi.sw.schema.WSLoggingInterceptor"/></ws:interceptors>
And this is the header of these 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:context="http://www.springframework.org/schema/context"
xmlns:ws="http://www.springframework.org/schema/web-services"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-1.5.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
Libs:
I tried to attach differentes .xsd but withoud any success.
I dont know what im doing wrong.
You haven't added a schema location for web-services
http://www.springframework.org/schema/web-services
http://www.springframework.org/schema/web-services/web-services-2.0.xsd
i am using Spring 3.0.5.RELEASE
and today when building the project with maven, i am getting following errors in appicationContext.xml file:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element
'context:component-scan'.
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:annotation-
config'.
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'tx:annotation-
driven'.
i tried to open the schema links:
Spring XML Beans Schema
Spring Framework's declarative
transaction management infrastructure
Spring Framework's application
context support
but i always gets the page Forbidden !
here's how i am configuring the 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"
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/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/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
please advise how to fix this error.
seems that the public schemas are not available anymore, so i load the schemas from the jars on the classpath instead as follows:
<?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"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
classpath:/org/springframework/beans/factory/xml/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
classpath:/org/springframework/transaction/config/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
classpath:/org/springframework/context/config/spring-context-3.0.xsd">
Seems you are experiencing this problem: Spring Beans Schema no longer available on the Web? Are you defining schemaLocation explicitly?
<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"
xmlns:tx="http://www.springframework.org/schema/tx"
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/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/context/spring-context-3.0.xsd
">