You are not logged in.

Unanswered posts



Important! This site has been replaced. All content here is read-only. Please visit our brand-new community at https://community.talend.com/. We look forward to hearing from you there!



#1 2017-03-17 21:41:06

email3888
Member
11 posts

email3888 said:

Configuration problem: Unable to locate Spring NamespaceHandler for XM

After I added the code in bold at the Spring, I got the above error.
<?xml version="1.0" encoding="UTF-8"?>
<!--Used to inject external resources, beans or define more CamelContext and RouteBuilder here-->
<beans xmlns=""
       xmlns:xsi=""
       xmlns:camel=""
       xmlns:context=""
       xmlns:osgi=""
       xsi:schemaLocation="
           
           
         
            ">

    <bean id="jmxEventNotifier" class="org.apache.camel.management.JmxNotificationEventNotifier" >
        <property name="source" value="DemoDatasource" />
        <property name="ignoreCamelContextEvents" value="true" />
        <property name="ignoreRouteEvents" value="true" />
        <property name="ignoreServiceEvents" value="true" />
        <property name="ignoreExchangeEvents" value="true" />
    </bean>
    <osgi:reference id="demoDS" interface="javax.sql.DataSource" filter="(osgi.jndi.service.name=jdb-TRNG)"/>
</beans>

Anyone have any idea how to fix it?

Thanks,
email3888

Offline

#2 2017-03-18 04:04:31

xldai
Talend Team


xldai said:

Re: Configuration problem: Unable to locate Spring NamespaceHandler for XM

Hi,

The namespace handler for Spring-DM is defined in the spring-osgi-core/1.2.1 jar, it could not be loaded automatically when you add osgi:reference into the Spring xml in the Studio, that's why you got the "Unable to locate Spring NamespaceHandler ...".

If you want to reference a DataSource using Spring-DM, you have to export/publish the Route into Talend Runtime (OSGi container), the Runtime container has the spring-osgi-core/1.2.1 and its dependences pre-installed. also you need to deploy the DataSource "demoDS" before deploy the Route.

(you may add a cConfig component and add spring-osgi-core-1.2.1.jar into it from Studio to solve the "Unable to locate Spring NamespaceHandler ...", but it's not the expected way for Spring-DM use case)

Regards.

Offline

#3 2017-03-18 16:35:21

email3888
Member
11 posts

email3888 said:

Re: Configuration problem: Unable to locate Spring NamespaceHandler for XM

Thanks xldai! I added the cConfig and passed thru that error. I got another error. Is it related to the version of the jar?
Unexpected exception parsing XML document from class path resource [META-INF/spring/demodatasource.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.osgi.config.OsgiNamespaceHandler] for namespace []: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/osgi/framework/ServiceReference
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [META-INF/spring/demodatasource.xml]; nested exception is org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.osgi.config.OsgiNamespaceHandler] for namespace []: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/osgi/framework/ServiceReference
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:413)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:335)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:303)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:243)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:127)
    at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:93)
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:539)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at demo_project.demodatasource_0_1.DemoDatasource$2.createContext(DemoDatasource.java:204)
    at org.apache.camel.main.Main.getCamelContextMap(Main.java:148)
    at org.apache.camel.main.MainSupport.postProcessContext(MainSupport.java:386)
    at org.apache.camel.main.Main.doStart(Main.java:124)
    at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
    at org.apache.camel.main.MainSupport.run(MainSupport.java:124)
    at demo_project.demodatasource_0_1.DemoDatasource.run(DemoDatasource.java:270)
    at demo_project.demodatasource_0_1.DemoDatasource.runJobInTOS(DemoDatasource.java:332)
    at demo_project.demodatasource_0_1.DemoDatasource.main(DemoDatasource.java:302)
Caused by: org.springframework.beans.FatalBeanException: Invalid NamespaceHandler class [org.springframework.osgi.config.OsgiNamespaceHandler] for namespace []: problem with handler class file or dependent class; nested exception is java.lang.NoClassDefFoundError: org/osgi/framework/ServiceReference
    at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:139)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1427)
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1422)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:187)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:147)
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:101)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:495)
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:391)
    ... 22 more
Caused by: java.lang.NoClassDefFoundError: org/osgi/framework/ServiceReference
    at org.springframework.osgi.config.CollectionBeanDefinitionParser.<clinit>(CollectionBeanDefinitionParser.java:78)
    at org.springframework.osgi.config.OsgiNamespaceHandler.init(OsgiNamespaceHandler.java:40)
    at org.springframework.beans.factory.xml.DefaultNamespaceHandlerResolver.resolve(DefaultNamespaceHandlerResolver.java:130)
    ... 29 more
