I'm trying to make my Discord bot to work on Heroku but I keep getting an error. The build process works fine but the bot doesn't go online. I went to Resources --> More --> View Logs and saw an error. I understood the error as some methods not getting recognized and I removed the error one. But another one would just pop up. The code and bot works on local using IntelliJ. Anyone can help me with this please?
The error/Resource logs:
2021-04-18T23:58:17.202220+00:00 app[Worker.1]: location: class Main
2021-04-18T23:58:17.226725+00:00 app[Worker.1]: src/main/java/Main.java:9: error: cannot find symbol
2021-04-18T23:58:17.226770+00:00 app[Worker.1]: jda.setActivity(Activity.listening("!help"));
2021-04-18T23:58:17.226835+00:00 app[Worker.1]: ^
2021-04-18T23:58:17.226906+00:00 app[Worker.1]: symbol: variable Activity
2021-04-18T23:58:17.226942+00:00 app[Worker.1]: location: class Main
2021-04-18T23:58:17.228071+00:00 app[Worker.1]: 5 errors
2021-04-18T23:58:17.230942+00:00 app[Worker.1]: error: compilation failed
2021-04-18T23:58:17.336252+00:00 heroku[Worker.1]: Process exited with status 1
2021-04-18T23:58:17.440163+00:00 heroku[Worker.1]: State changed from up to crashed
Build/Deploy logs:
-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/java
-----> Java app detected
-----> Installing JDK 15... done
-----> Installing Maven 3.6.2... done
-----> Executing Maven
$ mvn -DskipTests clean dependency:list install
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< org.example:CalciteDiscordBot >--------------------
[INFO] Building CalciteDiscordBot 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # CalciteDiscordBot ---
[INFO] Deleting /tmp/build_6a1072dc/target
[INFO]
[INFO] --- maven-dependency-plugin:2.8:list (default-cli) # CalciteDiscordBot ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # CalciteDiscordBot ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/build_6a1072dc/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # CalciteDiscordBot ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 21 source files to /tmp/build_6a1072dc/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # CalciteDiscordBot ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /tmp/build_6a1072dc/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # CalciteDiscordBot ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # CalciteDiscordBot ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # CalciteDiscordBot ---
[INFO] Building jar: /tmp/build_6a1072dc/target/CalciteDiscordBot-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # CalciteDiscordBot ---
[INFO] Installing /tmp/build_6a1072dc/target/CalciteDiscordBot-1.0-SNAPSHOT.jar to /tmp/codon/tmp/cache/.m2/repository/org/example/CalciteDiscordBot/1.0-SNAPSHOT/CalciteDiscordBot-1.0-SNAPSHOT.jar
[INFO] Installing /tmp/build_6a1072dc/pom.xml to /tmp/codon/tmp/cache/.m2/repository/org/example/CalciteDiscordBot/1.0-SNAPSHOT/CalciteDiscordBot-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.854 s
[INFO] Finished at: 2021-04-18T23:57:57Z
[INFO] ------------------------------------------------------------------------
-----> Discovering process types
Procfile declares types -> Worker
-----> Compressing...
Done: 76.7M
-----> Launching...
Released v23
https://calcitediscordbot.herokuapp.com/ deployed to Heroku
Main.java
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Activity;
import javax.security.auth.login.LoginException;
public class Main {
public static void main(String[] args) throws LoginException {
JDABuilder jda = JDABuilder.createDefault("I inserted token here");
jda.setActivity(Activity.listening("!help"));
jda.build();
}
}
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>org.example</groupId>
<artifactId>CalciteDiscordBot</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.target>15</maven.compiler.target>
<maven.compiler.source>15</maven.compiler.source>
</properties>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_246</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
</project>
Procfile:
Worker: java src/main/java/Main.java
If you run locally with an IDE like IntelliJ, it will handle things like this to you, but you need add a plugin to create a jar with dependencies before deploying it.
<?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>org.example</groupId>
<artifactId>CalciteDiscordBot</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>...</properties>
<dependencies>...</dependencies>
<repositories>...</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>
Main
</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
To fix this problem, you'd have to change the pom.xml and Procfile.
Add this line to the pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>2.1.0</version>
<configuration>
<assembleDirectory>target</assembleDirectory>
<programs>
<program>
<mainClass>MAIN_CLASS_PATH</mainClass>
<name>BOT_NAME</name>
</program>
</programs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>
Add this inside of your plugins tag in your build tag. Change MAIN_CLASS_PATH to your own main class and change BOT_NAME to your project's/bot's name.
Change the Worker for the Procfile to this:
worker: sh target/bin/BOT_NAME
Same thing here ^, change BOT_NAME to your project's/bot's name.
Most credit goes to BooleanCube's Discord. And thank you #Kaneda for the help!
Related
When i run mvn clean compile openjpa:enhance install i noticed compile goal running twice - once before openjpa:enhance and after it (also with resources), which causes enhanced classes with openjpa:enhance to be discarded, because they are compiled again and rewritten.
How to change pom.xml or mvn command arguments so it will not run compile twice, but only once before openjpa:enhance? install at the end is needed.
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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>registry</groupId>
<artifactId>datalayer</artifactId>
<version>0.0.1</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<includes>datalayer/dto/*.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
<enforcePropertyRestrictions>true</enforcePropertyRestrictions>
</configuration>
<executions>
<execution>
<id>enhancer</id>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId>
<version>3.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.15.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<version>10.15.2.0</version>
</dependency>
</dependencies>
</project>
output from mvn clean compile openjpa:enhance install:
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< registry:openjpaenhancingtest >--------------------
[INFO] Building openjpaenhancingtest 0.0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # openjpaenhancingtest ---
[INFO] Deleting C:\Users\wortigson\Desktop\ISMatrikaBcWorkspace\Openjpa.Test\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # openjpaenhancingtest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # openjpaenhancingtest ---
[WARNING] Can't extract module name from geronimo-jms_1.1_spec-1.1.1.jar: geronimo.jms.1.1.spec: Invalid module name: '1' is not a Java identifier
[WARNING] Can't extract module name from geronimo-jta_1.1_spec-1.1.1.jar: geronimo.jta.1.1.spec: Invalid module name: '1' is not a Java identifier
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to C:\Users\wortigson\Desktop\ISMatrikaBcWorkspace\Openjpa.Test\target\classes
[INFO]
[INFO] --- openjpa-maven-plugin:3.1.2:enhance (default-cli) # openjpaenhancingtest ---
88 DataLayer INFO [main] openjpa.Tool - Enhancer running on type "class entities.EntityPerson".
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # openjpaenhancingtest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # openjpaenhancingtest ---
[WARNING] Can't extract module name from geronimo-jms_1.1_spec-1.1.1.jar: geronimo.jms.1.1.spec: Invalid module name: '1' is not a Java identifier
[WARNING] Can't extract module name from geronimo-jta_1.1_spec-1.1.1.jar: geronimo.jta.1.1.spec: Invalid module name: '1' is not a Java identifier
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to C:\Users\wortigson\Desktop\ISMatrikaBcWorkspace\Openjpa.Test\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # openjpaenhancingtest ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # openjpaenhancingtest ---
[WARNING] Can't extract module name from geronimo-jta_1.1_spec-1.1.1.jar: geronimo.jta.1.1.spec: Invalid module name: '1' is not a Java identifier
[WARNING] Can't extract module name from geronimo-jms_1.1_spec-1.1.1.jar: geronimo.jms.1.1.spec: Invalid module name: '1' is not a Java identifier
[INFO] Changes detected - recompiling the module!
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # openjpaenhancingtest ---
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # openjpaenhancingtest ---
[INFO] Building jar: C:\Users\wortigson\Desktop\ISMatrikaBcWorkspace\Openjpa.Test\target\openjpaenhancingtest-0.0.1.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # openjpaenhancingtest ---
[INFO] Installing C:\Users\wortigson\Desktop\ISMatrikaBcWorkspace\Openjpa.Test\target\openjpaenhancingtest-0.0.1.jar to C:\Users\wortigson\.m2\repository\registry\openjpaenhancingtest\0.0.1\openjpaenhancingtest-0.0.1.jar
[INFO] Installing C:\Users\wortigson\Desktop\ISMatrikaBcWorkspace\Openjpa.Test\pom.xml to C:\Users\wortigson\.m2\repository\registry\openjpaenhancingtest\0.0.1\openjpaenhancingtest-0.0.1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
You need to add openjpa:enhance to the POM itself. Then you just run mvn clean install.
I am having trouble getting JUnit 5 tests to run on VSCODE. I believe my environment is set up properly. A clone of junit5-samples | junit5-jupiter-starter-maven builds and runs as expected. My project does not.
My project builds under maven but runs no tests. So this is probably a Maven or project configuration issue and not related to VSCODE.
I have tinkered with various ideas for a couple of hours to no avail. Something is different, probably a mistake and maybe additional pairs of eyes can find it. Any help you might provide will be greatly appreciated.
Here is some project information
'mvn clean package' runs without error, but no tests run. CodeLens is also not working.
Run Test|Debug Test is missing. No tests show up in test runner.
Here is my POM file with a few redactions:
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.redacted</groupId>
<artifactId>redacted</artifactId>
<packaging>jar</packaging>
<version>0.1.1</version>
<name>redacted</name>
<properties>
<skipTests>false</skipTests>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
<junit.jupiter.version>5.6.2</junit.jupiter.version>
</properties>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit.jupiter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!-- <skipTests>${skipTests}</skipTests> -->
</configuration>
</plugin>
<!-- <plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
</plugin> -->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.3.6</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/WSDL/redacted.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Here is the output from the mvn command:
[INFO]
[INFO] ------------------------< com.redacted:redactedClient >-------------------------
[INFO] Building redactedClient 0.1.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # redactedClient ---
[INFO] Deleting D:\repos\redacted\redactedClient\target
[INFO]
[INFO] --- cxf-codegen-plugin:3.3.6:wsdl2java (generate-sources) # redactedClient ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # redactedClient ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\repos\redacted\redactedClient\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # redactedClient ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to D:\repos\redacted\redactedClient\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # redactedClient ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory D:\repos\redacted\redactedClient\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) # redactedClient ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\repos\redacted\redactedClient\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) # redactedClient ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.444 s
[INFO] Finished at: 2020-04-26T09:55:55-07:00
[INFO] ------------------------------------------------------------------------
A test method should have the return type void whereas your test method GetModList() has Boolean.
In JUnit Jupiter you can remove public from the test class also from all test methods.
I try to run my test as -mvn test, it is showing as build is success but , No Source to Compile.Down I have attached my both pom and Result file.
Output :
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Wepaythemax 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # Wepaythemax ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\rck\git\repository3\Wepaythemax\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # Wepaythemax ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # Wepaythemax ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # Wepaythemax ---
[INFO] No sources to compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # Wepaythemax ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.051 s
[INFO] Finished at: 2018-12-20T18:37:53+05:30
[INFO] Final Memory: 10M/114M
Pom.xml 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>Wepaythemax</groupId>
<artifactId>Wepaythemax</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.141.5</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>selenium-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Help Me out, Where I have done Mistake, I can't find out. I'm Trying to Figure it out.Also I have attached a Screenshot Where the My testng.xml file is placed
no sources to compile, means no java file in src/main/java or src/test/java.
sources are in src/main/java, sources is different from resources, which means .xml,etc.
I'm trying to build shaded jar in spring boot application but having some issues. I don't know what i'm doing wrong here. I also read the following links but no luck
maven-shade-plugin error: Cannot find setter, adder nor field in org.apache.maven.plugins.shade.resource.ManifestResourceTransformer for 'resource'
here 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>dashboard</groupId>
<artifactId>dashboard</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.2.7.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>jira.widgets</groupId>
<artifactId>jira-widgets</artifactId>
<version>0.1.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.1.5.RELEASE</version>
</parent>
<!-- Additional lines to be added here... -->
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.text.dashboard.hello.Application</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
When i run mvn package then i got following exception on console
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building dashboard 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # dashboard ---
[INFO] Deleting C:\Users\confiz\Documents\workspace-sts-3.7.3.RELEASE\dashboard\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # dashboard ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) # dashboard ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 2 source files to C:\Users\confiz\Documents\workspace-sts-3.7.3.RELEASE\dashboard\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # dashboard ---
[INFO] Not copying test resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) # dashboard ---
[INFO] Not compiling test sources
[INFO]
[INFO] --- maven-surefire-plugin:2.15:test (default-test) # dashboard ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) # dashboard ---
[INFO] Building jar: C:\Users\confiz\Documents\workspace-sts-3.7.3.RELEASE\dashboard\target\dashboard-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:1.1.5.RELEASE:repackage (default) # dashboard ---
[INFO]
[INFO] --- maven-shade-plugin:2.3:shade (default) # dashboard ---
[WARNING] Map in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer declares value type as: class java.util.jar.Attributes but saw: class java.lang.String at runtime
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.609 s
[INFO] Finished at: 2016-04-15T10:55:02+05:00
[INFO] Final Memory: 22M/224M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.3:shade (default) on project dashboard: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.3:shade for parameter resource: Cannot find 'resource' in class org.apache.maven.plugins.shade.resource.ManifestResourceTransformer -> [Help 1]
[ERROR]
Scenario is : i have two spring boot projects and both have same type which executable jar. I'm adding other project in this project as dependency. That's why i'm building a jar which have all the dependencies
Any suggestions?
I don't know why but it worked for me. Use just
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.text.dashboard.hello.Application</Main-Class>
</manifestEntries>
</transformer>
Instead of
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.text.dashboard.hello.Application</Main-Class>
</manifestEntries>
</transformer>
</transformers>
I currently use Eclipse as my Java IDE and I use Maven. I click the run button and it is able to run a Selenium Java test I wrote.
I then proceeded to install Maven on my local machine.
After going to the directory where my pom.xml file is located.
I run the command: mvn test
I receive the following results:
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBu
ilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SeleniumWebDriver 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # SeleniumWebDriver ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platfo
rm dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) # SeleniumWebDriver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # SeleniumWebDriver ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platfo
rm dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) # SeleniumWebDriver ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # SeleniumWebDriver ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.139 s
[INFO] Finished at: 2014-03-17T14:12:27-05:00
[INFO] Final Memory: 12M/99M
[INFO] ------------------------------------------------------------------------
I do not understand why the Firefox webbrowser does not start, and a test is ran. When running the same test in the Eclipse IDE the Firefox webBrowser does start.
It seems to compile fine, but it is for some reason not testing or kicking off the browser when it has the .class files after compilation.
here is a copy of my pom.xml 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>SeleniumWebDriver</groupId>
<artifactId>SeleniumWebDriver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.40.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
</project>
This is a older thread, but still want to provide input for those who are stuck up at this. You have to make sure that the class file names you are creating are ending with "Test" string.
e.g. AppTest, TempTest are all valid class file names, but AppCheck, TempTest1 are invalid name; maven will not detect these files for execution.
I would recommend using Maven Failsafe (for integration tests), or Surefire (for unit tests).
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
I didn't see this until after I had posted my own question...and subsequently found an answer to it! I've included my answer below:
Maven can be made to run the code it compiles by using the exec-maven-plugin and adding the following to the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>Selenium2Example</mainClass>
<arguments>
<argument>arg0</argument>
<argument>arg1</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
As you can probably gather from the snippet, arguments can be passed in by listing them in the pom.xml. Also, be sure to use the proper package name in the mainClass element.
You can then run mvn compile followed by mvn test to compile and run your code.
Credit has to go to http://www.vineetmanohar.com/2009/11/3-ways-to-run-java-main-from-maven/ for listing several ways to do this.
This is most likely due to your directory structure. Maven uses an arbitrary directory structure.
src/main/java is your main java code
src/test/java is your tests. Maven will read THIS directory when executing mvn test by default.
You have two options:
Update your pom to something like:
<build>
<sourceDirectory>src/java</sourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
...
</build>
Abide by Maven convention and put your test sources under src/test/java