将Mule项目转换为Web应用程序时,在Mule Ajax连接器中使用的app.home无法正常工作 [英] app.home used in mule ajax connector is not working when mule project is converted to web application
问题描述
在m子中,当我使用web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID">
<!--Mule configuration (Mule format)-->
<context-param>
<param-name>org.mule.config</param-name>
<param-value>flight-config.xml</param-value>
</context-param>
<listener>
<listener-class>
org.mule.config.builders.MuleXmlBuilderContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>muleServlet</servlet-name>
<servlet-class>org.mule.transport.servlet.MuleReceiverServlet</servlet-class>
<load-on-startup>100</load-on-startup>
</servlet>
<!--Mule configuration ends-->
</web-app>
在m子应用程序中
<ajax:connector name="ajaxServer" serverUrl="http://0.0.0.0:9092/reservation" resourceBase="${app.home}/docroot" doc:name="Ajax"/>
以上连接器正常工作,但在Web应用程序中显示错误
The above connector was working but in web application it is showing error
HTTP ERROR 404
Problem accessing /reservation/. Reason:
NOT_FOUND
--------------------------------------------------------------------------------
Powered by Jetty://
在WebContent中,我创建了一个文件夹docroot
,并在其中相应地创建了文件,我在Web应用程序中使用的连接器是
In WebContent, I have created a folder docroot
and created the files in it accordingly, the connector I am using in web application is
<ajax:connector name="ajaxServer" serverUrl="http://0.0.0.0:9092/reservation" resourceBase="/docroot" doc:name="Ajax"/>
但是这不起作用.造成此错误的原因是什么?
but this is not working. What could be the cause of this error?
推荐答案
我是通过以下方式完成的:
I have done it in this way:
添加了一个扩展MuleXmlBuilderContextListener的ContextListener来执行以下操作
Added a ContextListener extending MuleXmlBuilderContextListener that does the following
ServletContext context = event.getServletContext();
System.setProperty("rootPath", context.getRealPath("/"));
initialize(context);
并使用了以下rootPath:
and used this rootPath like this:
<ajax:connector name="ajaxServer" serverUrl="http://0.0.0.0:9092/reservation" resourceBase="${rootPath}WEB-INF/docroot" doc:name="Ajax"/>
现在该应用程序正在运行.
now the application is working.
这篇关于将Mule项目转换为Web应用程序时,在Mule Ajax连接器中使用的app.home无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!