I am having trouble creating a simple Java AWS Lambda that does not exceed the 50MB size limit and I am not sure where I am going wrong...
My actual Java code is only around 100 lines long. I am using Maven to pull in my dependencies, most of which are the AWS dependencies themselves...
After I do a mvn package or mvn clean install the resulting jar is around 64MB!
What am I doing wrong here? If I do not add the AWS dependencies then I cannot build with maven but if I do then the resulting jar file is huge and I am unable to upload it to AWS lambda because of the size restriction...
My pom file is below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>lambda-handler</groupId>
<artifactId>lambda-handler</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-core</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.166</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.166</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.3</version>
</dependency>
</dependencies>
</project>
to fix this issue you need to do the following:
Remove the amazon SDK from your pom.
Add the Execution Amazon SDK variable:
AWSEXECUTIONENV -> AWSLambdajava8
Remember to use Java8 in your project. The total size of a simple project will be around 7-10 MB.
If you want to see HOW-TO with github sources and step by step you can see it on my blog:
jmazzetti.com -> Serverless on AWS Lambda using Java
All the best,
Jose.
you need to remove <artifactId>aws-java-sdk-s3</artifactId> and <artifactId>aws-java-sdk</artifactId> dependencies from your maven project and update and rebuild your maven project.
Related
I want to create a executable jar file so anyone can run it from their computer with least install require components.
I found several tutorial but none of them a work.
When I execute jar file I've built they are return error like:
Error: Could not find or load main class fully.qualified.MainClass
Caused by: java.lang.ClassNotFoundException: fully.qualified.MainClass
OR like this:
Error: Could not find or load main class io.cucumber.core.cli.Main
Caused by: java.lang.ClassNotFoundException: io.cucumber.core.cli.Main
My project run from Intellij with no problem.
Here my project structure
https://i.stack.imgur.com/NcQzf.png
And my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>CucumberSelenium</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cucumber.version>7.6.0</cucumber.version>
<selenium.version>4.8.0</selenium.version>
<webdrivermanager.version>5.2.1</webdrivermanager.version>
<junit.jupiter.version>5.9.0</junit.jupiter.version>
<apache.common.version>2.4</apache.common.version>
<projectlombok.version>1.18.24</projectlombok.version>
<maven.compiler.plugin.version>3.10.1</maven.compiler.plugin.version>
<maven.surefire.plugin.version>3.0.0-M7</maven.surefire.plugin.version>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-bom</artifactId>
<version>${cucumber.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>${junit.jupiter.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit-platform-engine</artifactId>
<scope>test</scope>
</dependency>
<!-- JUnit Platform -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-suite</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<!-- Web Driver Manager -->
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>${webdrivermanager.version}</version>
</dependency>
<!-- Apache Common -->
<dependency>
<groupId>org.apache.directory.studio</groupId>
<artifactId>org.apache.commons.io</artifactId>
<version>${apache.common.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${projectlombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>19</source>
<target>19</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<properties>
<configurationParameters>
cucumber.junit-platform.naming-strategy=long
</configurationParameters>
</properties>
<debugForkedProcess>true</debugForkedProcess>
<forkCount>0</forkCount>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifest>
<mainClass>io.cucumber.core.cli.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>assemble-all</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I've run mvn clean compile assembly:single, it's output a CucumberSelenium-1.0-SNAPSHOT-jar-with-dependencies.jar file, but it wont runs.
I just came across a similar issue and, despite trying the ubiquitous
java -cp . org.example.Main
(while on current directory being where the Main.class is), I kept getting this dreaded
"Error: Could not find or load main class"
I eventually resorted to comparing the actual command with parameters invoked by IntelliJ (on IntelliJ IDEA's debug log) with mine, and discovered that the following solves the issue:
java -cp C:\Users\WebViwer\IdeaProjects\MyProj\target\classes org.example.Main
I am guessing that once the fully qualified class name is specified, the current directory (where the class resides) is no longer valid as a classpath: Only the top level classes directory should be specified (in this org.example, 2 levels up).
You have a a few problems going on.
The maven-assembly-plugin should not be a in the dependencies section. It is not a dependency used by the runtime code of your project.
Your step definitions, feature files and glue code located in src/test are not included in the jar file build by the assembly plugin.
Your test scoped dependencies will also not be included by the assembly plugin either.
You must configure the containerDescriptorHandler of the assembly plugin with metaInf-services or the plugin will not merge files in META-INF/services correctly.
You can verify most of these by opening the generated jar file (it's a .zip file in disguise).
My project run from Intellij with no problem.
When running tests in Intelij you are using the test scope, the jar file only includes runtime scoped code.
For a more comparable test you must create a new run configuration that invokes the main method.
I found several tutorial but none of them a work.
It appears that you are relatively new to Java and Maven. It would be prudent to follow a proper course first rather than tutorials. You are missing fundamental knowledge that is generally not taught in tutorials.
I want to create a executable jar file so anyone can run it from their computer with least install require components.
It's also prudent to consider why you are doing this.
Tests will typically change as quickly as the source code they are testing does. Manually distribution of jar files won't keep up with this.
This means it's generally better to integrate the tests and the test source code into the automated build pipeline of the project they test.
This also means that you don't need to distribute your tests as a jar. Rather you should expect (and possibly train) people to use Maven, GIT and Java.
I have 2 maven projects
1) My Utils Project - imports datecalc-common as a dependency, contains my custom utility classes. Note that it doesn't have a main class.
2) My Main Project - imports 'My Utils Project' as a dependency.
'My Main Project' shows the error 'Cannot find class HolidayCalculator'.
My Utils Project-pom.xml is given below.
How do I modify it so that the dependency jars are included as part of 'My Utils Project'.jar ?
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<groupId>com.mycompany.mycommoncode</groupId>
<artifactId>myutilsjar</artifactId>
<version>0.0.12-SNAPSHOT</version>
<name>myutilsjar</name>
<description>Common Date Utils used by my classes</description>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.0.8.RELEASE</version>
</dependency>
<dependency>
<groupId>net.objectlab.kit</groupId>
<artifactId>datecalc-common</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>net.objectlab.kit</groupId>
<artifactId>datecalc-jdk8</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
<version>3.1.4</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
</dependencies>
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<url>my maven url</url>
</snapshotRepository>
</distributionManagement>
</project>
NOTE: I DO NOT want to use 'shade' plugin. Is there any other way of doing this?
I had to solve that same issue some months ago. I wrote a small library that was to be shared between many projects and I wanted to add it to maven.
This is what I did.
For your "Utils project"
Compile it using maven-assembly-plugin:
Add this to your pom.xml:
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>attached</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Build the library with it's dependencies using the following command:
mvn clean compile assembly:attached
For your main project
Add this plugin to your pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<id>install-external</id>
<phase>clean</phase>
<configuration>
<file>${project.basedir}/src/main/resources/lib/sso-client-1.0.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>SSOClient</groupId>
<artifactId>sso-client</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
<goals>
<goal>install-file</goal>
</goals>
</execution>
</executions>
</plugin>
As you can see, I wrote a custom SSO Client.
This will read the jar you compiled in the previous step, and make it available as a dependency. I decided to place it in the resources folder of the main project. The version has to match the one in your "utils project".
Also add the dependency to the pom.xml:
<dependency>
<groupId>SSOClient</groupId>
<artifactId>sso-client</artifactId>
<version>1.0</version>
</dependency>
That's it! You can now reference the classes of the package in your main project.
Let me know if you need clarification.
The Apache Maven Shade Plugin provides the capability to package your artifact in a "uber-jar", that is to say a jar including all dependencies required to run the project. If needed this plugin also supports packages shading (renaming) for some of the dependencies.
More info at:
https://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html#
I am trying to do a program where I need using Aws sdk and TinyB library. FOr that reason I have decided to use maven to create the project and resolve the dependencies. However, I have been trying to compile the project with the package TinyB for more than a week without success. I would be very grateful if someone could teach me what I am doing wrong.
The failure message I am receving is the following:
C:/Users/fran/Desktop/RSSI_AWS_PROJECT/BleDistanceMeasurement/src/main/java/org/tfm/app/BleMng.java:[7,1]
package tinyb does not exist
And my pom.xml is:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.tfm.app</groupId>
<artifactId>BleDistanceMeasurement</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>BleDistanceMeasurement</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.327</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-iot</artifactId>
<version>1.10.34</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java-samples</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.kura</groupId>
<artifactId>tinyb</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>tinyb</id>
<url>https://repo.eclipse.org/content/groups/releases/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have opened the project with Eclipse IDE to know what is happening but I have seen that eclipse is recognizing the dependencies correctly.
TinyB dependencie scan
Project dependencies
TinyB library I have downloaded and compiled the source from here:
https://github.com/intel-iot-devkit/tinyb
But there is no maven repositories directly from intel so I have added the one form eclipse kura:
<!-- https://mvnrepository.com/artifact/org.sputnikdev/bluetooth-manager-tinyb -->
<dependency>
<groupId>org.sputnikdev</groupId>
<artifactId>bluetooth-manager-tinyb</artifactId>
<version>1.0</version>
</dependency>
This one gives me problems when compiling, it seems as if the repository hasn't been downloaded. But the foder with the jar exists (it shows the error quoted previously).
I have made some little programs with TinyB and they are working perfectly, so the program is compiled and installed correctly. The problem is I am not using maven in this little programs (I just add the import and point to the .jar when executing). Like this:
sudo java -cp examples/java/HelloTinyB.jar:/usr/lib/lib/java/tinyb.jar HelloTinyB
I have also try this other maven repository:
<!-- https://mvnrepository.com/artifact/org.sputnikdev/bluetooth-manager-tinyb -->
<dependency>
<groupId>org.sputnikdev</groupId>
<artifactId>bluetooth-manager-tinyb</artifactId>
<version>1.3.2</version>
</dependency>
In this case it recognizes the dependencies and compiles. The problem is it gives error when I try to execute the program:
java.lang.RuntimeException: Native library is out of date. Please update the native library.
at tinyb.BluetoothManager.getBluetoothManager (BluetoothManager.java:317)
Thank you very much for your help.
I see you are trying to use eclipse Kura too.
Did you achieve making it work?
I have the same issue.
By the way, I see that maybe your dependencies are not really valid, as sputnikdev has a library over tinyB, but, finally I have the same problem than you. These are my main dependencies:
<!-- https://mvnrepository.com/artifact/org.sputnikdev/org.eclipse.smarthome.binding.bluetooth.transport.tinyb -->
<dependency>
<groupId>org.sputnikdev</groupId>
<artifactId>bluetooth-manager</artifactId>
<version>1.5.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/intel-iot-devkit/tinyb -->
<dependency>
<groupId>intel-iot-devkit</groupId>
<artifactId>tinyb</artifactId>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>org.sputnikdev</groupId>
<artifactId>bluetooth-manager-tinyb</artifactId>
<version>1.3.3</version>
</dependency>
When I run in Eclipse, Maven and TestNG work fine and pass, but when I run in Jenkins, the following failure message appears:
MojoFailureException
Unlike many other errors, this exception is not generated by the Maven core itself but by a plugin. As a rule of thumb, plugins use this error to signal a failure of the build because there is something wrong with the dependencies or sources of a project, e.g. a compilation or a test failure.
The concrete meaning of the exception depends on the plugin so please have a look at its documentation. The documentation for many common Maven plugins can be reached via our plugin index.
This is my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.techbeamers</groupId>
<artifactId>loadtesting</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Load Testing</name>
<description>Selenium Load Testing Example using TestNG and Maven</description>
<properties>
<selenium.version>2.53.1</selenium.version>
<testng.version>6.9.10</testng.version>
</properties>
<build>
<plugins>
<!-- Below plug-in is used to execute tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<!-- TestNG suite XML files -->
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<!-- Include the following dependencies -->
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
</project>
Please help -- I don't know what's wrong with my plugin or dependencies.
The first possible problem I see: you define the property: testng.version, set the value to: 6.9.10, but then ignore the testng.version property later in your pom.xml, and set the <version> of TestNG to: 6.8.
Try changing the definition of your TestNG <dependency> from what you curently have:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
So that the definition is defined as follows:
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
I need to set the classpath for the maven xmlbean plugin since the xsd are depends upon my 2 java program which I don't wish to pack it as jar and added it to the dependencies.
Note : I dont wish to use maven ant plugin to do the above task.
Actual Error thrown by maven-xml plugin :
error: cvc-complex-type.2.4a: Expected elements 'namespace#http://xml.apache.org/xmlbeans/2004/02/xbean/config qname#http://xml.apache.org/xmlbeans/2004/02/xbean/config extension#http://xml.apache.org/xmlbeans/2004/02/xbean/config' instead of 'usertype#http://xml.apache.org/xmlbeans/2004/02/xbean/config' here in element config #http://xml.apache.org/xmlbeans/2004/02/xbean/config
Since I have used 2 usertype in the xmlconfig and I am bit user maven-xmlplugin is unable to locates the classes. I even tried to package those classes and added in the dependencies though failed.
pom.xml
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 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">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroup</groupId>
<artifactId>myartifacts</artifactId>
<version>V1</version>
<packaging>jar</packaging>
<name>myartifacts</name>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xmlbeans-maven-plugin</artifactId>
<version>2.3.3</version>
<executions>
<execution>
<id>generateEbpacObjectMapJar</id>
<phase>generate-sources</phase>
<goals>
<goal>xmlbeans</goal>
</goals>
</execution>
</executions>
<inherited>true</inherited>
<configuration>
<memoryInitialSize>50m</memoryInitialSize>
<memoryMaximumSize>80m</memoryMaximumSize>
<schemaDirectory>src/xsddir</schemaDirectory>
<xmlConfigs>
<xmlConfig implementation="java.io.File">src/myconfig.xsdconfig</xmlConfig>
</xmlConfigs>
<sourceGenerationDirectory>target/generated/JARSources</sourceGenerationDirectory>
<debug>true</debug>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>saxon</artifactId>
<version>8.7</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans-xpath</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans-xmlpublic</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans-qname</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean</artifactId>
<version>2.5</version>
</dependency>
</dependencies>
xsd config below:
xb:config
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xb="http://xml.apache.org/xmlbeans/2004/02/xbean/config"
xmlns:ebpac="http://bct.com/platform/factory"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xml.apache.org/xmlbeans/2004/02/xbean/config xmlconfig.xsd">
<xb:usertype name="cl:myClass" javaname="java.lang.Class">
<xb:staticHandler>com.ImplClassHandler</xb:staticHandler>
</xb:usertype>
You may look into <scope>provided</scope> tag usage in Maven depedency, the jars would be available at the compile time from your .m2 directories; but not included in packaging.
However, you need to make sure that the library jar should be available somewhere in the classpath of the JVM.