views:

389

answers:

2

I'm currently using JerseyTest w/ Grizzly embedded server to test some code. I do some very simple configuration to point it to the proper resources:

Map<String, String> initParams = new HashMap<String, String>();
initParams.put("com.sun.jersey.config.property.packages", "com.sample.service");
ApplicationDescriptor appDescriptor = new ApplicationDescriptor();
appDescriptor.setServletInitParams(initParams);
super.setupTestEnvironment(appDescriptor);

This works fine and the Jersey components are available and working as expected.

I'm now trying to add some Mule functionality to some of these Jersey calls, but Mule is not being properly initialized/configured by Grizzly. Has anyone gotten this kind of setup running? What additional configuration do I need to do with JerseyTest/GrizzlyWebServer to get it to initialize Mule properly?

A: 

While it is not ideal because the mule instance is not able to use Grizzly by default, I was able to get this working by staring up mule separately with:

    DefaultMuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
    SpringXmlConfigurationBuilder configBuilder = new SpringXmlConfigurationBuilder("mule-config.xml");
    muleContext = muleContextFactory.createMuleContext(configBuilder);
    muleContext.start();
Tim
A: 

I'm not sure what you're trying to achieve but you can use the Mule Jersey connector. Mule will handle the HTTP requests (instead of Grizzly) and you'll keep the Jersey processing as is.

<service name="helloWorldResource">
         <inbound>
            <inbound-endpoint address="jersey:http://localhost:63081/" synchronous="true"/>
         </inbound>
<component class="org.mule.transport.jersey.HelloWorldResource"/>
</service>

http://www.mulesoft.org/display/JERSEY/User's+Guide

dmossakowski