Deployment of basic Java web application to AWS : javax/xml/bind/JAXBException - java

I keep getting this error while trying to deploy an application to AWS:
An internal error occurred during: "Updating AWS Elastic Beanstalk environment:
SampleWebApplication".
javax/xml/bind/JAXBException
Here is what I do:
I create new Maven project based on maven-archetype-webapp 1.0
I configure the pom.xml file with dependencies (full file below)
I type in whatever to index.jsp (it's supposed to be super easy application)
I run it on tomcat7:run, it works like a charm on http://localhost:8080/
I create AWS Server
I select the project, I choose Amazon Web Services Tool --> Deploy to AWS Elastik Beanstalk, choose the added server and I keep getting this message:
I am not able to find any information about this error in the internet. The only thing that I have found is that it is connected to Java version, but I am running Java 1.8 (as was suggested in one post that I found).
Can anyone please help me? I am following this instruction for deployment of the application.
I'm super new to AWS so I don't even know where to start!
index.jsp
<html>
<body>
<h2>Hello There!</h2>
</body>
</html>
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dominikazb</groupId>
<artifactId>SampleWebApplication</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>SampleWebApplication Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<tomcat.version>7.0.50</tomcat.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
<build>
<finalName>SampleWebApplication</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.9</version>
<configuration>
<wtpversion>2.0</wtpversion>
<wtpContextName>todo</wtpContextName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<verbose>true</verbose>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<webappDirectory>${project.build.directory}/${project.artifactId}
</webappDirectory>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
</plugins>
</build>
</project>
Project structure
Please, please, please help!

Finally, I find an answer to this problem in the website:
https://github.com/aws/aws-toolkit-eclipse/issues/123
The examples there were in Unix. Mine is in Window 7. What I did base on the website suggestion is:
Find where is the file jaxb-api-2.2.5.jar located. I am not sure if version 2.2.5 is a must. Suggest try whatever you have.
Mine is located in
C:\Users\myUserName\.m2\repository\javax\xml\bind\jaxb-api\2.2.5.
Exit the Eclipse IDE.
Open PowerShell in Admin mode.
cd to your user directory (my case C:\Users\myUserName) and execute the following command to open the Eclipse IDE with a -dev option which points to the jaxb-api-2.2.5.jar.
C:\Users\myUserName\eclipse\jee-2020-09\eclipse\eclipse -dev $(ls ~/.m2/repository/javax/xml/bind/jaxb-api/*/*[0-9].jar | Select-Object -Last 1)
Certainly, the location of your eclipse.exe can be different.
Happy coding!

Related

How to build standalone executable cucumber jar file?

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.

Could not resolve dependencies for my Maven project

I am trying to create a program that will use the sikulix libraries. So I copy pasted the dependencies from https://mvnrepository.com/artifact/com.sikulix/sikulixapi/1.1.2. Then I ran mvn install to install the libraries and I got this error
[ERROR] Failed to execute goal on project auto-fish: Could not resolve dependencies for project com.bine:auto-fish:jar:1.0: Could not find artifact com.github.vidstige:jadb:jar:-v1.0-g94ebf38-23 in central (https://repo.maven.apache.org/maven2)
After doing some research I realized I may need to add a repositories tag with the sikulixapi repo. That gave me this error.
[ERROR] Failed to execute goal on project auto-fish: Could not resolve dependencies for project com.bine:auto-fish:jar:1.0: Could not find artifact com.github.vidstige:jadb:jar:-v1.0-g94ebf38-23 in Sikulix Repo (https://mvnrepository.com/artifact/com.sikulix/sikulixapi)
At this point I am unsure as to what I should do. This is my first every Maven project.
`
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
<groupId>com.bine</groupId>
<artifactId>auto-fish</artifactId>
<version>1.0</version>
<name>auto-fish</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>Sikulix Repo</id>
<url>https://mvnrepository.com/artifact/com.sikulix/sikulixapi</url>
</repository>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.sikulix/sikulixapi -->
<dependency>
<groupId>com.sikulix</groupId>
<artifactId>sikulixapi</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
`
The code is split up but note that they are all in the pom file for my maven project. Also the first 5 lines aren't not showing up for some reason but I feel like they are not important. And i'm using Vs code for all this.
And if you're wondering the goal of this is to create something that will play some dumb fishing game for me, but this is more of a test to see if I can pull it off rather than something I actually need lol.
If you look at your vidstige artifact in mvnrepository.com, you'll see it lists "Mulesoft" as the only repo that contains it. Following that link shows https://repository.mulesoft.org/nexus/content/repositories/public/ as the optional repository URL you should be adding, not the mvnrepository URL you added which was just a link to the mvnrepository search engine results.
So in short, this should hopefully work:
<repository>
<id>Mulesoft Repo</id>
<url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
</repository>
Note I'm unfamiliar with this repository, so if it requires any kind of authentication or licensing you would want to follow up with instructions from that repo owner.
Alternatively you can skip the dependency download using exclusion.
Since i am not aware of your source code. I am just suggesting this solution
<dependency>
<exclusions>
<exclusion>
<groupId>com.github.vidstige</groupId>
<artifactId>jadb</artifactId>
</exclusion>
</exclusions>
</dependency>
Solution found from LaunchPad

Configure Jenkins to use Chrome - Selenium 3.0.1 Maven TestNG

I've been trying to get Jenkins to use Chrome for my automated tests. When I run the tests locally I am able to get it to use Chrome by -Dbrowser=chrome in JDK VM options for TestNG.
For some reason it seems to be stuck on using Firefox no matter what I try.
Here is my before method
#BeforeMethod(
alwaysRun = true
)
public static void configureBrowserBeforeTest(Method testMethod) {
try {
((Driver)driver.get()).resetBrowser();
wait.set(newDefaultWait());
userAgent = determineUserAgent();
initialiseNewScreenshotCapture(testMethod);
} catch (Exception var2) {
logger.error("Failed to configure browser.", var2);
throw new RuntimeException("Failed to configure browser.", var2);
}
}
And POM File
<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.frameworkium</groupId>
<artifactId>Frameworkium</artifactId>
<packaging>jar</packaging>
<version>2.0.5</version>
<name>Frameworkium</name>
<description>
A template designed to get up and running quickly with Selenium and Appium.
</description>
<url/>
<inceptionYear/>
<organization/>
<licenses/>
<developers/>
<contributors/>
<prerequisites>
<maven>3.1.1</maven>
</prerequisites>
<modules/>
<scm/>
<issueManagement/>
<ciManagement/>
<distributionManagement/>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<env.config>local</env.config>
<threads>1</threads>
<groups/>
<aspectj.version>1.8.9</aspectj.version>
</properties>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.9.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.14</version>
</dependency>
<dependency>
<groupId>com.github.Frameworkium</groupId>
<artifactId>frameworkium-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>3.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>
src/main/resources
</directory>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>tests</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<parallel>methods</parallel>
<threadCount>${threads}</threadCount>
<systemProperties>
<screenshotDirectory>
${project.build.directory}/screenshots
</screenshotDirectory>
<allure.issues.tracker.pattern>
/browse/%s
</allure.issues.tracker.pattern>
</systemProperties>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<includes>
<include>**/Test*.java</include>
<include>**/*Tests*.java</include>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
<include>**/*TestCase.java</include>
</includes>
<groups>${groups}</groups>
<testFailureIgnore>false</testFailureIgnore>
<argLine>
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar"
</argLine>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
I'm sure the solution is something simple, I have Jenkins running as a service and using a local admin account. I have installed the chromedriver plugin for jenkins as well as the Selenium plugin. The tests are being found OK but they are using Firefox and FF version 50 doesnt seem to work with the gecko driver on Selenium 3.0.1, so I would rather use Chrome which I know works just fine but for the life of me I cant figure out how to tell Jenkins to use Chrome instead of FF. Thanks in advance for your help! And apologies if I've missed anything out.
OS - Windows Server 2012
Maven
TestNG
Selenium 3.0.1
I am guessing that the default browser defined to be used is firefox and your test code is not able to find the browser flavour to use (via command line (or) JVM args (or) via parameters) so its defaulting to what it knows of viz., firefox.
I noticed that in your IntelliJ run configurations screenshot, you have specified the browser flavour using the JVM argument -Dbrowser=chrome but for some reason I don't see the same in your Jenkins configuration page screenshot.
You seem to be having something like this clean install package -DBrowserName="$BROWSERNAME" -e
Can you please change it to clean install package -Dbrowser=$BROWSERNAME -e (I dont think you need to enclose $BROWSERNAME with quotes and am assuming that BROWSERNAME refers to a valid parameter in your Jenkins configuration page )
That should basically take care of your issue.

limit jetty scanning in maven plugin

I'm having problems getting a webapp to start quickly in using the maven jetty plugin in eclipse. I'm using the jetty:run goal.
After turning on the logging the problem seems to be that jetty scans all the jars in my webapp for web app configuration. Just including a dependency to jersey-media-moxy causes jetty to add 48 seconds to its start up time.
How do I limit this scanning in the jetty-maven-plugin? I've found Jetty startup delay due to scanning but before I make some external jetty configuration and include this is the maven configuration, I want to make sure that there isn't a more straightforward option.
http://eclipse.org/jetty/documentation/current/quickstart-webapp.html looks promising, but I'm unsure how to proceed (as this doesn't mention the maven plugin either).
my pom.xml file is included 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my-app</groupId>
<artifactId>my-app</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>my-app</name>
<build>
<finalName>my-app</finalName>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.9.v20150224</version>
<configuration>
<war>${project.basedir}/target/my-app.war</war>
<stopPort>8088</stopPort>
<stopKey>foo</stopKey>
<stopWait>10</stopWait>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<!-- artifactId>jersey-container-servlet-core</artifactId -->
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<!-- uncomment this to get JSON support -->
<!-- -->
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
<!-- -->
</dependencies>
<properties>
<jersey.version>2.16</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
This is what I use for my projects to speed up Jetty startup just from the maven pom.xml file (no external configuration is required):
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
<webApp>
<!-- no need to scan anything as we're using servlet 2.5 and moreover, we're not using ServletContainerInitializer(s) -->
<!-- for more relevant information regarding scanning of classes refer to https://java.net/jira/browse/SERVLET_SPEC-36 -->
<webInfIncludeJarPattern>^$</webInfIncludeJarPattern>
<containerIncludeJarPattern>^$</containerIncludeJarPattern>
<!--<webInfIncludeJarPattern>.*/spring-[^/]*\.jar$|.*/.*jsp-api-[^/]\.jar$|./.*jsp-[^/]\.jar$|./.*taglibs[^/]*\.jar$</webInfIncludeJarPattern>-->
</webApp>
</configuration>
</plugin>
Use any regex of your choice (if you're using servlet initializers). Note that ^$ excludes everything.

NoClassDefFoundError on Android project

I have this problem that i can't understand how to solve. i have imported a maps forge project in eclipse using maven, but if try to load the project on device, i get this error.
But i know that that class is in the project. How can i solve this problem?
I am working with the Mapsforge rescue 4.0 library.
I have used the same method to import Mapsforge 0.31 and everything works fine.
02-25 16:46:03.202: E/AndroidRuntime(6370): java.lang.NoClassDefFoundError: org.mapsforge.map.android.graphics.AndroidGraphicFactory
This is the pom.xml of the app.
<?xml version="1.0" encoding="UTF-8"?>
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
org.mapsforge
mapsforge
0.4.0-SNAPSHOT
../../../pom.xml
<artifactId>Samples</artifactId>
<packaging>apk</packaging>
<properties>
<rootDirectory>../../../</rootDirectory>
<targetJdk>1.6</targetJdk>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<configuration>
<dex>
<jvmArguments>
<jvmArgument>-Xmx512M</jvmArgument>
</jvmArguments>
</dex>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<configuration>
<useProjectReferences>false</useProjectReferences>
<buildOutputDirectory>bin/classes</buildOutputDirectory>
<additionalBuildcommands>
<buildcommand>com.android.ide.eclipse.adt.ResourceManagerBuilder</buildcommand>
<buildcommand>com.android.ide.eclipse.adt.PreCompilerBuilder</buildcommand>
<buildcommand>com.android.ide.eclipse.adt.ApkBuilder</buildcommand>
<buildcommand>org.eclipse.jdt.core.javabuilder</buildcommand>
</additionalBuildcommands>
<additionalProjectnatures>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
<projectnature>com.android.ide.eclipse.adt.AndroidNature</projectnature>
</additionalProjectnatures>
<classpathContainers>
<classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER</classpathContainer>
<classpathContainer>com.android.ide.eclipse.adt.ANDROID_FRAMEWORK</classpathContainer>
<classpathContainer>com.android.ide.eclipse.adt.LIBRARIES</classpathContainer>
<classpathContainer>com.android.ide.eclipse.adt.DEPENDENCIES</classpathContainer>
</classpathContainers>
<excludes>
<exclude>com.google.android:android</exclude>
<exclude>org.apache.httpcomponents:httpclient</exclude>
<exclude>org.apache.httpcomponents:httpcore</exclude>
<exclude>commons-codec:commons-codec</exclude>
<exclude>commons-logging:commons-logging</exclude>
<exclude>org.json:json</exclude>
<exclude>org.khronos:opengl-api</exclude>
<exclude>xerces:xmlParserAPIs</exclude>
<exclude>xpp3:xpp3</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mapsforge</groupId>
<artifactId>mapsforge-map-android</artifactId>
<type>apklib</type>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>android</groupId>
<artifactId>android</artifactId>
<version>4.4.2_r2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.jayway.android.robotium</groupId>
<artifactId>robotium-solo</artifactId>
<version>5.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>support-v4</artifactId>
<version>r7</version>
</dependency>
</dependencies>
The solution is as follows:
Download those 5 files:
mapsforge-core
mapsforge-map
mapsforge-map-reader
mapsforge-map-android
svg-android
Put those libraries (jar files) in your project folder libs
Than go to Project->clean
You don't need to install Maven or other plugins. Including the libraries through Java Build Path -> Libraries -> Add External JARs won't work. You need to put it in the libs folder.
If it still doesn't work, make sure you update your android tools and try again.
Good luck :)

Categories