Mule 4.x Sample Example With Standard War File Deployment - mule

We want to embed mule community edition 4.x is our war file. Is there a sample anywhere showing this. With Mule 3x we used the MuleXmlBuilderContextListener.
UPDATE:
I added the mule repositories to my settings.xml as mentioned in the mule documention. I am referencing 4.1.4 and the different mule jar files I need are available except for the builders. I am trying to initialize the mule with the org.mule.runtime.config.builders.MuleXmlBuilderContextServlet passing in the location of the mule context.
When I look for that class in the mule repositories, the latest version I find is here:
<dependency>
<groupId>org.mule.runtime</groupId>
<artifactId>mule-module-builders</artifactId>
<version>4.0.0-FD.4</version>
</dependency>
and during startup I see some errors in comparability. Does anyone know where in the mule repositories I can find version 4.1.4 of the mule-module-builders atrifact?

Related

log4j2 for MULE 3 CE patch update

I need some information of log4j2 for updating our central versions of Mule CE 3.9.0 and Mule CE 3.9.5 (CE=Community Edition).
What is the best way to protect them and does downloading only jar files from Apache site https://dlcdn.apache.org/logging/log4j/2.12.3/ be useful to patch Mule CE 3.9?
Regards
As a summary you only need to find the vulnerable jars in the mule-server and in the mule flows deployed in the apps folder.
A Java project is a set of java class and libraries with complex dependencies relationship, but easy to replace one of them (manually or automated with maven), so no matter how or where log4j is being used, we just need replace the jar file.
mule community server 3.9.0
In this version, with this command find . -type f -iname "*log4j*" we will get the log4j jars:
As we can see, the version prior to the 2.14.x
log4j-jul-2.8.2.jar
log4j-jcl-2.8.2.jar
log4j-slf4j-impl-2.8.2.jar
log4j-core-2.8.2.jar
log4j-api-2.8.2.jar
log4j-1.2-api-2.8.2.jar
But according to the official maven repository, this version is affected too :(
Just the 2.17.0 is safe to use
Source: https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core
If this change breaks your mule, just delete the specific vulnerable class:
zip -q -d
log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class
Source: https://www.docker.com/blog/apache-log4j-2-cve-2021-44228/
mule flow or mule app
This is not the server, is the app developed by programmers, packaged as .zip and deployed to the mule apps folder in the server.
In this layer, the app can ignore completely the server configurations and has its own jar versions.
If you don't use maven (rare), you need to search and replace the jar, app by app, similar to the server with find command but in the specific app folder:
/opt/mule_server/apps/my-mule-app
If you use maven, you could find if the jar is used with the pom.xml previewer of Eclipse Ide or with command mvn dependency:tree. Check this:
https://stackoverflow.com/a/68916675/3957754
Remember: If you not use directly this jar, you need to check if mule esb server uses it.
Here some tips from manual to automated pipelines:
mule esb monolithic with manual deployment
In this case you need to fix the server and your apps.
for the server, backup, stop, search the jar on lib folder and replace it with the 2.17 (after vulnerability fix) and start. Test if everything is working
for the mule apps, the process is the same: stop the mule server, go to your mule apps and one by one, search the jar and replace it. Start the mule server and test if everything is working
git repository , maven and one mule app by server
In this case, you don't have a big server with a big mule containing a lot of mule apps/flows. You have one light server for just one mule app.
Just search the dependency in your pom with maven and replace it.
Push your changes and in the next deploy( manual or automated) your mule app will be fixed.
Also note that this approach fix the app, not the server.
git, docker
If you are using docker, the things are easy. Just search the Dockerfile (usually in a git repository). In this file there are a lot of sentences, since the java installation until the star of mule server.
Choose the exact line between the download of mule and the start of server and put a sentence which replace the jar file
Next deploy will pick you new image version and that's all.
automated flow(devops)
Here you are using maven, gi, docker and some ci server. You just need:
update the git repository of your mule app (maven)
update the git repository of your docker image
deploy your fix using the ci server.
With this, you will not need human access to the production servers to fix your java application ( mule)

Does Anypoint studio have a plugin for debugging mule files in Intellij

I want to debug through my code that contains mule and various XML files in Intellij. I was hoping to know if there was a Plugin for the same.
Use Mule-intellij Plugin
Reference Urls:
https://plugins.jetbrains.com/plugin/8212?pr=
https://github.com/machaval/mule-intellij-plugins
https://forums.mulesoft.com/questions/1777/moving-from-mule-studio-to-intellij.html
My entire project coupled with both Front end application and with Mule - maven based( I suppose to work both with Intellij and also Anypoint).Each and every application have its own POM. When i work with individual Mule application, will import apps as maven based. Anypoint studio is best to work on Mule interfaces compare to Intellij.
When it comes to front end application, used Intellij.
When working on very large project ( both front end and Mule) if you try to import entire project in Anypoint- It hangs. Those cases Intellij is best to import as Module( easy search, code monitor with Jira history etc).
I switch Intellij and Mule studio case by case.
After Installing Mule-intelij plugin. Could see Mule configuration xml marked as 'M'. Easy to run as Maven project and also Junit test cases.
I have installed old version of plugin where I can only debug Mule-Java application( not Mule configurable xml).Ctr+tab will show all the options as like AnyPoint. But you cant see Mule GUI or Drag and Drop feature here.
In the above mentioned first URL, new plugin version shows debug point in Mule configuration example. You can give it a go.

Deploying Mule to Tomcat

i'm very new to mule esb. I have some question after try mule.
1.how can i run mule project by Tomcat? (I've try this issue but seem not working : http://www.mulesoft.org/documentation/display/current/Deploying+Mule+as+a+Service+to+Tomcat)
I have error when I starting tomcat like something was wrong.
2.How can I packing mule project to .war? ,I see that my editor(sts) don't think that mule application is a web application but the file path of mule application seem to be similar to maven generate project so... I don't know.
I use mule version 3.4.0
thank you,
First of all, you should use the Mule Standalone, if you can. If you really need to use Tomcat, I suggest you package all the Mule dependencies into the application war with Maven, and not try to work with the jars manually. See the answer by David Dossot here and an example Maven project here. Note that the example project uses Mule 3.1.2, so you probably want to update it a bit.

How to install a connector on Mule Standalone?

I'm using Mule Standalone. From Mule Studio I'm using a connector I've installed, but since the standalone doesn't have it, it throws an error saying that it can't find the connector amqp:connector etc...
How can I install components in the Mule Standalone?
It should be brought in your application /lib directory by Maven, as a dependency, when you build its package.
For the latest version of the AMQP transport, use:
<dependency>
<groupId>org.mule.transports</groupId>
<artifactId>mule-transport-amqp</artifactId>
<version>3.4.0</version>
</dependency>
Check to see that your connector is in your projects class path before you export to standalone. You can do this automatically if you drag and drop your connector in a flow and save it.

Does Mule CloudHub use Java SE or EE by default?

I'm uploading an application to CloudHub and getting ClassNotFound errors for javax.validation.ValidatorFactory. I believe the javax.validation package is found only in EE and not SE, which is available in my localhost environment. So, is EE not available to CloudHub apps by default?
Mule is not a JavaEE container so it doesn't embed all the JavaEE extensions to the standard JDK.
If you download Mule Standalone EE and look at the JARs in lib/opt you'll see what JavaEE JARs are available by default, which include (but is not limited to):
Activation 1.1
JMS 1.1
JTA 1.1
If you need more JARs or different versions, it is up to you to ship them with your app. You may have to use classloader filtering if you want to use a different version of a JAR provided by Mule.