Javalin: Issue with docker deployment

Created on 27 Jun 2019  路  5Comments  路  Source: tipsy/javalin

NOTE: I am new in docker thing and maven projects (I am an android developer)

I've been trying javalin, and following this tutorial, and met with an error

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project my-javalin: Failed to deploy artifacts/metadata: Cannot access your-snapshot-repo-url with type default using the available connector factories: BasicRepositoryConnectorFactory: Cannot access your-snapshot-repo-url using the registered transporter factories: WagonTransporterFactory: Unsupported transport protocol -> [Help 1]

Here's 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.mygroup</groupId>
    <artifactId>my-javalin</artifactId>
    <version>1.0-SNAPSHOT</version>

    <!-- library dependencies -->
    <dependencies>
        <dependency>
            <groupId>io.javalin</groupId>
            <artifactId>javalin</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.7.26</version>
        </dependency>


    </dependencies>

    <distributionManagement>
        <repository>
            <id>repo</id>
            <name>Internal release</name>
            <url>your-snapshot-repo-url</url>
        </repository>
    </distributionManagement>

    <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>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <!-- Run shade goal on package phase -->
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <shadedArtifactAttached>true</shadedArtifactAttached>
                            <transformers>
                                <!-- add Main-Class to manifest file -->
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>HelloWorld</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>dockerfile-maven-plugin</artifactId>
                <version>1.3.6</version>
                <executions>
                    <execution>
                        <id>default</id>
                        <goals>
                            <goal>build</goal>
                            <goal>push</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <repository>localhost:5000/javalin</repository>
                    <tag>${project.version}</tag>
                    <buildArgs>
                        <JAR_FILE>${project.build.finalName}-shaded.jar</JAR_FILE>
                    </buildArgs>
                </configuration>
            </plugin>

        </plugins>
    </build>


</project>

I think it happened because I didn't give snapshot-repo-url (line#32). I didn't see any replacement for that placeholder in the above mentioned article.

So, what should I replace with your-snapshot-repo-url ?

HELP WANTED QUESTION

All 5 comments

I'm not very familiar with Docker, but I've tagged the question, so hopefully someone else can answer it.

still waiting for response...

So it looks like the tutorial is building the jar and then expecting you to push it to a maven repo somewhere. Most people use maven central, jcenter or an internal enterprise tool like artifactory. I can't just give you a url to put there as you need to set it up yourself. Here is an article explaining it. https://reflectoring.io/bintray-jcenter-maven-central/

That make sense for builds you are releasing to the world, but makes little sense for a personal containers. Instead just create a fat jar of your javalin app, and use the docker command
COPY <location of your jar on local machine> /usr/share/javalin/my-javalin.jar

With Docker I have found that these quick tutorials may get a simple project up a running, but they do little to help you understand what is actually happening. I would read up on some more docker related tutorials. https://medium.com/@wkrzywiec/how-to-put-your-java-application-into-docker-container-5e0a02acdd6b

What are your goals? Do you want to have docker image from built jar, so you can transfer it for deployment. Or you want to have docker environment (application, database, etc) so you can work locally by starting everything easily? I'll provide an example project based on your needs.

Going to close this since it's been inactive for two weeks. Feel free to keep writing in the issue though.

Was this page helpful?
0 / 5 - 0 ratings