cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jms:listener-container' - spring

I am getting following error while deploying my application to glassfish 3.1 server,
Exception while loading the app :
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 20 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'jms:listener-container'..
Please see server.log for more details.

Your question is a pain to read. When you want to get help, make some efforts to make yourself understood.
Your applicationContexnt.xml file probably miss JMS namespace declaration (see Spring JMS documentation).
From Spring documentation, your XML file header needs to be at least (pay attention to JMS part) :
<?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:jms="http://www.springframework.org/schema/jms"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-2.5.xsd">
<!-- <bean/> definitions here -->
</beans>
You may have others namespace declarations such as aop, util, context, etc.

Related

Importing beans from package in Spring - Unexpected exception parsing XML document

--- Not Important ---
Hi, this is my first question and I'm not really good at english, so I'm sorry if I don't explain myself well.
I'm currently starting to learn Java Web with Spring Framework from free online courses, but almost everytime I write the code that the teacher writes, I get exceptions and have to search the problem on Google, this time I got an error that I didn't find.
--- Important ---
I'm trying to automatically "import" beans from a package in order instead of "import" them manually (I write them with quotation marks because I don't know what is the word for that) but when I run the code I get this exception:
Unexpected exception parsing XML document from class path resource [beans.xml]; nested exception is java.lang.NoSuchMethodError: 'java.lang.String org.springframework.util.StringUtils.uncapitalizeAsProperty(java.lang.String)
And this is my beans.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"
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
https://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.principal"/>
</beans>
I don't have any idea what's going on, so I hope you guys can help me, thanks in advance, you're awesome c:

What are the possible causes of Duplicate bean name in Spring 5.3.18 other than two beans with the same name/id?

I'm receiving this error after building my war and deploying it to a tomcat server:
Error creating bean with name 'dwrController': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Duplicate name found. See logs for details.
However, this code inside my servlet.xml is the only place in the application where "dwrController" is named. There is no duplicate bean anywhere.
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.directwebremoting.org/schema/spring-dwr http://www.directwebremoting.org/schema/spring-dwr-3.0.xsd">
<dwr:controller id="dwrController" debug="true" />
</beans:beans>
I'm pretty new to spring, so I'm not entirely sure of what is going on under the hood (since assumingly somehow a second bean of the same name is being created without code on startup) and what the possible causes of this might be, which makes it difficult to debug.

Error in spring xsd

I am creating a apache-camel spring dsl application.
In the camel-config.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring"
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://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
This is showing error
Multiple annotations found at this line:
- Referenced file contains errors (http://www.springframework.org/schema/beans/spring-beans.xsd). For more information, right click on the message
in the Problems View and select "Show Details..."
- Start tag of element
on show details
s4s-elt-character: Non-whitespace characters are not allowed in schema elements other than 'xs:appinfo' and 'xs:documentation'. Saw 'Error'.
Do you have more than just this piece of xml, I bet your error is in some invalid xml you have typed yourself. There is plenty of Spring + Camel XML examples out there you can take look at, that works, for example:
https://github.com/camelinaction/camelinaction/blob/master/chapter2/spring/src/main/resources/META-INF/spring/camel-context.xml

Difference between Spring DOCTYPE and <beans> tag

In Spring there is a XML configuration for bean right?
What is the difference between:
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
and
<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">
Also i'm a bit curious with the difference between SpringMVC, MVC and just Spring
Difference is in formats of documents definitions. First is called DTD, second - XSD. Both are used to describe possible contents of xml document. DTD is older than XSD. XSD is more flexible and powerful than DTD. More differences you can see here.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<!-- bean definitions here -->
</beans>
The equivalent file in the XML Schema-style would be…​
<?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 definitions here -->
</beans>
The above Spring XML configuration fragment is boilerplate that you can copy and paste (!) and then plug definitions into like you have always done.
Differences between an XML Schema Definition (XSD) and Document Type Definition (DTD) include: XML schemas are written in XML while DTD are derived from SGML syntax. XML schemas define datatypes for elements and attributes while DTD doesn't support datatypes. ... XML schemas are extensible while DTD is not extensible.

Using spring together with jbossws-cxf on jboss 6

I want to use spring together with jbossws-cxf. Is this possible?
First I tried using jbossws-cxf.xml with bean definitions of spring. The warning message [DescriptorDeploymentAspect] Spring not available, skipping check for user provided jbossws-cxf.xml / cxf.xml configuration files. states that the file gets ignored and means that you should install spring in order for it to not get ignored :-) . So I installed spring for jboss..
After installation and running of a simple MathWS together with a simple WS example I get a
[org.jboss.wsf.stack.cxf.client.configuration.JBossWSSpringBusFactory] INITIAL_APP_CONTEXT_CREATION_FAILED_MSG: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.apache.cxf.binding.soap.customEditorConfigurer' defined in URL [vfs:/D:/lifeDevSuite/jboss/jboss-6.0.0.FinalSpring/common/lib/cxf-rt-bindings-soap.jar/META-INF/cxf/cxf-extension-soap.fixml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'java.util.ArrayList' to required type 'org.springframework.beans.PropertyEditorRegistrar[]' for property 'propertyEditorRegistrars'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.apache.cxf.binding.soap.spring.SoapVersionRegistrar] to required type [org.springframework.beans.PropertyEditorRegistrar] for property 'propertyEditorRegistrars[0]': no matching editors or conversion strategy found
error.
My jbossws-cxf.xml looks like this:
`
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
<bean id="mathBean" class="com.sample.MathWS">
<constructor-arg value="alabama" />
</bean>
<jaxws:endpoint id="MathWSX" implementor="#mathBean" address="http://localhost:8080/HelloCXF" />
`
I solved the problem. Sadly - I cannot recall how. And please forgive me - but I'm not going back to try and reproduce it :-)
Basically the answer is "yes". To that specific problem, it may have been a namespace problem, e.g. correct would be
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:util="http://www.springframework.org/schema/util"
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-2.5.xsd
http://cxf.apache.org/jaxws
http://cxf.apache.org/schemas/jaxws.xsd">
It may have been as well that custom spring libraries were deployed (I think it is recommended using the spring libraries coming with jboss and are deployed dynamically automagically)
It may have been something else alltogether

Resources