Thirlan
Thirlan

Reputation: 712

Wildfly: embedding Spring and Camel into a jar

We are working with another group's Wildfly server. We will provide them with one or more jars/wars that they will load into their Wildfly .ear. We can't modify what is available in their Wildfly server, but we want access to Camel with the Spring DSL for Camel. We are thinking about embedding Camel and Spring into one of our jars. How do we go about doing this?

Notes:

Upvotes: 0

Views: 394

Answers (1)

Vadim
Vadim

Reputation: 4120

Maybe you need to try WildFly owners to think about it one more time...

Combine Camel and Spring into fat jar file and deploy it in ear

It is possible, but... is quite not good

Pros: None.

Cons:

  • Both Spring and Camel are not just single jar files, but a bunch different jar files, transitive dependencies and so and so.

  • Combine all of that will produce tremendously large jar file which will be deployed within tremendously large ear... Do they really want this?

Instead of that there are two options aside of adding Spring and Camel to the WildFly installation:

  1. if WildFly owners are OK with large ear file, you can add all needed dependencies for your war file with compile or runtime scope into Maven Ear project pom.xml. Then Maven will put all dependency jar files inside ear file and you will be able to use them for your application.

    • Create your own JBoss module with all needed jar files.
    • Store it in JBoss module directory.
    • Define that module as dependency for your war file in deployment descriptor - jboss-deployment-structure.xml file.

Something like:

<jboss-deployment-structure>
  ...
  <sub-deployment name="my-camel-app.war">
     <dependencies>
        <module name="com.mycompany.spring-camel.module" />
     </dependencies>
  </sub-deployment>
  ...
</jboss-deployment-structure>

That is the best way to do that and WildFly owners do not need to worry about that. As long as Spring and Camel are not in WildFly configuration, nobody will use it, but only applications with explicitly defined dependency in their deployment descriptors to that module.

PS. It is not hard to create a module for JBoss and you can find enough samples and instructions... As example here is the simple one: How to install a module on WildFly

Upvotes: 1

Related Questions