Hi i am working on Spring Mediator in WSO2 ESB 4.6.0, using this and this tutorial
I am getting the Error as follows:
ERROR - SpringMediator Cannot look up Spring configuration conf/sample/resources/spring/springsample.xml
ERROR - SpringMediatorCannot reference application context with key : conf/sample/resources/spring/springsample.xml
Could you please explain me how to solve this.
when i send a message, the only error message i got is this one
so it means, the config file has been found. But what about the instanciation of the bean inside, i cannot see any explicit error. The jar file is in components/lib and i can see it also in dropins folder.
:/
These are the steps for spring mediator in brief as Isuru explained above
Create spring mediator library by extending AbstractMediator
Copy into ESB_HOME/repository/components/lib
Re-start the server
Register springtest.xml file in the Registry (http://madhukaudantha.blogspot.com/2012/07/wso2-esb-proxy-from-registry.html up to step 5 as Isuru explained)
Then, create a Custom proxy with Spring Mediator.
In there, add Bean as “springtest” (defined bean id for the mediator class within the xml file)
Select the Key as where the configuration registry file stored according to the 4th step.
Ex : If you have stored that springtest.xml file into path “_system/config/repository/”
Select Key as “/_system/config/repository/springtest.xml”
Note:
Verify in ESB_HOME/repository/components/dropins folder for OSGI bundle of the mediator of the created spring mediator library which is copied into ESB_HOME/repository/components/lib. If it is not there after restarting server, it may be a problem in created mediator library.
As well as, put unique package name for the mediator class to avoid conflicts with other mediator class in ESB_HOME/repository/components/lib.
Keep in mind to add unique bean id for the .xml file which is registered in the registry when you registered .xml file in 4th step.
This is because of the esb finds the
springsample.xml
file in the pathrepository/conf/sample/resources
But the
springsample.xml
file location is inrepository/samples/resources/
. Therefore it should be corrected as the following,In documentation, the configuration is not correct, If you start the esb by the command
wso2esb-samples -sn 470
(as mentioned in the documentation) the esb will load the file inrepository/samples/synapse_sample_470.xml
where in this file above parameter is correctly configured.Hope this will solve your problem :)
UPDATED:
According to your comment, as your are directly using sample spring example, this occur due to permission of the file trying to access, Or this can be due to file path error. So please try with absolute file url.
I got to work this as below,
The class should extends AbstractMediator and override the mediate() method as follows,
Then place the jar in [ESBHOME]/repository/components/lib folder
In mediate method it prints a message with the argument like
HELLO 'arg'
And I added the following file to registry
(/_system/config/repository/spring/springtest.xml)
,My proxy is as follows,
In the proxy you can see the
bean=[bean id of the springtest.xml]
andclass=qualified name of the class
In my ESB terminal, I got the following out put with the given property value in springtest.xml,
You must restart the ESB after placing the jar in repository/components/lib