I am building a project using groovy on grails 2.3.7. Rather that using the default grails plugins I want to configure the plugins as maven dependencies.
I also want to use jetty server instead of tomcat server and mongodb instead of the regular relational databases.
After creating the project I executed 'grails create-pom' to create the pom.xml file for the project.
I have added the following changes to the pom.xml.
Removed the dependency for hibernate and added the following dependency for mongodb
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>mongodb</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
Removed the default plugin for tomcat and added the following plugin for jetty.
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>jetty</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
<type>zip</type>
</dependency>
I have also configured the repository for grails plugins.
While executing the code I get the following error.
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.mycompany:grails-mongodb-demo:grails-app:0.1
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. # line 200, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building grails-mongodb-demo 0.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # grails-mongodb-demo ---
[INFO] Deleting /mnt/data/Work/Tutorials/Practice/grails/grails-mongodb-demo/target
[INFO] Deleting /mnt/data/Work/Tutorials/Practice/grails/grails-mongodb-demo/plugins (includes = [**/*], excludes = [])
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:clean (default-clean) # grails-mongodb-demo ---
[WARNING] Grails Start with out fork
|Loading Grails 2.3.7
|Configuring classpath
|Running pre-compiled script
.
|Environment set to development
....................
|Application cleaned.
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:validate (default-validate) # grails-mongodb-demo ---
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:init (default-init) # grails-mongodb-demo ---
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:config-directories (default-config-directories) # grails-mongodb-demo ---
[INFO]
[INFO] --- grails-maven-plugin:2.3.7:maven-compile (default-maven-compile) # grails-mongodb-demo ---
[WARNING] Grails Start with out fork
|Loading Grails 2.3.7
|Configuring classpath
|Running pre-compiled script
..........
|Compiling 12 source files
.Error
|
Fatal error during compilation org.apache.tools.ant.BuildException: java.lang.NoClassDefFoundError: javax/servlet/http/HttpSession (Use --stacktrace to see the full trace)
Can anyone please tell me, what plugin I am missing or is there some thing I have configured incorrectly.
Add this to you pom.xml and see if it helps:-
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
Related
A colleague posted a quarkus project to our internal git. When I cloned the repo, and did 'mvn compile quarkus:dev', I get:
$ mvn compile quarkus:dev
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.fnorb.api:rest-cloudpoc >------------------
[INFO] Building rest-cloudpoc 0.1
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # rest-cloudpoc ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # rest-cloudpoc ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 30 source files to C:\Bitbucket\INT\java-rest-cloudpoc\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Bitbucket/INT/java-rest-cloudpoc/src/main/java/com/fnorb/api/rest/cloudpoc/beans/DeriveTemplate.java:[4,40] package com.fasterxml.jackson.annotation does not exist
The "fasterxml.jackson.annotation" line is repeated N times, capped at 100.
There are also instances of
[ERROR] /C:/Bitbucket/INT/java-rest-cloudpoc/src/main/java/com/fnorb/api/rest/cloudpoc/beans/ObjectType.java:[18,2] cannot find symbol
symbol: class JsonInclude
The dep tree shows:
[INFO] +- io.quarkus:quarkus-resteasy:jar:1.4.2.Final:compile
[INFO] | +- io.quarkus:quarkus-vertx-http:jar:1.4.2.Final:compile
....
[INFO] | | +- io.quarkus:quarkus-vertx-core:jar:1.4.2.Final:compile
[INFO] | | | +- io.quarkus:quarkus-netty:jar:1.4.2.Final:compile
....
[INFO] | | | \- io.vertx:vertx-core:jar:3.8.5:compile
....
[INFO] | | | \- com.fasterxml.jackson.core:jackson-core:jar:2.10.3:compile
Is this just a misconfiguration of my host systems? Tried on Win10 and Ubuntu 18.04 headless (Linux subsystem for Windows) and Ubuntu 18.04.4 LTS native.
Technology evidenced above (ie, like 'beans') of which I have added no commentary, assume I have no knowledge of that particular technology. If you think this is related to the problem -- great! but will need hand-holding if you need me to do something with them. Don't just say "huh beans. You need to frog blast the vent core, the reticulator dependency hasn't been frinosticated yet" because I will just nod, rub my chin, shrug and try very hard not to tsk you. Thanky.
Please tell me I missed a step someplace!
Edit 1: Request for POM dependencies
<version>0.1</version>
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<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>
<quarkus-plugin.version>1.4.2.Final</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.4.2.Final</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
And request for imports in the imports from one of the relevant files:
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
No, no, your hosts are not misconfigured. Maven projects normally work out-of-the-box if they themselves are set up right.
First of all, the com.fasterxml.jackson.annotation package is not in the jackson-core dependency but instead in the jackson-annotations package.
If you're using Quarkus, you'll get the jackson-annotations dependency indirectly if you're using for example quarkus-smallrye-openapi. But to me it seems like the class DeriveTemplate in your project imports something from com.fasterxml.jackson.annotation, so the jackson-annotations should be declared as dependency directly in your pom.xml.
If this doesn't help you, you should post your pom.xml as well as the imports section of DeriveTemplate here.
Hope, I didn't vent the frog capacitor too much ;-)
Most likely, the missing dependency will look like:
<dependency>
<groupId>com.fasterxml</groupId>
<artifactId>jackson-annotations<artifactId>
<version>${your-desired-jackson-version}</version>
</dependency>
I am working on resolving duplicate dependency issue. While solving I come to know that using dependency graph it will be easy. But I am not getting how to print a dependency Graph in STS4.
I have tried this command which I found in Maven Documentation
mvn dependency:tree -Dverbose -Dincludes=commons-collections
which is resulting :
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # attache-ui-web ---
[WARNING] Invalid POM for com.apple.ist.msol.attache:attache-api-entity:jar:3.0.0-SNAPSHOT, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] Invalid POM for com.apple.ist.msol.attache:attache-api-entity:jar:3.0.0-SNAPSHOT, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 10.972 s
[INFO] Finished at: 2019-09-17T09:30:23+05:30
[INFO] ------------------------------------------------------------------------
Can someone explain what does this result exactly mean and how to get dependency tree ?
When you open the pom.xml file in Eclipse/STS3/STS4, there is a tab to list all the dependencies as well as a tab for the dependency hierarchy. It shows you all the dependencies that you declared in your project as root nodes and their transitive dependencies as sub-nodes.
I am using Maven 3 to build my java EAR and Jenkins as CI tool. My maven project is multi-module project that builds a jar, war and EAR.
I am using maven-version-plugin:use-latest-versions goal to update the war dependency in my EAR POM during clean phase.
This updates war dependency version to latest(19.3) version in EAR POM but fails to package the latest WAR(19.3) to EAR.
Maven is using the old version(19.2) of WAR during EAR packaging.How do I configure maven to use latest built dependency?
Thank you in advance
Jenkins Console Output
--- maven-clean-plugin:2.5:clean (default-clean) # EAR ---
[INFO] Deleting EAR\target
[INFO]
[INFO] --- versions-maven-plugin:2.1:use-latest-versions (update-dependency-versions) # EAR ---
[INFO] Major version changes allowed
Props: {project.version=19.3-SNAPSHOT, project.artifactId=EAR, project.groupId=gov.dwd.uplink}
**Updating dependency version from 19.2 to 19.3 in EAR POM**
**[INFO] Updated groupId:App:war:19.2-SNAPSHOT to version 19.3-SNAPSHOT**
[INFO]
[INFO] --- maven-ear-plugin:2.8:generate-application-xml (default-generate-application-xml) # AppEAR ---
[INFO] Generating application.xml
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # AppEAR ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory EAR\src\main\resources
[INFO]
[INFO] --- maven-ear-plugin:2.8:ear (default-ear) # AppEAR ---
**[INFO]Copying artifact [war:groupid:App:19.2-SNAPSHOT] to [App.war]**
This should copy 19.3 not 19.2 version
[INFO] Could not find manifest file: AppEAR\target\AppEAR-19.3-SNAPSHOT\META-INF\MANIFEST.MF - Generatingone
[INFO] Building jar: AppEAR\target\App.ear
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # AppEAR ---
[INFO] Installing AppEAR\target\App.ear to maven_repo2\GroupID\AppEAR\19.3-SNAPSHOT\AppEAR-19.3-SNAPSHOT.ear
[INFO] Installing AppEAR\pom.xml to D:\CCViews\maven_repo2\GroupID\AppEAR\19.3-SNAPSHOT\AppEAR-19.3-SNAPSHOT.pom
[INFO]
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
[JENKINS] Archiving disabled
Here is how I fixed my issue with incrementing dependency versions.
I used maven-version-plugin:update-versions to increment the POM version number. Then for dependencies version I used ${project.version}. This keeps POM versions's and dependencies always in sync which helps in CI environment.
Please post if you have a better solution.
I can't remember what I did to cause this problem. When I try to run mvn clean install, I get the following output:
mvn clean install
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building search Maven Webapp 1.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.slf4j:slf4j-api:jar:12.1.2 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.895 s
[INFO] Finished at: 2014-05-29T21:55:34+02:00
[INFO] Final Memory: 6M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project search: Could not resolve dependencies for project com.ws:search:war:1.0: Failed to collect dependencies at com.oracle.weblogic:weblogic-server-pom:pom:12.1.2-0-0 -> com.oracle.weblogic:com.oracle.state-management.e
xecutor-internal-api_12.1.2:jar:12.1.2: Failed to read artifact descriptor for com.oracle.weblogic:com.oracle.state-management.executor-internal-api_12.1.2:jar:12.1.2: Failure to find com.oracle.state-management:state-management-parent:pom:1.0.0-SNAPSHOT in http://10.68
.20.32:8081/artifactory/libs-snapshot was cached in the local repository, resolution will not be reattempted until the update interval of snapshots has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
The attempt to find com.oracle.state-management.executor-internal-api_12.1.2:jar:12.1.2 (Note the version: 12.1.2) fails because it originates from the dependency com.oracle.state-management.executor-internal-api_12.1.2 (version 12.1.2 too) while this dependency's pom has the following portion:
<parent>
<artifactId>state-management-parent</artifactId>
<groupId>com.oracle.state-management</groupId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../parent/pom.xml</relativePath>
</parent>
What surprises me is that there is another version for this dependency (com.oracle.state-management.executor-internal-api_12.1.2) which is 12.1.2-0-0, I believe that this is the right version to refer to, not 12.1.2
What I think supports my assumption is that the output mentions that it failed to find sfl4j dependency with the version 12.1.2 !!
[WARNING] The POM for org.slf4j:slf4j-api:jar:12.1.2 is missing, no dependency information available
I refer to weblogic's dependency this way
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-server-pom</artifactId>
<version>12.1.2-0-0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
How can I fix that ?
For some unearthly reason, weblogic's dependency
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-server-pom</artifactId>
<version>12.1.2-0-0</version>
<type>pom</type>
<scope>provided</scope>
</dependency>
had the following version for it's dependencies
<dependency>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>[12.1.2,12.1.3)</version>
</dependency>
To resolve this, I replaced all [12.1.2,12.1.3) occurrences with 12.1.2-0-0 and now I can install my project again.
I would really appreciate it if someone tells me why was the POM generated this way ?!
I'm suffering an issue similar to Maven 2 - different dependency versions in test and compile but the specified answer there does not work.
In my project I need to depend on a Cloudera distribution of Hadoop and a 'vanilla' version for JUnit testing, as the former only works on *nix.
When I try and execute my application, I get Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/conf/Configuration. When I run JUnit tests from Maven or Eclipse, everything works fine. If I comment out the test dependencies, the application runs successfully.
Why is the compile dependency getting ignored when the test dependency is uncommented?
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>0.20.2-cdh3u2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-test</artifactId>
<version>1.0.0</version>
<scope>test</scope>
</dependency>
mvn dependency:list is shown below. The compile scoped version does not show up at all:
[INFO] The following files have been resolved:
[INFO] ant:ant:jar:1.6.5:test
[INFO] aopalliance:aopalliance:jar:1.0:compile
[INFO] asm:asm:jar:3.3.1:compile
[INFO] cglib:cglib:jar:2.2.2:compile
[INFO] ch.qos.logback:logback-classic:jar:1.0.0:compile
[INFO] ch.qos.logback:logback-core:jar:1.0.0:compile
[INFO] com.google.guava:guava:jar:r08:compile
[INFO] com.h2database:h2:jar:1.3.164:test
[INFO] com.jolbox:bonecp:jar:0.7.1.RELEASE:compile
[INFO] com.sun.jersey:jersey-core:jar:1.11:test
[INFO] commons-beanutils:commons-beanutils:jar:1.7.0:test
[INFO] commons-beanutils:commons-beanutils-core:jar:1.8.0:test
[INFO] commons-cli:commons-cli:jar:1.2:test
[INFO] commons-codec:commons-codec:jar:1.4:test
[INFO] commons-collections:commons-collections:jar:3.2.1:test
[INFO] commons-configuration:commons-configuration:jar:1.6:test
[INFO] commons-digester:commons-digester:jar:1.8:test
[INFO] commons-el:commons-el:jar:1.0:test
[INFO] commons-httpclient:commons-httpclient:jar:3.0.1:test
[INFO] commons-lang:commons-lang:jar:2.4:test
[INFO] commons-logging:commons-logging:jar:1.1.1:compile
[INFO] commons-net:commons-net:jar:1.4.1:test
[INFO] hsqldb:hsqldb:jar:1.8.0.10:test
[INFO] junit:junit:jar:4.10:test
[INFO] mysql:mysql-connector-java:jar:5.1.18:compile
[INFO] net.java.dev.jets3t:jets3t:jar:0.7.1:test
[INFO] net.sf.kosmosfs:kfs:jar:0.3:test
[INFO] org.apache.commons:commons-math:jar:2.1:test
[INFO] org.apache.ftpserver:ftplet-api:jar:1.0.0:test
[INFO] org.apache.ftpserver:ftpserver-core:jar:1.0.0:test
[INFO] org.apache.ftpserver:ftpserver-deprecated:jar:1.0.0-M2:test
[INFO] org.apache.hadoop:hadoop-core:jar:1.0.0:test
[INFO] org.apache.hadoop:hadoop-test:jar:1.0.0:test
[INFO] org.apache.mina:mina-core:jar:2.0.0-M5:test
[INFO] org.codehaus.jackson:jackson-core-asl:jar:1.0.1:test
[INFO] org.codehaus.jackson:jackson-mapper-asl:jar:1.0.1:test
[INFO] org.eclipse.jdt:core:jar:3.1.1:test
[INFO] org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] org.liquibase:liquibase-core:jar:2.0.3:test
[INFO] org.liquibase.ext:liquibase-slf4j:jar:0.0.1:test
[INFO] org.mortbay.jetty:jetty:jar:6.1.26:test
[INFO] org.mortbay.jetty:jetty-util:jar:6.1.26:test
[INFO] org.mortbay.jetty:jsp-2.1:jar:6.1.14:test
[INFO] org.mortbay.jetty:jsp-api-2.1:jar:6.1.14:test
[INFO] org.mortbay.jetty:servlet-api:jar:2.5-20081211:test
[INFO] org.mortbay.jetty:servlet-api-2.5:jar:6.1.14:test
[INFO] org.slf4j:jcl-over-slf4j:jar:1.6.4:compile
[INFO] org.slf4j:log4j-over-slf4j:jar:1.6.4:compile
[INFO] org.slf4j:slf4j-api:jar:1.6.4:compile
[INFO] org.springframework:spring-aop:jar:3.1.1.RELEASE:compile
[INFO] org.springframework:spring-asm:jar:3.1.1.RELEASE:compile
[INFO] org.springframework:spring-beans:jar:3.1.1.RELEASE:compile
[INFO] org.springframework:spring-context:jar:3.1.1.RELEASE:compile
[INFO] org.springframework:spring-context-support:jar:3.1.1.RELEASE:compile
[INFO] org.springframework:spring-core:jar:3.1.1.RELEASE:compile
[INFO] org.springframework:spring-expression:jar:3.1.1.RELEASE:compile
[INFO] org.springframework:spring-jdbc:jar:3.1.1.RELEASE:compile
[INFO] org.springframework:spring-test:jar:3.1.1.RELEASE:test
[INFO] org.springframework:spring-tx:jar:3.1.1.RELEASE:compile
[INFO] org.springframework.data:spring-data-hadoop:jar:1.0.0.BUILD-SNAPSHOT:c
ompile
[INFO] oro:oro:jar:2.0.8:test
[INFO] tomcat:jasper-compiler:jar:5.5.12:test
[INFO] tomcat:jasper-runtime:jar:5.5.12:test
[INFO] xmlenc:xmlenc:jar:0.52:test
What you desire, is no longer valid for Maven 3 (this used to be valid for Maven 2). Maven 3 will attempt to obtain the nearest dependency, effectively ensuring that only one of the compile or test scoped dependency is used for both the compile and test phases.
In your case org.apache.hadoop:hadoop-core:1.0.0:test overrides org.apache.hadoop:hadoop-core:0.20.2-cdh3u2:compile and hence becomes the nearest dependency. You may see the following warning displayed by Maven when running the mvn dependency:list goal, that alludes to this being a problem in your project model:
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be
unique: org.apache.hadoop:hadoop-core:jar -> version 0.20.2-cdh3u2 vs 1.0.0 # line xyz, column xyz
To 'fix' this, it would be better to split your tests into a separate project whose project model can define a separate set of test dependencies.
Looks like a maven bug - or if not, something that is fishy enough I wouldn't trust the documentation if there were any.
In your case, I would probably:
upgrade maven and see if the issue is fixed in the latest m3
try repackaging one of the hadoop versions with another artifact id or group name. maven-shade-plugin, don't bother changing the package name, but just introduce something maven won't know is no different from org.apache.hadoop:hadoop-core
try moving the tests to a separate project downstream
start debugging maven and understand what's going on exactly (and then fall back on 1 or 2...)