How to make a deployable war file of a mule ESB application - mule

can somebody please help me how to make a war of a simple mule application.
My mule application consists of a single mule-config.xml file.
I have made this mule project in ecplise and can run it as a mule server.
My requirement is to make a war and deploy it in a tomcat or tcat server.
Thanks and Regards,
Arijit

As explained in the user guide:
To embed Mule inside a webapp, you provide one or more configuration file locations as context params and include a context listener to initialize the Mule Server.
So just add this in your web.xml, with mule-config.xml at the root of your classpath (for ex. in src/main/resources):
<context-param>
<param-name>org.mule.config</param-name>
<param-value>mule-config.xml</param-value>
</context-param>
<listener>
<listener-class>org.mule.config.builders.MuleXmlBuilderContextListener</listener-class>
</listener>
EDIT I've open-sourced a running demo: https://github.com/ddossot/mule-webapp-example

Related

Closed : Logback xml not picked by weblogic

We have externalized the logback configuration in our spring app.
Used logback spring ext
compile 'org.logback-extensions:logback-ext-spring:0.1.4'
Added following lines in web.xml
<context-param>
<param-name>logbackConfigLocation</param-name>
<param-value>file:/${log-config-folder}/api/logback.xml</param-value>
</context-param>
Placed logback.xml in the folder mentioned in web.xml
/usr/me/my-app/log-config
/api
/logback.xml
Added JVM argument in start up script of tomcat.
JAVA_OPTS="$JAVA_OPTS -Dlog-config-folder=usr/me/my-app/log-config"
When the app is deployed in tomcat, it works perfectly fine. We are able to see the logs. When logback xml gets updated, I can see changes reflecting immediately in the app (changing LOG LEVELs)
Problem: When this same configuration is moved to weblogic, its not picking up the logback xml from external folder. JVM argument is added to weblogic start up script. I can see the JVM argument getting set.
Weblogic team came back and told they have made the weblogic setting to prioritize application classes and config.
<prefer-web-inf-classes>true</prefer-web-inf-classes>
Any pointers to triaging this would be really helpful.

IBM Worklight - How to change dynamically domain/hostname to which the adapter connects from the client at launch or runtime?

When configuring WL HTTP Adapters, the domain and port are part of the adapter configuration .xml file build and uploaded on the WL server.
For our use case (especially beta testing and demos) the endpoint server url needs to be configurable for the end user. Example, same builds are tested by QA on test envs, while BA connects to demo.
We have only one WL Server up and setting environment specific servers is not an option.
Is it possible to change domain/hostname dynamically at application launch or runtime ? Ideally it would be to get and use the domain/hostname value from a drop down or free input from the client and use it.
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>{hostname}</domain>
<port>80</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
Update: This answer is useful, so I leave it here for reference, but accept that it doesn't correctly answer this question!
There is a specific Worklight feature designed to address your scenario (for the Infocenter detail, see here).
You can do this by using a combination of worklight.properties and JNDI properties.
For example, let's say you had this setup in your adapter XML:
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>${my.adapter.protocol}</protocol>
<domain>${my.adapter.domain}</domain>
<port>${my.adapter.port}</port>
</connectionPolicy>
<loadConstraints maxConcurrentConnectionsPerNode="2" />
</connectivity>
You then define default values for these in your worklight.properties file (in the server/conf directory of your Worklight project, and "burnt in" to the .WAR file when you build it):
my.adapter.protocol=http
my.adapter.domain=some.host.com
my.adapter.port=80
You can then override these values in individual environments, by setting JNDI properties. For example, if you are using WebSphere Liberty, you might put this in your server.xml:
<jndiEntry jndiName="my.adapter.protocol" value="https"/>
<jndiEntry jndiName="my.adapter.domain" value="some.other.host.com"/>
<jndiEntry jndiName="my.adapter.port" value="8080"/>
You could create 3 adapters: 2 adapters connect to each backend servers, and one "proxy" adapter.
Your application would call the proxy adapter, passing some variable (the dropdown). Then the proxy would call one of the 2 real adapters.
You canĀ“t. An option is to use MashUps.
See:
IBM Worklight 6.1 - Can a HTTP adapter call another HTTP adapter on server-side?
http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v620/04_11_Advanced_adapter_usage_and_mashup.pdf
The idea is to have an Adapter responding to app mobile than this adapter call other deployed adapter (QA, Test Env, Prod Env, etc) considering any logic.
I think if you override WL.Server.invokeHttp so you can specify the domain name in each request instead of using the one set in the XML file, would a good alternative . You can get the domain name as parameter in the invocation request.
There is question that may interest you regarding that, you should check it because I'm not sure if it's possible or not. Worklight Adapter Override Origin of request

Enable logging in Apache CXF generated client

I followed directions on CXF web site to enable logging of SOAP requests, but cannot see any logging going on in my logs.
I have log4j, so I added -Dorg.apache.cxf.Logger=org.apache.cxf.common.logging.Log4jLogger to Tomcat jvm args, then I created cxf.xml and put into classpath. I also added logger into log4j config.
Nothing gets logged.
What can be a problem?
cxf.xml:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cxf="http://cxf.apache.org/core"
xsi:schemaLocation="
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
</beans>
I use the LoggingInInterceptor/LoggingOutInterceptor and am not sure about your bus configuration but you should be sure to also added a correct logger (with the correct name) to your log4j configuration.
In the Apache CXF - 2.5 Migration Guido you will find the usefull information
The Logging interceptors now log using service specific
categories/loggers instead of just
LoggingInInterceptor/LoggingOutInterceptor. The names of the logger
that is used is
org.apache.cxf.services.ServiceName.PortName.PortTypeName. This allows
the user to configure specific per service filters and formatters in
their logging configuration.
I have written a blog post about logging with Apache CXF that provides all information I needed to enable request/response logging in my application.

ExtendedFormAuthenticator in JBoss 7

I'm porting a legacy application from JBoss 4.2.3 to JBoss 7 (the web profile version). They used a custom login module and used a valve to capture the login failure reason into j_exception. They did this by putting context.xml into the web-inf directory of the war, with the following contents:
<!-- Add the ExtendedFormAuthenticator to get access to the username/password/exception ->
<Context cookies="true" crossContext="true">
<Valve className="org.jboss.web.tomcat.security.ExtendedFormAuthenticator"
includePassword="true" ></Valve>
</Context>
The login is working for me, but not that valve. When there's a login exception, the j_exception is still empty and the logic that depends on analyzing why the login was rejected fails. According to this link: http://community.jboss.org/wiki/ExtendedFormAuthenticator, everything looks right. However that link is very old, and it's possible things have changed since then. What's the new way?
It seems that security valves are now defined directly in jboss-web.xml, like this:
<jboss-web>
<security-domain>mydomain</security-domain>
<valve>
<class-name>org.jboss.web.tomcat.security.ExtendedFormAuthenticator</class-name>
<param>
<param-name>includePassword</param-name>
<param-value>true</param-value>
</param>
</valve>
</jboss-web>
However, the ExtendedFormAuthenticator class wasn't ported to JBoss 7.0.1. A ticket has been opened for me, so it should be present in JBoss 7.1.0:
https://issues.jboss.org/browse/AS7-1963

No factories configured while using Jetty 7 embedded + Myfaces 1.2

I am using an embedded version of jetty 7 to load a web application using Apache MyFaces 1.2 in a junit 4 test class on the advice from another thread.
While running the test i get this error.
java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
This application works fine with tomcat, weblogic and even oc4j!
How can i get this to work with jetty?
I solved this by adding the myfaces-impl jar which had the .tld file inside the WEB-INF/lib directory.