I want to run a simple program -- like HelloWorld -- on Heroku, and also using Heroku Scheduler to run each 10minutes.
I`m not sure about Maven-pom.xml setting, Heroku run task system, and Heroku Scheduler.
Now I have these source but the task result is failed.
> MyApp.java
package com.github.graycat27.sample
public class MyApp {
public static void main(String[] args){
System.out.println("Hello Heroku Scheduler task!");
}
}
> 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.github.graycat27</groupId>
<artifactId>MyApp</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
</project>
> Heroku Scheduler job command
$ java MyApp
deploy to Heroku via GitHub has completed in success.
as a result, logs shows
2021-07-21T11:13:59 app[api]: Starting process with command `java MyApp` by user scheduler#addons.heroku.com
2021-07-21T11:14:02 heroku[scheduler.5096]: Starting process with command `java MyApp`
2021-07-21T11:14:03 heroku[scheduler.5096]: State changed from starting to up
2021-07-21T11:14:05 app[scheduler.5096]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2021-07-21T11:14:05 app[scheduler.5096]: Error: Could not find or load main class MyApp
2021-07-21T11:14:05 heroku[scheduler.5096]: Process exited with status 1
2021-07-21T11:14:05 heroku[scheduler.5096]: State changed from up to complete
what should I change my program or config?
Your ClassName isnt MyApp its com.github.graycat27.sample.MyApp and you need to provide where it can find this File on an Class-/Module-Path
Related
I built a server template in java and now i need to compile and run it using MAVEN.
this is my POM:
<?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:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>bgu.spl</groupId>
<artifactId>spl-net</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
-<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>
<name>spl-net</name>
</project
When I run mvn compile it all works. but then i go to test it with: mvn exec:java - Dexec.mainClass=”bgu.spl.net.impl.BGRSServer.ReactorMain” - Dexec.args=”<port> <No of threads>” and it gives me a class not found exception. I looked in the target directory and this exact main was indeed there, it just refuses to run.
Turns out there was nothing wrong with my code. I failed to realize that in ubuntu, the command: mvn exec:java - Dexec.mainClass=”bgu.spl.net.impl.BGRSServer.ReactorMain” - Dexec.args=”<port> <No of threads>” simply doesn't work. the correct command would be: mvn exec:java - Dexec.mainClass=bgu.spl.net.impl.BGRSServer.ReactorMain - Dexec.args=<port> <No of threads>
Im trying to configure Websockets on my tomcat server but I'm not able to set the endpoint. But I keep getting error
error: cannot find symbol #ServerEndpoint("/websocketendpoint")
I installed the javax.websocket api but im still missing javax.websocket.server package. I've tried installing every java websocket package I could find and still doesnt work.
Is it supposed to be a part of my tomcat server, java 11 or openJDK, or do I just have to get from somewhere online? I've not been able to find this package till now. All other anotations work when I compile with websocket-api.jar
import javax.naming.*;
import java.io.*;
import java.util.*;
import org.json.*;
import javax.naming.*;
import javax.websocket.*;
#ServerEndpoint("/websocketendpoint")
public class OffisEndpoint{
private Session session;
#OnOpen
public void onOpen(Session session){
this.session = session;
}
#OnMessage
public void onMessage(String message){
try{
if(this.session != null && this.session.isOpen()){
this.session.getBasicRemote().sendText("From Server"+ message);
}
}catch(Exception e){
}
}
#OnClose
public void onClose(){
System.out.println("Close Connection ...");
}
#OnError
public void onError(Throwable e){
e.printStackTrace();
}
}
You're not going to be able to live without a build tool very long as you move forward. For this code I used maven to get going. Maven assumes a particular directory structure so your environment would look like:
pom.xml
src/
main/
java/
com/
example/
websocket/
OffisEndpoint.java
The first line in OffisEndpoint.java will now be package com.example.websocket; to indicate that the file now lives in a Java package.
The contents of pom.xml are:
<?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>com.example</groupId>
<artifactId>websocket</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
You'll need to install Maven to be able to use it. See the Install instructions for more detail.
Once you get Maven installed, change to the directory where your pom.xml file lives and run mvn clean package. This will download files that are needed one time. The next time you build it will not take very long.
The build creates target/websocket-1.0.0.war. This can be deployed to a running Tomcat by copying it to the webapps directory.
You will access this websocket endpoint through http://localhost:8080/websocket/websocketendpoint. The extra path element is because your code is deploy the the websocket web application.
This question already has answers here:
How to force maven update?
(26 answers)
Closed 6 years ago.
I want to learn java spring, so I choose Eclipse Mars2 Version and I want to build a java project using Maven. But I get errors
maven-compiler-plugin:3.1:compile(1 errors)
maven-compiler-plugin:3.1:testCompile(1 errors)
Then I check my maven and java path in my Windows 10 64 bit system variable.
I configured like this :
JAVA_HOME => C:\Program Files\Java\jdk1.8.0_71
M2_HOME => C:\apache-maven
MAVEN_HOME => C:\apache-maven
And in systen variabel path :
%JAVA_HOME%\bin
%M2_HOME%\bin
Everything is fine, I checked it by java -version and mvn-version
Also, I have installed mvn plugin in eclipse in install new software
to maven :
Name: m2e
Location: http://download.eclipse.org/technology/m2e/releases
But I still failed. The errors is still pop up.
Please advise. Thanks.
UPDATE
I test to build a project maven-archetype-quickstart version 1.1
execution default-compile, in Access/pom.xml
execution default-testCompile, in Access/pom.xml
UPDATE AGAIN
<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.tresnamuda</groupId>
<artifactId>access</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>access</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>
</dependencies>
</project>
Eclipse detect error in first line which is :
project xmlns="http://maven.apache.org/POM/4.0.0" .....
also in line 8.
This is the complete error :
It seems like there is corruption in your local repository.
Please try:
Delete the local repository, if you use Windows, delete the folder C:\Users\your-user-name\.m2\repository
In Eclipse, right click on the project name and click Maven\Update project ... (or use hotkey ALT+F5)
I am looking to start a project using Vaadin and I want to use Maven as the repository manager, but I am having a lot of trouble starting the Maven project.
I tried creating a project in IntelliJ using the vaadin-archetype-application-example and it doesn't create any directory.
I also tried creating the project with the mvn commands and I found a lot of troubles too. When I create the Maven project this error is shown in the log:
-Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable and mvn script match.
[ERROR] Maven execution terminated abnormally (exit code 1)
How can I deploy a Maven project with IntelliJ? I have the Maven plugin installed and the mvn command seems to work just fine.
This is 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.imtoolazytoadmin</groupId>
<artifactId>ImTooLazyToAdmin-master</artifactId>
<version>1.0-SNAPSHOT</version>
</project>
Use this command to create your project and then import it to your IDE.
$ mvn archetype:generate \
-DarchetypeGroupId=com.vaadin \
-DarchetypeArtifactId=vaadin-archetype-application \
-DarchetypeVersion=7.5.9 \
-DgroupId=your.company \
-DartifactId=project-name \
-Dversion=1.0 \
-Dpackaging=war
More info about creating Vaadin projects in IntelliJ here.
I start learning packaging for several distros (currently Cygwin and Debian).
They have requirement to build system to allow out-of-tree build (synonym out-of-source build):
http://wiki.debian.org/UpstreamGuide#Out-of-Tree_Builds
To work-around "dumb" build system for example cygport recommend use lndir (from xutils project):
lndir ${S} ${B}
cd {B}
...build-commands...
I read mvn(1) man page but doesn't found anything appropriated. Next I just try:
$ mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
...
$ pwd
/maven/simple
$ ls
my-app
$ mvn -f my-app/pom.xml compile
...
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) # my-app ---
[INFO] Compiling 1 source file to /maven/simple/my-app/target/classes
As you can see target directory created in source root hierarchy while I look for a way to avoid this.
Is it possible out-of-tree build with maven? And how?
You could do like this to get it in your current working directory:
<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.stackoverflow</groupId>
<artifactId>Q13173063</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}-${project.version}</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<buildDir>${user.dir}</buildDir>
</properties>
<build>
<directory>${buildDir}</directory>
</build>
</project>
Then you can issue
mvn -f my-app/pom.xml compile
And it will give you your classes in the current working directory.
And easily change to another output directory:
mvn -f my-app/pom.xml -DbuildDir=/tmp/build compile
It might be as simple as having a
<build>
<directory>/your/build/directory</directory>
</build>
in your pom.xml. /your/build/directory need not be in the source tree and can be parameterized using the usual ${...} syntax.
Cheers,