Search code examples
javaherokuspark-java

Can't deploy SparkJava program on Heroku , getting Insufficient privileges error


I have a simple sparkJava endpoint, i am trying to deploy it on Heroku but i am getting the following error.

Failed to deploy application: Insufficient privileges to "spark-heroku-example" statuscode:403 responseBody:{"id":"forbidden","message":"You do not have access to the app spark-heroku-example."}

Here is my maven:

<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://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>com.haseeb</groupId>
  <artifactId>reactive-multi</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <dependencies>
    
    <dependency>
      <groupId>com.twilio.sdk</groupId>
      <artifactId>twilio</artifactId>
      <version>8.26.0</version>
    </dependency>

    <dependency>
      <groupId>com.sparkjava</groupId>
      <artifactId>spark-core</artifactId>
      <version>2.9.3</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <descriptorRefs>
            <!-- This tells Maven to include all dependencies -->
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
          <archive>
            <manifest>
              <mainClass>Main</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.heroku.sdk</groupId>
        <artifactId>heroku-maven-plugin</artifactId>
        <version>2.0.3</version>
        <configuration>
          <jdkVersion>1.8</jdkVersion>
          <appName>spark-heroku-example</appName>
          <processTypes>
            <!-- Tell Heroku how to launch your application -->
            <web>java -jar ./target/my-app-1.0-jar-with-dependencies.jar</web>
          </processTypes>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Solution

  • Your pom.xml is irrelevant. This error has nothing to do with the code you are trying to deploy.

    You do not have access to the app spark-heroku-example.

    You are trying to deploy to the Heroku app spark-heroku-example. Do you own that app? Did you create it, or have you been invited to contribute to it? Probably not.

    I guess you are following this tutorial but missed or misread this step:

    heroku create spark-heroku-example #choose your own application name
    

    The author chose and registered the name spark-heroku-example. You need to pick another name (or you can let Heroku pick a name for you by simply running heroku create without any arguments).

    Make sure to use your app's name everywhere the author uses spark-heroku-example in the tutorial.