Caused by: java.lang.ClassNotFoundException: org.osgi.framework.ServiceReference
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 32 more

Offline

#4 2017-03-21 18:03:46

email3888
Member
11 posts

email3888 said:

Re: Configuration problem: Unable to locate Spring NamespaceHandler for XM

Hi xldai,
I added more jars in cConfig as in the screenshot. My current error is 
Error creating bean with name 'trngDS': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Required 'bundleContext' property was not set. Can you help me to solve it?



Thanks in advanced!
email3888
mini_blob_20170321-1005.png

Last edited by email3888 (2017-03-21 18:05:39)

Offline

#5 2017-03-22 08:02:24

xldai
Talend Team


xldai said:

Re: Configuration problem: Unable to locate Spring NamespaceHandler for XM

Hi

Well, are you expected running the Route within Studio? What I suggested is based on the DataSource is deployed in Runtime, also the Route is running in the Runtime container.

I've never tried the Route + DataSource running in Studio, if you want to try you don't need to introduce the osgi:reference , you can define the DataSource bean in the same spring.

Regards.

Offline

#6 2017-03-22 17:26:59

email3888
Member
11 posts

email3888 said:

Re: Configuration problem: Unable to locate Spring NamespaceHandler for XM

Hi xldai,
I am not expected to run in Studio, but at least there is no compilation error. I think there will be runtime error (at least for the datasource)
I tried to deploy to Karaf. I got this error.
karaf@trun()> feature:install TestDatasource-feature
[Karaf local console user karaf] ERROR org.apache.karaf.shell.support.ShellUtil - Exception caught while executing command
org.osgi.service.resolver.ResolutionException: 
Unable to resolve root: missing requirement
 [root] osgi.identity; osgi.identity=TestDatasource-feature; type=karaf.feature; version="[0.1.0,0.1.0]"; filter:="(&(osgi.identity=TestDatasource-feature)(type=karaf.feature)(version>=0.1.0)(version<=0.1.0))" [caused by: Unable to resolve TestDatasource-feature/0.1.0:missing requirement [TestDatasource-feature/0.1.0] osgi.identity; osgi.identity=demo_project.TestDatasource; type=osgi.bundle; version="[0.1.0,0.1.0]"; resolution:=mandatory [caused by: Unable to resolve demo_project.TestDatasource/0.1.0: missing requirement [demo_project.TestDatasource/0.1.0] osgi.wiring.package; filter:="(osgi.wiring.package=org.osgi)"]]

Thanks very much for looking into it.
email3888

Offline

#7 2017-03-24 03:35:28

xldai
Talend Team


xldai said:

Re: Configuration problem: Unable to locate Spring NamespaceHandler for XM

Hi,

OK. if you expect running the Route in Runtime container, you need to "Build Route"/"Publish" it, that will be no any compilation error from Studio. the compilation error you mentioned only happening when you try to "Run" the route within Studio. So please remove the cConfig component or remove the spring-osgi-core, org.osgi.core lib from the cConfig then "Build Route"/"Publish" it.

We are not sure if Route + Datasource (your use case) is fully supported. as alternative suggestion, you may create a Job using tXXXConnection (e.g tMySQLConnection) and "Specify a data source alias", and invoke this Job using cTalendJob component in your Route.

Regards.

Offline

#8 2017-03-24 04:42:43

email3888
Member
11 posts

email3888 said:

Re: Configuration problem: Unable to locate Spring NamespaceHandler for XM

Hi xldai,
I removed the cConfig and export it to karaf. I still got the same error.
Unable to resolve root: missing requirement
Thanks for suggesting to use Job, instead of Route. But, our company has some Camel projects which want to migrate into Talend and we want to keep the technology. This is my proof of concept project. I was following the link below to do it. Can you tell me what is missing in karaf or the kar?


Thanks again!
email3888

Offline

#9 2017-03-24 19:38:14

email3888
Member
11 posts

email3888 said:

Re: Configuration problem: Unable to locate Spring NamespaceHandler for XM

I uploaded the simple project with 3 components. Can you see if it works on your system?

Thanks,
email3888
DemoDatasource.zip.zip

Offline

Board footer

Talend Contributor Agreement - Talend Website Privacy Policy