Difficulties deploying bot to Heroku - java

I am completely new to this so pretty much clueless and need help.
I have done a few things involving setting up a pom.xml file and Procfile, but whether that's working and the file hierarchy is correct is also kind of a mystery to me...
Anyway, when I deploy to Heroku, this is the error message I get:
[ERROR] Failed to execute goal on project TokenBot1.0: Could not resolve dependencies for project org.example:TokenBot1.0:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: net.dv8tion:JDA:jar:4.2.0_214, com.jagrosh:jda-utilities:jar:3.0.4: Could not find artifact net.dv8tion:JDA:jar:4.2.0_214 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
! ERROR: Failed to build app with Maven
We're sorry this build is failing! If you can't find the issue in application code,
please submit a ticket so we can help: https://help.heroku.com/
! Push rejected, failed to compile Java app.
! Push failed
I also don't understand maven vs. gradle all that much, but I think my project was using gradle initially, and then I followed a guide to try setup with maven since a lot of the Heroku guides wanted maven.
Files look something like this:
TokenBot 1.0
Procfile
build.gradle
.git
src
pom.xml
main
build
libs
.jar file
Procfile
worker: java -jar target/TokenBot 1.0-1.0-SNAPSHOT.jar
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>org.example</groupId>
<artifactId>TokenBot1.0</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_214</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jagrosh</groupId>
<artifactId>jda-utilities</artifactId>
<version>3.0.4</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Please let me know if you need to know anything else.
Thanks in advance to anyone that can help!

I remade my whole project (just salvaged the code) using maven instead of gradle since basically every tutorial I could find used maven.
Next I made sure that I could still run my bot fine locally (I had to do a bit to my pom.xml file to achieve that)
The only tutorial I found that matched my exact case for deploying to heroku (minus github) was this Russian one: https://www.youtube.com/watch?v=LRapMfUMe4s
After following this tutorial exactly, the only thing that was missing for me was to create a Procfile, which I did. Once that's done, head over to heroku and enable the dyno that should show up.
So basically:
Create a fresh project file using maven instead of gradle
Make sure it runs fine locally (both with 'run' button in IntelliJ and executing the .jar file)
Deploy to heroku following the video/journey above
Procfile; make sure to create one in your root folder

Related

Maven project compile error: cannot find symbol (which is java.lang.String)

It's a very simple web scraping program that I built in intellij idea with the maven build system. It worked fine before today but when I tried to build it today it gave me object not found errors for base java objects like String and List. When I tried to reload the maven project I got another error below. Idea also highlights the basic java object in red and gives no advice. The only thing I did was slightly modify the java source code. So, I tested with the stock hello world code. It did compile and run, but Intellij still highlights String and System in red and the maven reload produces the same error. Help is greatly appreciated as I need to get some data for a research project.
Error with web scraping source code compilation error
Error:(24, 13) java: cannot find symbol
symbol: class List
location: class Main
Maven reload error
Cannot resolve plugin org.apache.maven.plugins:maven-compiler-plugin:${maven.compiler.version}
This is the pom.xml file
<?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>htmlunittest</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<version>2.19</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Update:
After resolving the maven errors, since you are facing IDE related problems, I would suggest you to do this:
Go to File > Project Structure
Add the JDK in Project SDK (If it is not there, under Platform Settings > SDKs, you need to add the JDK)
Also ensure that maven home is set correctly in Preferences > build tools > maven:
Then do a maven rebuild from the side panel:
You have forgot to define the property ${maven.compiler.version} in your POM.
Define a properties section in your POM like this:
<properties>
<java.version>1.11</java.version>
<maven.compiler.version>3.8.1</maven.compiler.version>
</properties>

Robot Framework errors when running my maven-selenium-testNG java project

I'm trying to set up a java project that uses Maven, Selenium 3 and TestNG in Eclipse. I did it successfully by creating a maven project and just adding selenium and testNG dependencies, then letting maven to do all the work of downloading libraries.
But now I want to add Robot Framework, so I grabbed the dependency info from https://mvnrepository.com/artifact/org.robotframework/robotframework/3.0.2 and plugin info, then created a "robotframework/acceptance" folder within src/test and a tests.robot file in src/test/robotframework/acceptance to write my tests (I only added an example test that opens a website, just to check if it works).
This is what my pom.xml looks like:
<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.automation</groupId>
<artifactId>automated_tests</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.robotframework</groupId>
<artifactId>robotframework</artifactId>
<version>3.0.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.robotframework</groupId>
<artifactId>robotframework-maven-plugin</artifactId>
<version>1.4.7</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And this is my test:
*** Settings ***
Library SeleniumLibrary
Test Set Up Start Selenium Server
Test Tear Down Stop Selenium Server
*** Test Cases ***
Visit google
Open Browser https://www.google.com chrome
Close Browser
I also created a run configuration like this:
In the Run Configurations dialog, double clicked on the Maven Build
Clicked on the Browser Workspace button and selected my project as the base directory
Under "Goals" I entered robotframework:run
Checked "Resolve Workspace artifacts" and "Update Snapshots"
However, when I run it using this, I get the following error:
[ ERROR ] Error in file 'C:\Users\myself\automated_tests\src\test\robotframework\acceptance\tests.robot': Importing test library 'SeleniumLibrary' failed: ImportError: No module named SeleniumLibrary
Traceback (most recent call last):
None
PYTHONPATH:
C:\Users\myself\.m2\repository\org\robotframework\robotframework\3.0.2\Lib
C:\Users\myself\.m2\repository\org\robotframework\robotframework\3.0.2\robotframework-3.0.2.jar\Lib
__classpath__
__pyclasspath__/
CLASSPATH:
/C:/eclipse/plugins/org.eclipse.m2e.maven.runtime_1.6.3.20160209-1444/jars/plexus-classworlds-2.5.2.jar
Acceptance.Tests :: A resource file containing the application specific key...
Can anyone tell me what I'm missing?

