简体   繁体   English

无法从jar文件(M子)访问xsl文件

[英]Unable to access xsl file from jar file (Mule)

I have been facing trouble accessing an xsl file located inside a folder in jar file. 我在访问位于jar文件中的文件夹内的xsl文件时遇到了麻烦。 I need to get this working in mule-config file. 我需要让它在mule-config文件中工作。

As given below I need to access an XSL file from a filder inside a jar file from an xslt transformer. 如下所示,我需要从xslt转换器的jar文件中的filder中访问XSL文件。 But it gives out error IOException 但它给出了错误IOException

<mule-xml:xslt-transformer name="rateConverter"     
    xsl-file="classpath:\xslt\ratechanger.xsl">
</mule-xml:xslt-transformer>

the jar structure is 

ccyutil.jar
  |_ xslt
    |_ ratechanger.xsl

Error while starting the application is : 启动应用程序时出错是:

Root Exception stack trace:
java.io.IOException: Unable to load resource classpath:\xslt\ratechanger.xsl
    at org.mule.util.IOUtils.getResourceAsString(IOUtils.java:54)
    at org.mule.module.xml.transformer.XsltTransformer.initialise(XsltTransformer.java:135)
    at org.mule.routing.AbstractSelectiveRouter.initialise(AbstractSelectiveRouter.java:94)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

2013-05-01 11:23:19,489 ERROR [main] mule.MuleServer (MuleServer.java:474) - 
********************************************************************************
* A Fatal error has occurred while the server was running:                     *
* Unable to load resource classpath:\xslt\ratechanger.xsl             *
* (java.io.IOException)                                                        *
*                                                                              *
* The error is fatal, the system will shutdown                                 *

It works fine if the xsl file is available in the jar directly instead of a folder. 如果xsl文件直接在jar中而不是在文件夹中可用,则效果很好。

  ccyutil.jar
  |_ ratechanger.xsl

Note: This is not a duplicate question related to accessing files form jar files. 注意:这不是与从jar文件访问文件有关的重复问题。 I have gone through most of the existing questions but couldn't find a solution. 我已经解决了大多数现有的问题,但找不到解决方案。

Use it the following way. 按以下方式使用它。 Its working. 它的工作。

  <mule-xml:xslt-transformer name="rateConverter"     
          xsl-file="xslt/ratechanger.xsl">
  </mule-xml:xslt-transformer>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM