starting a spring 3.0 application - spring

i stated a new spring project in the STS
add a new spring configuration (it generate it automatically):
<?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">
</beans>
and i get the next error message from the STS:
Error occured processing XML 'null'. See Error Log for more details
what am i doing wrong?

Its a STS bug. Take a look at
STS-2180 Status : open Resolution : Unresolved
Edit
Adi Mor Found a solution from the spring forum : need to disable the Cache in the eclipse:
Window -> Preferences -> General -> Network Connections -> Cache -> Disable caching

Related

Apache CXF SOAP JAXB issue on WebLogic 12c

We are using Java 8, Apache CXF as a SOAP client on top of Spring Boot to send SOAP messages to WS.
If the app is deployed as a WAR on Tomcat 8, the app works well and the SOAP client is sending the right XML messages with the right namespaces.
If the same app WAR is deployed on Weblogic 12c the SOAP message that is produced by the CXF SOAP client has missing namespaces.
We know that the WebLogic maybe uses some old JAXB jars that are responsible for creating the XML message from Java objects and they are different then the Tomcat server and this maybe the reason why we are seeing this issue.
We also know that we can specify in the weblogic.xml in the war file what jars the Weblogic needs to load from the war and what dependencies to load from directly from the Weblogic libraries, but every combination that we tried in the weblogic.xml does not work.
Any good advice will be fully appreciated
Sample XML output from Tomcat server with Apache CXF
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<event xmlns="http://www.test.com" xmlns:ns5="http://www.test2.com" xmlns:ns3="urn:test1:1423.15465:123123:namespace">
<ns5:created-date-time>2020-08-12T08:02:35Z</ns5:created-date-time>
<ns5:payload>
<Test2>
<ns3:ID>f14bb</ns3:ID>
<ns3:createdDateTime>2020-08-12T08:02:35Z</ns3:createdDateTime>
</Test2>
</ns5:payload>
</event>
</env:Body>
</env:Envelope>
Sample code from Weblogic 12c
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<event xmlns="http://www.test.com" xmlns:ns5="http://www.test2.com">
<ns5:created-date-time>2020-08-12T08:02:35Z</ns5:created-date-time>
<ns5:payload>
<Test2>
<ID>f14bb</ID>
<createdDateTime>2020-08-12T08:02:35Z</createdDateTime>
</Test2>
</ns5:payload>
</event>
</env:Body>
</env:Envelope>
The "urn:test1:1423.15465:123123:namespace" is completely ignored in the weblogic server making this XML message not valid by the consumer
weblogic.xml
we are trying to tell weblogic to load our classes from the war file instead of the JaxB classes from the web logic but without success
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>java.xml.bind.*</wls:package-name>
<wls:package-name>org.apache.cxf.*</wls:package-name>
<wls:package-name>javax.xml.ws.*</wls:package-name>
<wls:package-name>javax.wsdl.*</wls:package-name>
</wls:prefer-application-resources>
</wls:container-descriptor>
Except this issue everything else is working fine, the Apache CXF is sending correct in multiple scenarios, just in one is it not adding the namespace we need
It looks like you are describing a class loading problem here. Thus, kindly use the below tag in your weblogic.xml descriptor.
<prefer-web-inf-classes>false</prefer-web-inf-classes>
Some years ago I was struggling with class loading issues because I was missing it. Below you have an example about this extracted from this blog.
If after applying this you still are facing issues with the class loader, you should install Classloader Analysis Tool (CAT) to get the class loader, which is loading the conflicting classes. In this blog you will have some instructions about how to use CAT.
Importantly, in this document Oracle states about this
Note that in order to use prefer-application-packages or prefer-application-resources, prefer-web-inf-classes must be set to false.
This issue was solved by updating the package-info.java
#javax.xml.bind.annotation.XmlSchema(namespace = "urn:test1",
xmlns = {#XmlNs(prefix = "",
namespaceURI = "http://www.test.com")},
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
This is the part of the package-info that was not been there before
xmlns = {#XmlNs(prefix = "",
namespaceURI = "http://www.test.com")}
adding the namespace trick JavaXB to add the original namespace
Please check the mentioned page, which has a different Filtering classloading:
<wls:prefer-application-packages>
<wls:package-name>com.ctc.wstx.*</wls:package-name>
<wls:package-name>javax.wsdl.*</wls:package-name>
<wls:package-name>org.apache.cxf.*</wls:package-name>
<!-- <wls:package-name>javax.jws.*</wls:package-name> -->
</wls:prefer-application-packages>

spring src-resolve issue "Cannot resolve the name ...''

I'm stuck with a standalone java application I'm maintaining, I'm really new with Maven. I use the copy dependencies, package plugins in command line and everything it's ok, but then when I see the project in eclipse, it validates the project and it seems that there is a problem checking which .xsd version should take into account.
Description Resource Path Location Type src-resolve: Cannot resolve
the name 'beans:identifiedType' to a(n) 'type definition'
component. spring-jee-2.0.xsd
Description Resource Path Location Type src-resolve: Cannot resolve
the name 'beans:identifiedType' to a(n) 'type definition'
component. spring-jee-2.5.xsd
I'm using spring 2.5.6 and I cannot upgrade. I do not know if I have to set up something in my eclipse IDE.
My configuration file is like this:
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd">
Any ideas or suggestions? Is it something related with a problem in the project or with eclipse IDE?
Thanks in advance
I cannot reproduce your situation, but it seems to be related to this problem:
That's a feature of STS (trying to be clever and importing XSD from
project classpath it fails to find the spring core ones). Raise a JIRA
ticket there if you want to really solve the problem, but my
understanding is that it is a compromise - users who do not edit
custom XSDs are far more numerous than those that do, so it's better
to support the larger group.
You can work around it by adding the spring-beans-3.1.xsd to your XML
Catalog in Eclipse (look in Preferences). You probably only need to
specify a namespace id, but I always add the schema location to be on
the safe side. You probably need to extract the XSD from the spring
jar file because I don't think you can add a catalog entry from a jar.
So, try to add spring-beans-2.5.xsd to XML Catalog in Eclipse. Hope this helps.