Run Maven project from command line with arguments give error

I am having a Maven project that has following file structure :
src/main/java/com/TestFolder/{Java file name}
This Java file contains a main method that I need to execute with argument from command line. How this can be done ? Please help.
Currently am doing something like this :
mvn exec:java -Dexec.mainClass=src.main.java.com.TestFolder.MyMainJavaClass -Dexec.args="1"
Is this right syntax to do it ? Because when i run this i get following error :
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven- plugin:1.4.0:java (default-cli) on project Staples_7Lakh: Execution default-cli of goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java failed: Plugin org.codehaus.mojo:exec-maven-plugin:1.4.0 or one of its dependencies could not be resolved: The following artifacts could not be resolved: backport-util-concurrent:backport-util-concurrent:jar:3.1, org.apache.maven:maven-core:jar:2.2.1, org.codehaus.plexus:plexus-utils:jar:3.0.20: Could not transfer artifact backport-util-concurrent:backport-util-concurrent:jar:3.1 from/to central (https://repo.maven.apache.org/maven2): GET request of: backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar from central failed: SSL peer shut down incorrectly -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
This problem is because the dependancies are missing in the executable jar. The executable jar needs all run time dependencies to be present. I also had a similar problem which I solved using maven assembly plugin please find below configuration with the pom file for the assembly plugin configuration -
<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>xyz.jeetendra.hibernate.Sample</groupId>
<artifactId>Excercise1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Excercise1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
<build>
<finalName>UserService</finalName>
<plugins>
<!-- maven Assenmbly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<!--get all project dependency -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- Main class in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>xyz.jeetendra.hibernate.sample.Service</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
BR

Maven : Migrating Android project from Ant to Maven

I started an Android project, and by default it is built with ANT, I am trying to upgrade it to Maven so I can get rid of compile time problems I am having with Android SDK, and ease of library import and management. The problems I have encountered are :
1) How to modify build.xml to instruct it to use maven.
2) Maven complaining folder structure is wrong.
Here is my build.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project name="myapp" default="help">
<property file="local.properties"/>
<property file="ant.properties"/>
<property environment="env"/>
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME"/>
</condition>
// and more
So I presume I have to modify the ant.properties attribute, how can I suggest to use Maven??
Here is the POM.xml I have pasted in the Parent directory of the project, but when I try to run mvn compile, I get the following error :
Failed to execute goal com.jayway.maven.plugins.android.generation2:android-maven-plugin:4.0.0-rc.2:generate-sources (default-generate-sources) on project gs-maven-android:
[ERROR]
[ERROR] Found files or folders in non-standard locations in the project!
[ERROR] ....This might be a side-effect of a migration to Android Maven Plugin 4+.
[ERROR] ....Please observe the warnings for specific files and folders above.
[ERROR] ....Ideally you should restructure your project.
[ERROR] ....Alternatively add explicit configuration overrides for files or folders.
[ERROR] ....Finally you could set failOnNonStandardStructure to false, potentially resulting in other failures.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
And finally, here is the 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.hello</groupId>
<artifactId>MyAPP</artifactId>
<version>1.0</version>
<packaging>apk</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>4.1.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<artifactId>android-maven-plugin</artifactId>
<version>4.0.0-rc.2</version>
<configuration>
<sdk>
<platform>20</platform>
</sdk>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
So what am I doing wrong here? Any help would be nice. I am using Intellij Idea on Ubuntu Linux. Thanks.
Please update to a full release version and then update the error message in the post. The latest release is 4.3.0.
The warning is about the source code and other sources being located in non-standard folders. You should use the standard structure. The full version will show error message with details where everything should be.

Maven, Webstart, and Java 8 Headaches

I am trying to convert a project from compiling with Java 6 to Java 8. We are using the webstart-maven-plugin for which there is currently a workaround (http://mojo.10943.n7.nabble.com/jira-MWEBSTART-269-Java-8-support-td44357.html) for compiling with Java 8 by adding the following dependencies to the plugin definition.
...
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<version>1.0-beta-6</version>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>webstart-pack200-impl</artifactId>
<version>1.0-beta-6</version>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-api-1.7</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
...
</plugin>
</plugins>
</pluginManagement>
</build>
...
This got me past my initial issues.
I am now receiving the following error.
[ERROR] Failed to execute goal org.codehaus.mojo:webstart-maven-plugin:1.0-beta-6:jnlp-inline (default) on project <redacted>: Unable to parse configuration of mojo org.codehaus.mojo:webstart-maven-plugin:1.0-beta-6:jnlp-inline for parameter pack200: Cannot find default setter in class org.codehaus.mojo.webstart.Pack200Config -> [Help 1]
The Help link goes to the following page.
https://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException
As far as I can figure out, the webstart-pack200-impl dependency requires some configuration to define which setter is used. Any information regarding setters that I have found online seems to be a different issue from this. I can't figure out if there is a way to set a configuration for a dependency.
Or am I looking at this in a completely incorrect way?
Many thanks in advance
the error points to pack200 which was configured as <pack200>false</pack200>in older version of webstart plugin configuration.
This can be resolved by changing pack200 configuration to this instead (within <configuration> section of the plugin settings)
<pack200><enabled>false</enabled></pack200>
for more details please refer http://www.mojohaus.org/webstart/webstart-maven-plugin/upgrade.html section "Important changes since 1.0-beta-3"

Categories

Resources