OC4J 10.1.3.5 / Spring3 Issue - spring

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!

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 schema folder & Spring XML namespaces

I am looking for how we should determine the symbol of a namespace in Spring bean XML definitions. I guess they are in the Spring schema folder, but I can't find it. For example, what are c:, p:, util:, .. in the XML bean configuration?
Where can I find the schema's for each namespace? For example, how do I know if I should use http://www.springframework.org/schema/p in xmlns:p="http://www.springframework.org/schema/p", where are the other namespaces and how can I find them?
You can choose the symbol (p, util, jee, beans, ...) by yourself. These are namespaces, and they work by adding the xmlns attribute like:
<beans xmlns:util="http://www.springframework.org/schema/util">
<!-- Content -->
</beans>
In this case we said that util: will be used by the util schema, so you'll have to use <util:properties> to access things from this namespace. But you could also have said xmlns:foobar="http://www.springframework.org/schema/util" in which case you could have used things like <foobar:properties>.
But you also need to provide the location of the XSD of that namespace by using xsi:schemaLocation:
<beans xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<!-- Content -->
</beans>
In this case the XSD for http://www.springframework.org/schema/util is available at http://www.springframework.org/schema/util/spring-util.xsd. The http://www.springframework.org/schema/util part is just a label and can be chosen as well. The only thing that has to match is the XSD schema.
For more information about XML namespaces, you should look at this question and its answers.
A list of common XML schema's with Spring can be found in their documentation (33. XML Schema-based configuration). However, these only list the core schemas. Some projects (like Spring Web Services, ...) have their own namespaces like:
http://www.springframework.org/schema/web-services/web-services.xsd
http://www.springframework.org/schema/oxm/spring-oxm.xsd
...
You can find the entire list by visiting the Index of /schema. However, like I mentioned, most of these are only used for specific Spring projects, don't just import them, read the specific documentation to find out what you need. The documentation about the constructor namespace (c:) can be found in 7. The IoC container.

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...

Unable to locate Spring NamespaceHandler for element 'flow'

I am developing a spring webflow (2.0.7) project using SpringSource Tool Suite. I am trying to setup a basic flow.
My someflow.xml looks like this:
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<!- view-state declarations -->
</flow>
On STS tool(Spring IDE on eclipse), I see a warning message near the flow schemaLocation:
Unable to locate Spring NamespaceHandler for element 'flow' of schema namespace 'http://
www.springframework.org/schema/webflow'
Then when tomcat starts up, I get the error
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/webflow]
Offending resource: ServletContext resource [/WEB-INF/flows/someflow.xml]
I googled a while and some posts suggested that the problem is spring-webflow jars not being in class path. In my case, springsource tool created the template and all jars are in place. I manually checked them as well. So that can't be the issue
One of the suggestions in this post http://forum.springsource.org/archive/index.php/t-49098.html was to splice the jar! That can't be a solution, but I tried to see if it fixes it. But no.
Stuck now.. Did anyone else face this issue?
I've had similar issues before and it usually boiled down to the jar missing from the built war. Can you open up the war you are using and check that the webflow jar is in the /WEB-INF/lib directory?
If you are using Maven to do your builds, check your dependency settings for webflow as well.
if you are using eclipse,please provide the appresource path name,right click on your test case select Run as --> Run Configurations --> click on the Classpath tab and copy the below line and give the full path name of your property file location.
appResourcePath = ../../environment-dev.properties).

Resources