0

我的 dataweave 代码配置 xml 如下:

<dw:transform-message doc:name="Transform Message">
    <dw:set-payload  resource="#[flowVars['sample']]" />
 </dw:transform-message>

其中 sample 是一个流变量,其中包含具有实际转换逻辑的 .dwl 文件的文件路径。

<set-variable doc:name="Variable" value="file:D:/Transformer/sample.dwl" variableName="sample"/>

我在部署应用程序时看到的错误如下:

org.mule.module.launcher.DeploymentInitException: FileNotFoundException: class path resource [#[flowVars['sample']]] cannot be opened because it does not exist
at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:197) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.artifact.ArtifactWrapper$2.execute(ArtifactWrapper.java:62) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.artifact.ArtifactWrapper.executeWithinArtifactClassLoader(ArtifactWrapper.java:129) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.artifact.ArtifactWrapper.init(ArtifactWrapper.java:57) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:25) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.guardedDeploy(DefaultArchiveDeployer.java:324) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.deployArtifact(DefaultArchiveDeployer.java:345) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:163) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:268) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DefaultArchiveDeployer.deployPackagedArtifact(DefaultArchiveDeployer.java:83) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DeploymentDirectoryWatcher.deployPackedApps(DeploymentDirectoryWatcher.java:275) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.DeploymentDirectoryWatcher.start(DeploymentDirectoryWatcher.java:150) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.MuleDeploymentService.start(MuleDeploymentService.java:104) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.module.launcher.MuleContainer.start(MuleContainer.java:170) ~[mule-module-launcher-3.7.3.jar:3.7.3]
at org.mule.tooling.server.application.ApplicationDeployer.main(ApplicationDeployer.java:15) ~[tooling-support-3.7.3.jar:?]
Caused by: org.mule.api.config.ConfigurationException: IOException parsing XML document from URL [file:/C:/Users/Satyakeerthika_Ch/AnypointStudio/workspaceLatest/.mule/apps/sample/sample.xml]; nested exception is java.io.FileNotFoundException: class path resource [#[flowVars['sample']]] cannot be opened because it does not exist (org.mule.api.lifecycle.InitialisationException) (org.mule.api.config.ConfigurationException)
at org.mule.config.builders.AbstractConfigurationBuilder.configure(AbstractConfigurationBuilder.java:49) ~[mule-core-3.7.3.jar:3.7.3]
at org.mule.config.builders.AbstractResourceConfigurationBuilder.configure(AbstractResourceConfigurationBuilder.java:69) ~[mule-core-3.7.3.jar:3.7.3]
at org.mule.context.DefaultMuleContextFactory$1.configure(DefaultMuleContextFactory.java:89) ~[mule-core-3.7.3.jar:3.7.3]
at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:222) ~[mule-core-3.7.3.jar:3.7.3]
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:81) ~[mule-core-3.7.3.jar:3.7.3]
at org.mule.module.launcher.application.DefaultMuleApplication.init(DefaultMuleApplication.java:188) ~[mule-module-launcher-3.7.3.jar:3.7.3]
... 14 more

有人可以帮我如何读取资源中的变量吗?

4

2 回答 2

0

您不能那样做,但是您可以使用 MEL 函数来评估 set-payload 中的 dataweave 脚本。

#[dw(<dw-script-string>)]
#[dw(<dw-script-string>, <out-content-type>)]

如果您不指定内容类型,则默认为 java。

所以,它最终会变成:

<set-payload value="#[dw(<dw-script-string>)]" doc:name="Set Payload"/>

链接到文档

于 2016-01-06T13:17:41.453 回答
0

我在使用 Mule 3.9.0 的 anypoint 工作室中也遇到了同样的问题,我必须使用以下指南更正我的 anypoint 工作室中的 java 库。

  1. 右键单击项目
  2. 从上下文菜单中选择属性
  3. 在项目属性页面上选择 java 构建路径
  4. 在java构建路径中单击库
  5. 选择 Add Library -> 点击 JRE System Library
  6. 选择备用 JRE 并浏览到要添加到项目中的 JDK

这应该可以解决您的问题

于 2019-10-10T08:56:43.817 回答