dimanche 29 mars 2015

Spring cannot find spring.schemas and spring.handlers in camel-spring-2.15.0.jar

I understand that similar questions have been asked and answered, however apparently the solutions do not work for me.


Situation


I'm trying to employ apache camel in a Liferay portlet. I use Liferay 6.2, camel 2.15 and springframework 4.1.5 releases, and have put the dependency jar files under my portlet WEB-INF/lib folder.


Related spring xml:



<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="
http://ift.tt/GArMu6 http://ift.tt/1jdM0fG
http://ift.tt/TZ5qsO http://ift.tt/1apCv6i
">
<camelContext id="camel-apns-test" xmlns="http://ift.tt/TZ5qsO">

<template id="producer"/>

<route id="send-apns">
<from uri="seda:send-apns" />
<multicast>
<!-- <to uri="apns:notify" /> -->
<to uri="file:C:/Development/liferay-ws/temp?fileName=apns.log&amp;fileExist=Append" />
</multicast>
</route>

<route id="receive-apns">
<from uri="apns:consumer?initialDelay=10&amp;delay=3600&amp;timeUnit=SECONDS" />
<to uri="log:org.apache.camel.component.apns?showAll=true&amp;multiline=true" />
<to uri="mock:result" />
</route>
</camelContext>


Problem



  1. On a computer without internet access, when the portlet was being deployed, system was stuck for a short while and then threw following error:


org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'camelContext'.


Apparently system could not find the xsd file inside camel-spring-2.15.0.jar and was trying to download from internet but failed.



  1. After I enabled the internet access on the computer, system threw followign exception:


Context initialization failed org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://ift.tt/TZ5qsO]


Then I realised that spring just could not load the spring.schemas and spring.handlers in camel-spring-2.15.0.jar\META-INF folder.


What I have tried




  1. I tried putting the spring.schemas and spring.handlers inside camel-spring-2.15.0.jar into my portlet META-INF folder, still got "unable to locate spring namespace handler" error.




  2. I tried adding those jar names under WEB-INF/lib folder to META-INF/MANIFEST.MF Classpath entry, still got the error.




  3. I tried creating a normal servlet web application, with exact same jar files and spring XML, and deployed the web app to Tomcat 7.0, it works fine without errors.




Understand Liferay does some special handling to the classloading (refer to http://ift.tt/19kA0Ih). Not sure if this is a side affect caused.


Any idea how to resolve this issue or provide a workaround so that the camel's schema & handler mapping can be read by spring? Thanks!


Aucun commentaire:

Enregistrer un commentaire