I want to use a JWT library in Lagom but I'm not certain what library to use. I use Lagom with the Java api.
I found:
Java libraries, but they are all exposed through gradle
Scala libraries, but I'm not sure how to use them when I make use of the Java api in Lagom.
Any help?
I guess that using Maven would be the most obvious solution since Lagom supports it now.
Alternatively I'd guess there would be a way to integrate a scala plugin, build with sbt and link the Java code after compilation.
I also encountered this problem, and after a long search and long time spent in this problem, I decided to implement my own mechanism while relying on the oAuth2 standard. I understood the mechanism of oAuth2 and I made my own authentication module. It is not difficult to implement
My previous answer was wrong.
There are two better options:
1) Add the library jar manually as unmanaged dependency in the lib folder
2) https://alvinalexander.com/scala/how-use-maven-repository-library-with-scala-sbt
Quoted:
In your build.sbt:
libraryDependencies += groupID % artifactID % revision
For example:
<dependency>
<groupId>net.sourceforge.htmlcleaner</groupId>
<artifactId>htmlcleaner</artifactId>
<version>2.2</version>
</dependency>
Becomes:
libraryDependencies += "net.sourceforge.htmlcleaner" % "htmlcleaner" % "2.2"
As mentioned in other recipes, because SBT and Maven both use Apache Ivy under > the covers, and SBT also uses the standard Maven2 repository as a default
resolver, SBT users can easily use Java libraries that are packaged for Maven.
Glad that I will be able to use sbt after all! :-)
Related
I have a spring boot application with maven.
I need to use an external jar say "tp.jar". I have used the method of system scope to do the same but seems it has been deprecated. Is there any better alternative which doesn't involve running maven commands to do the same. I found some solutions here Can I add jars to maven 2 build classpath without installing them?
But the posts are pretty old was wondering if any new solution and convenient solution has been found.
If you are in a company doing Java, you probably have a Nexus or Artifactory server running. This is the place to put the jar. Then you can use all Maven mechanisms to use it.
while working on spring mvc 4, how to find the jar for offline project like the jar Spring Security Config,spring-security-web for spring 4 ... etc as thet are not available with default package of jars and I do not want to use maven at this time so where one can find the jar for spring 4
?
First of all, foregoing proper dependency management is a bad idea and will make development that much harder, especially when it comes to transitive dependency resolving.
However, if you really want to do it then you can download .jars straight from Maven Repository or any other online repo that hosts them.
If that fails then a Google search will give you some source to download them from.
Trying to avoid a dependency management tool that to with a framework like Spring which complements many other frameworks is a bad idea in the long run. It will be painful to upgrade the versions in future.
But if you still don't want to use maven/gradle kind of build tool, just use pom.xml/build.gradle just for onetime use and let maven/gradle download all the dependencies and copy all those jars in some folder of your code.
Again I strongly suggest to use a build tool, especially for Spring. Maven/Gradle are not that bad if you don't want to do crazy things!!
I have a GWT project with the following dependencies
<dependency>
<groupId>com.google.gwt.inject</groupId>
<artifactId>gin</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>net.sourceforge.owlapi</groupId>
<artifactId>owlapi-distribution</artifactId>
<version>4.0.2</version>
</dependency>
gin 2.1.2 depends on guice 3.0 while owlapi 4.0.2 depends on guice 4.0-beta.
gin is used on the client side while owlapi is used on the server side.
Compilation fails when I force guice 4.0-beta to be used. Caused by java.lang.ClassNotFoundException: com.google.inject.internal.util.$Maps
Compilation succeeds when I force guice 3.0 to be used, but fails at run-time caused by java.lang.ClassNotFoundException: com.google.inject.internal.guava.collect.$ImmutableList
Downgrading the version of owlapi is not an option.
What options do I have to make this work? Can I use dependency scopes somehow while still retaining a functioning GWT DevMode?
Split your project in distinct modules. Given Maven's limited (by design) dependency scoping options, this is really the way to go.
Use one module for client-side code, using only client dependencies (GIN with Guice 3), and one module for server-side code, using only server dependencies (OWLAPI with Guice 4); and have your client module compile your code to JS and package them as a WAR, that you can use as an "overlay" in the server module (or possibly use a third module that depends on both client and server if you prefer). If you have shared code, use a third/fourth shared module that both client and server modules depend on; the shared module would call maven-source-plugin's jar-no-fork goal so the client module could depend on the shared sources.
You can find archetypes following this approach at https://github.com/tbroyer/gwt-maven-archetypes. They use my Maven Plugin for GWT, but earlier versions (you'd have to clone and mvn install the project then from the appropriate commit) relied on Mojo's Maven Plugin for GWT (my plugin is designed with multi-module projects in mind, and removed a lot of hacks that were needed previously when using Mojo's plugin).
This is a complex scenario for my maven experience with scopes for dependencies.
Given that the error you get mentions guava, you may get lucky forcing the latest guava to be used - owlapi should work with 17 or 18.
Another option might be to try and recompile gin with guice 4 (and maybe contribute the changes upstream). I've got no idea how hard this can be though. You'd also have to ensure your snapshots are released with your app and accessible to others in your team who might need them.
For what it's worth. I spent a few minutes and "ported" it over to guice 4.0. Luckily it was pretty easy. I mavenized it otherwise there were virtually no changes to the code base.
https://github.com/chinshaw/google-gin
I am working in a new project that is going to use Java EE 7 with WildFly, but I am still confused about which maven dependencies I should use.
I have found these two groups that apparently I can use: org.wildfly.bom and org.jboss.spec
They have the following predefined artifact to use in the projects (searched in https://repository.jboss.org/nexus/index.html#welcome):
org.wildfly.bom:
jboss-javaee-7.0-with-all
jboss-javaee-7.0-with-hibernate
jboss-javaee-7.0-with-tools
jboss-bom-parent
jboss-javaee-7.0-with-transactions
jboss-javaee-7.0-with-security
jboss-javaee-7.0-with-resteasy
jboss-javaee-7.0-with-infinispan
jboss-javaee-7.0-with-hibernate3
org.jboss.spec:
jboss-javaee-all-7.0
jboss-javaee-web-7.0
jboss-javaee-7.0
Also I have realized that that I can see dependency Hierarchy using org.jboss.spec but not with wildfly.bom. So, my question is what is the difference?, which one do you suggest?
The org.wildfly.bom includes dependencies for the versions of Hibernate, RESTEasy, etc. as well as their dependencies that are used in WildFly. For if you use Jackson2 annotations the org.wildfly.bom:jboss-javaee-7.0-with-resteasy should include the correct version of the Jackson2 dependency.
The org.jboss.spec only include the Java EE 7 API's used.
If you're not using anything specific to WildFly then I would use the org.jboss.spec BOM. If you're using something specific that the server includes, like Jackson2, Infinispan, etc., then I'd use the org.wildfly.bom.
I'm using Maven 3.0.4 and Axis2 1.5.1 plugin. I've a problem with the generation of a stub class using AXIS2 plugin on Maven.
Depending on the JDK currently configured on the build environment, AXIS2 plugin generates a different stub class source code. I've tried the generation using JDK 1.6 and then JDK 1.7.
Is there any way to "force" the JDK (i.e. 1.6) used by the AXIS2 plugin inside Maven (without changing environment)? (I would like to have a code generation independent from the environment)
Any help will be much appreciated.
I assume you select your JDK like described here :
http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html
Then, I would generate the stub using a different profile, allowing you to override some configuration, but keeping the benefits of your overall conf.
Unfortunately, all my attempts are unsuccessful.
I have to resign myself to what I was shown in another post (http://maven.40175.n5.nabble.com/Maven-amp-Axis2-plugin-different-stub-code-generation-tc5730726.html ): if I really require this type of functionality, I may have to do this work yourself. Otherwise ask Axis2 devs if someone
will volunteer to do it.