Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Maven issue #14

Closed
BenRomberg opened this issue Dec 4, 2016 · 4 comments
Closed

Fix Maven issue #14

BenRomberg opened this issue Dec 4, 2016 · 4 comments
Assignees
Labels
Milestone

Comments

@BenRomberg
Copy link

jrestless sounds really promising. Unfortunately it's not straightforward to get it running with Maven.

With the following pom.xml:

    <dependencies>
        <dependency>
            <groupId>com.jrestless.aws</groupId>
            <artifactId>jrestless-aws-gateway-handler</artifactId>
            <version>0.3.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>2.23</version>
        </dependency>
    </dependencies>
    
    <repositories>
        <repository>
            <id>jcenter</id>
            <url>http://jcenter.bintray.com</url>
        </repository>
    </repositories>

The build results in [ERROR] Failed to execute goal on project ***: Could not resolve dependencies for project ***: Could not find artifact org.glassfish.jersey.containers:project:jar:2.23 in jcenter (http://jcenter.bintray.com) -> [Help 1].

The problem is that org.glassfish.jersey.containers:project is being referenced within com.jrestless.core:jrestless-core-container as a dependency. Maven then thinks this is a dependency of type jar, where in fact it is of type pom. When trying to download the corresponding jar file, it gets a 404 from both jcenter and Maven Central and throws the error above.

The following workaround fixes the issue:

    <dependencies>
        <dependency>
            <groupId>com.jrestless.aws</groupId>
            <artifactId>jrestless-aws-gateway-handler</artifactId>
            <version>0.3.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.glassfish.jersey.containers</groupId>
                    <artifactId>project</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.core</groupId>
            <artifactId>jersey-server</artifactId>
            <version>2.23</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>2.23</version>
        </dependency>
    </dependencies>

It would be great if you could fix the dependencies to use jersey-server directly instead of relying on the project parent POM, so that the workaround is no longer needed in future versions. Thanks!

@bbilger bbilger added this to the 0.4.0 milestone Dec 4, 2016
@bbilger
Copy link
Owner

bbilger commented Dec 4, 2016

thanks for reporting!
Your proposed fix sounds reasonable. I will take a look and will fix it ASAP.

@bbilger
Copy link
Owner

bbilger commented Dec 6, 2016

@BenRomberg
I fixed the dependency as suggested by you. I will also add maven examples for the next release.
FYI: the next release is planned for the end of next week.

@bbilger
Copy link
Owner

bbilger commented Dec 19, 2016

@BenRomberg
I updated the examples to work with Maven.
See https://github.com/bbilger/jrestless-examples#build
For example:

git clone https://github.com/bbilger/jrestless-examples.git
cd jrestless-examples
find . -path ./.git -prune -o -name 'serverless.yml' -type f -exec sed -i 's/artifact: build\/distributions\/\([a-z0-9-]\+\)\.zip/artifact: target\/\1.jar/' {} +
cd aws/gateway/aws-gateway-showcase
mvn package
serverless deploy
curl https://YOUR_ID.execute-api.YOUR_REGION.amazonaws.com/dev/api/info

I had some trouble getting the examples running with Maven. In particular I had to configure the Maven shade plugin as follows:

<configuration>
   <createDependencyReducedPom>false</createDependencyReducedPom>
  <!-- http://stackoverflow.com/questions/29107376/jersey-problems-with-maven-shade-plugin -->
  <transformers>
    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
    </transformers>
</configuration>

See https://github.com/bbilger/jrestless-examples/blob/master/pom.xml#L48

Let me know if you have any issues with Maven.

@BenRomberg
Copy link
Author

Thanks @bbilger, works as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants