Dean Hiller
Dean Hiller

Reputation: 20182

How to load Mule XML configuration

I was trying to follow this example

http://www.mulesoft.org/documentation/display/MULE3USER/Building+Web+Services+with+CXF

on a legacy project so then I create a main class with a main method that starts up spring like so(or I think this is how to do it)

    XmlBeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(
            "mule-config.xml"));

but the I then telnet into the port I have for my webservice and it doesn't work!!!

  1. IS it supposed to start it's own web container/server or do I need to deploy to tomcat or some app server to make this work
  2. If the answer to #1 is need to deploy, why is there an absolute url specified in their example like it will start one for you?

How to get this to work?

Here is my xml..

<flow name="helloService">
    <http:inbound-endpoint address="http://localhost:63081/enrollment" exchange-pattern="request-response">
        <cxf:jaxws-service serviceClass="com.ifp.esb.integration.ingest.EnrollmentWS"/>
    </http:inbound-endpoint>
    <component> 
        <spring-object bean="enrollmentBean" />  
    </component> 
</flow>

Upvotes: 2

Views: 2017

Answers (2)

jonfornari
jonfornari

Reputation: 520

You can use a webapp to start the mule context too. See that it is marked to load on startup.

Here's an example of a web.xml

<web-app
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd"
version="2.4">
<context-param>
    <param-name>org.mule.config</param-name>
    <param-value>
        mule-config.xml,
        mule-config2.xml,
            ...
        mule-config99.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>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>muleServlet</servlet-name>
    <url-pattern>/muleservlet/*</url-pattern>
</servlet-mapping>
</web-app>

Upvotes: 0

David Dossot
David Dossot

Reputation: 33413

You need to use the Mule-specific Spring config loader:

SpringXmlConfigurationBuilder builder = new SpringXmlConfigurationBuilder("mule-config.xml");
MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
MuleContext muleContext = muleContextFactory.createMuleContext(builder);
muleContext.start();

Upvotes: 5

Related Questions