Unable to locate Spring NamespaceHandler for element 'flow' - spring

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

Related

Profiling for different environment Spring MVC

I'm working on a maven Spring project, and I'm running Spring 3.0.7
in my .js file i use url for jquery ajax call like following
url : "/myProjectName/controllerName/MethodName"
In jdbc.properties file my userName & password is like following
jdbc.username=root
jdbc.password=
and some other like this. this is what i do when I work on my pc.
But before uploading my application, I have to change these as following
url : "/controllerName/MethodName"
jdbc.username=myName
jdbc.password=myPass
so what i am doing now is changing this every time manually before uploading my jar in the server.
Now I am wondering if there any way to do this so that I don't have to change this value manually every time before uploading it to the server. I read about profiling I dont know how to use it.
How to do this? Example code is highly appreciated.
You can add 'profile' attribute to your spring configuration file
Look 'Enter bean definition profiles' section at here
Use below code to set you spring profile, may be you can do this in your ServletContextListener
System.setProperty(AbstractEnvironment.DEFAULT_PROFILES_PROPERTY_NAME, [YOUR PROFILE]);
Load both 2 xml file below, only the file match the active profile will effect.
In develop.xml
<beans ... profile="develop">
... beans here will only be loaded while profile is 'develop'
</beans>
In server.xml
<beans ... profile="server">
... beans here will only be loaded while profile is 'server'
</beans>

spring integration jdbc init error

error info:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/integration/jdbc]
Offending resource: class path resource [META-INF/spring/applicationContext-integration.xml]
I have added xmlns and xsi:schemaLocation to the header of configuration file, it didn't show any error, but why excepiton occured when project startup?
anybody helps me...
It's interest, what was the problem to use search? At least on the StackOverflow
Your issue is about that spring-integration-jdbc.jar isn't presented in the CLASSPATH
Cheers

filter-name element is missing in generated web.xml

One of our old applications uses Struts-1.2 and EJB-2, generated with xdoclet 1.2.3. Maven 1 is used to build the application using java 1.4. The application has been running in weblogic 8.1 without any issues.
Now we are upgrading to Weblogic 10.3.6 which runs on java 6. When the application is deployed to Weblogic 10.3.6 we encounter the following error.
The error is weblogic.descriptor.DescriptorException: VALIDATION PROBLEMS WERE FOUND problem:
cvc-minLength-valid.1.1: string length (0) is less than minLength facet (1) for filter-nameType
in namespace http://java.sun.com/xml/ns/javaee:<null>
I understand this error is because the web.xml file is missing the filter-name element for a Filter class.
The problem is web.xml is generated by the application as part of the build process and I have no idea where or how to add the filter-name element value. What should I do to get the filter-name element to be added to the generated web.xml?
(Note: There is no problem when deployed to Weblogic8.1. This happens only when trying to deploy on weblogic10.3.6.)
Any help will be much appreciated.
Thanks.
Got it going.
I had to add the following annotation to the filter class...
#web.filter name="FilterClassName"
web.xml generated the filter-name element after I added the above annotation.

Normalizing Spring Resource for use with JUnit & war?

I'm probably thinking about this incorrectly, but here's what I'm up against:
I'm injecting Spring Resource objects into my app that give me the location of security certificates, for example:<property name="certificateResource" value="SomeCert.p12" /> where certificateResource is of type org.springframework.core.io.Resource
Running under JUnit the Resource is a classpath resource and everything is fine. When deployed as a war under Tomcat the the Resource is in a Servlet Context and requires WEB-INF/classes/ prepended to the certificate.
I've tried a number of Resource prefix and wildcard combinations but can't come-up with a single string that satisfies both contexts. So far the "solution" is to override the bean definition in src/test/resources/test-applicationContext.xml but that means maintaining the strings in two locations.
Any pointers to better solutions would be appreciated, thanks.
I have tried to make a small but descriptive application using spring-test and spring-webmvc and using resources referenced in xml configs while these xml's are reused by production and testing spring configurations. Here is what I recieved: github.com/isopov/spring-resource-test
The central is the referencing of the prodcution xml config from the testing config:
<import resource="file:src/main/webapp/WEB-INF/applicationContext.xml" />
it is also possible to not import one xml from the other, but give each test several configs:
#ContextConfiguration(locations = { "classpath:test-applicationContext.xml",
"file:src/main/webapp/WEB-INF/applicationContext.xml" })
the resource itself resides in src/main/resources (I assumed you are using Maven or something derived from the "Standard Directory Layout") so is always accessible with "classpath:hello.txt" from any spring config.
I tested this with maven build, as web-application and running UTs inside Eclipse.

Spring OSGi classpath resource issue

I'm trying to deploy a spring based bundle in osgi (fuse esb).In spring context, I'm referring to a db4o file which is inside resources folder. As per my understanding, a maven project will make sure that any file available under resources folder will be available in project classpath. I've kept the file under resources/META-INF/spring/repo/test.db4o.
Here's the entry in spring context.
<bean id="objectContainer" class="org.springmodules.db4o.ObjectContainerFactoryBean">
<property name="databaseFile" value="classpath:META-INF/spring/repo/test.db4o" />
</bean>
Once I install and try to start the application, I'm getting the following exception.
java.io.FileNotFoundException: OSGi resource[classpath:META-INF/spring/repo/test.db4o|bnd.id=258|bnd.sym=taxonomydaoimplbundle] cannot be resolved to absolute file path because it does not reside in the file system: bundle://258.0:1/META-INF/spring/repo/test.db4o
I've tried different combinations, but OSGi doesn't seem to recognize this file. Any pointer will be appreciated.
-Thanks
I found the issue finally. ObjectContainerFactoryBean is relying on OSGiResourceBundle to load the resource as a file object. Though OSGiResourceBundle exposes a method called getFile(), it doesn't work as intended in an OSGi environment. It always expects a file protocol whereas the resource returned as an URI has a protocol "bundle".Hence, the exception is being thrown. The workaround is to use a inputstream or getUrl. Since I didn't have the source code of ObjectContainerFactoryBean, I had to extend this class to provide my own implementation which loads the file as an inputstream.

Resources