No declaration can be found for element 'context:component-scan'

i'm starting with Spring 3 (3.1.2) and Google App Engine.
I've followed a tutoria online, now, i've my bean-realted xml which has a problem while starting.
this is the code
<?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.xsd
http://www.springframework.org/schema/context/
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="my.example">
where the root package of all the java file is "my.example". The subpackage are "model" and "controller" with subpackages as well.
now.
when i start the app i receive back this error:
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 10 in XML document from ServletContext resource [/WEB-INF/spring-servlet.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 'context:component-scan'.
with a lot of more stacktrace.
does anyone know how i can solve this?
i checked the XSD and they seems to be correct.
You are probably missing spring-context.jar, that is the one which contains the definition for context schema.
I don't know if this helps any, but I had an error very similar to yours while using the maven shade plugin to make a single .jar, and the shade plugin wiped out the spring.handlers and spring.schemas from META-INF/.
This SO answer pointed me in the right direction: https://stackoverflow.com/a/3650844/7008
And the document on using an AppendingTransformer to add those spring bits back in to your META-INF/ folder did the trick for me: http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer
Problem is incompatible schema locations with your spring-context dependencies.
Replace
http://www.springframework.org/schema/context/spring-context.xsd
by
http://www.springframework.org/schema/context/spring-context-2.5.xsd
That should do the trick! I was using spring-context 3.1.1 and I was getting the same error referring to http://www.springframework.org/schema/context/spring-context-2.1.xsd
However, you should also do a maven tree dependendency and check if you've got different spring versions. This error could be due to this fact also...

WebLogic Portal & Spring Portlet MVC

I have integrated spring portlet MVC 3.0 into Weblogic Portal 10.3. However, when I tried to activate multi-thread options in portlet, the maximized and minimized windows of portlets didn't run properly.
All my portlets are JavaPortlet as the configuration as below:
<?xml version="1.0" encoding="UTF-8"?>
<portal:root xmlns:netuix="http://www.bea.com/servers/netuix/xsd/controls/netuix/1.0.0" xmlns:portal="http://www.bea.com/servers/netuix/xsd/portal/support/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/servers/netuix/xsd/portal/support/1.0.0 portal-support-1_0_0.xsd">
<netuix:javaPortlet definitionLabel="offshoreTechnology" offerRemote="false"
forkable="true" forkPreRender="true" forkRender="true"
portletName="offshoreTechnology" title="Offshore Technology">
</netuix:javaPortlet>
</portal:root>
The forkable="true" forkPreRender="true" forkRender="true" will activate the multi-threading portlet.
Does anyone have such problem?

OC4J 10.1.3.5 / Spring3 Issue

I'm using OC4J 10.1.3.5.0, and have an issue with the XML namespaces in the Spring XML files supplied in the WAR/EAR.
According to the Oracle documentation, there is a known issue in parsing the Spring 3 XSD files within OC4J, as this embeds the Oracle XMLParserV2 jar and uses this for all XML parsing (which has issues with some XSD tricks used in Spring 3 apparently).
I've folowed the Oracle work-around, defining my own XML parser shared libraries on the OC4J instance, and (in the orion-application.xml), defining the shared library to use. I created a shared library,'apache.xml', with xercesImpl (v 2.9.1), xml-apis (v 1.3.04), and xml-resolver (v 1.2). I tried defining the EAR to use the new library
<imported-shared-libraries>
<imported-shared-library name="apache.xml"/>
</imported-shared-libraries>
I receive the following error
14:50:31 ERROR (UserId:) [DispatcherServlet] Context initialization failed
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 10 in XML document from ServletContext resource [/WEB-INF/spring/webflow-config.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 'webflow:flow-executor'.
The webflow-config.xml file is defined as normal:
<?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:webflow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
<!-- Executes web flows -->
<webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry" />
<!-- Rest of the file ... -->
</beans>
Does anyone have any ideas?
[Edit]
The snippet:
<imported-shared-libraries>
<imported-shared-library name="apache.xml"/>
</imported-shared-libraries>
should, of course read:
<imported-shared-libraries>
<import-shared-library name="apache.xml"/>
</imported-shared-libraries>
Sorry!
I found the answer to this. Turns out this was specifically because I was running OC4J on a Java 6 JVM. If anyone else gets this problem, here's what we did to resolve:
The Oracle XML parser does not handle the Spring 3 XSD files well, this is a know issue. You need to remove the Oracle XSD libraries for your application. In your orion-application.xml file, you need
<imported-shared-libraries>
<remove-inherited name="oracle.xml"/>
</imported-shared-libraries>
The Oracle documentation then tells you to import a new shared library. However, if you're running OC4J on a Java 6 JVM (which we are!), you can't do this. It looks like there is an XML parser in the Java 6 core now, and importing Xerces libraries will conflict with these classes, causing weird errors.
Anyway, on Java 6, remove the Oracle libraries, but don't import any other ones!

Resources