How to package switchyard application with maven

How can I package my switchyard app with dependencies from my other project with maven? I am currently trying to get everything to work as explained here.

But with no result when running the application in the log file I see

Caused by: java.lang.NoClassDefFoundError: com/aspiderngi/common/switchyard/InventoryRequest
Caused by: java.lang.ClassNotFoundException: com.aspiderngi.common.switchyard.InventoryRequest from...

      

Is it possible to achieve anyway?

UPDATE: pom.xml

<?xml version="1.0" encoding="UTF-8"?>

      

http://maven.apache.org/xsd/maven-4.0.0.xsd "xmlns =" ​​http://maven.apache.org/POM/4.0.0 "xmlns: xsi =" http: // www. w3.org/2001/XMLSchema-instance "> 4.0.0 com.example.switchyard 0.0.1-SNAPSHOT com.example.switchyard: SY example SY example 2.0.0.Final 1.7 1.7 war

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-bom</artifactId>
            <version>${switchyard.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>

    <dependency>
        <groupId>com.aspiderngi</groupId>
        <artifactId>artifacts-common</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>org.switchyard.components</groupId>
        <artifactId>switchyard-component-camel</artifactId>
    </dependency>
    <dependency>
        <groupId>org.switchyard.components</groupId>
        <artifactId>switchyard-component-camel-jms</artifactId>
    </dependency>
    <dependency>
        <groupId>org.switchyard.components</groupId>
        <artifactId>switchyard-component-resteasy</artifactId>
    </dependency>
    <dependency>
        <groupId>org.switchyard</groupId>
        <artifactId>switchyard-api</artifactId>
    </dependency>
    <dependency>
        <groupId>org.switchyard</groupId>
        <artifactId>switchyard-transform</artifactId>
    </dependency>
    <dependency>
        <groupId>org.switchyard</groupId>
        <artifactId>switchyard-validate</artifactId>
    </dependency>
    <dependency>
        <groupId>org.switchyard</groupId>
        <artifactId>switchyard-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.switchyard.components</groupId>
        <artifactId>switchyard-component-test-mixin-cdi</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.switchyard.components</groupId>
        <artifactId>switchyard-component-bean</artifactId>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.switchyard</groupId>
            <artifactId>switchyard-plugin</artifactId>
            <version>${switchyard.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>configure</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <scannerClassNames>
                    <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
                </scannerClassNames>
            </configuration>
        </plugin>

        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <packagingExcludes>
                    WEB-INF/lib/*.jar,
                    WEB-INF/classes/META-INF/switchyard.xml
                </packagingExcludes>
                <webResources>
                    <resource>
                        <directory>target/classes/META-INF</directory>
                        <targetPath>WEB-INF</targetPath>
                        <includes>
                            <include>switchyard.xml</include>
                        </includes>
                    </resource>
                </webResources>
            </configuration>
        </plugin>
    </plugins>
</build>

      

+3


source to share


2 answers


You can use the Maven Shade plugin: https://maven.apache.org/plugins/maven-shade-plugin/

Example:



<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.4.1</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <shadedArtifactAttached>true</shadedArtifactAttached>
              <shadedClassifierName>jackofall</shadedClassifierName> <!--     Any name that makes sense -->
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>

      

0


source


Please try this. The dependent project must have its own pom.xml (child) Include this child pom in the parent pom. And include the below code in the parent pom.xml This will directly deploy the application to the server From the project root in cmd execute the below commands: 1.mvn clean 2.mvn dependency: allow 3.mvn install

if you are using Eclipse use maven update. then run command "How to start maven"

<build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                    <debug>true</debug>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <configuration>
                    <skip>false</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.switchyard</groupId>
                <artifactId>switchyard-plugin</artifactId>
                <version>${switchyard.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>configure</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <scannerClassNames>
                        <param>org.switchyard.transform.config.model.TransformSwitchYardScanner</param>
                    </scannerClassNames>

                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jboss.as.plugins</groupId>
                <artifactId>jboss-as-maven-plugin</artifactId>
                <executions>
                    <execution>

                        <phase>install</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

      



if you are using Bean then include

<scannerClassNames>
          <param>org.switchyard.transform.config.model.BeanSwitchYardScanner</param>
    </scannerClassNames>

      

0


source







All Articles