Maven, tomcat7, Simple Web App. java.lang.LinkageError: loader constraint violation - maven

I'm following directions from book "Introducing Maven, Apress", to create a simple web app: HelloWorld!! in a JSP . With Maven and Tomcat7 and using following artifact: (by the way I'm using win7)
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-webapp
The structure created is as follow:
gswm-web
|_pom.xml
|_src
|_main
|_resources
|_webapp
|_WEB-INF
| |_web.xml
|_index.jsp
And pom.xml looks as below, with a tomcat plug-in added:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.apress.gswmbook</groupId>
<artifactId>gswm-web</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>gswm-web Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>gswm-web</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
</build>
</project>
then I run from command line in root of project following command:
mvn tomcat7:run
And I'm getting following information:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------------------------------------------------
----
[INFO] Building gswm-web Maven Webapp 1.0-SNAPSHOT
[INFO] ---------------------------------------------------------------------
---
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) # gswm-web >>>
Downloading: http://repo.maven.apache.org/maven2/javax/servlet/jsp/jsp-
api/2.1/jsp-api-2.1.pom
Downloaded: http://repo.maven.apache.org/maven2/javax/servlet/jsp/jsp-
api/2.1/jsp-api-2.1.pom
Downloading: http://repo.maven.apache.org/maven2/javax/servlet/jsp/jsp-
api/2.1/jsp-api-2.1.jar
Downloaded: http://repo.maven.apache.org/maven2/javax/servlet/jsp/jsp-
api/2.1/jsp-api-2.1.jar
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # gswm-
web ---
[debug] execute contextualize
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered
resources, i.e. build is
platform dependent!
[INFO] skip non existing resourceDirectory
C:\MauricioFiles\Maven\gswm-book-master\gswm-book-
master\chapter6\final\gswm-web\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # gswm-web
---
[INFO] No sources to compile
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) # gswm-web <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) # gswm-web ---
[INFO] Running war on http://localhost:8080/gswm-web
[INFO] Creating Tomcat server configuration at
C:\MauricioFiles\Maven\gswm-book-master\gswm-book-
master\chapter6\final\gswm-web\target\tomcat
[INFO] create webapp with contextPath: /gswm-web
Jun 03, 2015 1:50:08 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jun 03, 2015 1:50:08 PM org.apache.catalina.core.StandardService
startInternal
INFO: Starting service Tomcat
Jun 03, 2015 1:50:08 PM org.apache.catalina.core.StandardEngine
startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Jun 03, 2015 1:50:12 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
But when I try to display project in browser at port 8080 I'm getting below message:
Jun 03, 2015 1:50:34 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [jsp] in context with path [/gswm-web]
threw exception
[java.lang.LinkageError: loader constraint violation: loader (instance of
org/apache/jasper/servlet/JasperLoader)
previously initiated loading for a different type with name
"javax/servlet/http/HttpServletRequest"]
with root cause
java.lang.LinkageError: loader constraint violation: loader
(instance of org/apache/jasper/servlet/JasperLoader) previously initiated
loading for a different type with name
"javax/servlet/http/HttpServletRequest"
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2688)
at java.lang.Class.getDeclaredMethods(Class.java:1962)
at
org.apache.catalina.util.Introspection.getDeclaredMethods
(Introspection.java:127)
at
org.apache.catalina.core.DefaultInstanceManager.populateAnnotationsCache
(DefaultInstanceManager.java:342)
at org.apache.catalina.core.DefaultInstanceManager.newInstance
(DefaultInstanceManager.java:161)
at org.apache.catalina.core.DefaultInstanceManager.newInstance
(DefaultInstanceManager.java:149)
at org.apache.jasper.servlet.JspServletWrapper.getServlet
(JspServletWrapper.java:172)
at org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:369)
at org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service
(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service
(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:210)
at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke
(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke
(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process
(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process
(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run
(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker
(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Among other things I have tried, doing some research I have added following lines to pom, without success:
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
Does anybody know how could this be fixed?. Thank you alot

Do the same for the javax.servlet-api artifact:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>xxxx</version><!-- Whatever version you are using -->
<scope>provided</scope>
</dependency>
Actually the offending class, HttpServletRequest is in this artifact.

The servlet-api dependency in the pom.xml needed the "provided" scope. This is because Tomcat already provides (requires and uses itself) the servlet-api dependency. Maven's dependency scoping rules are defined here
http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>xxxx</version><!-- Whatever version you are using -->
<scope>provided</scope>
</dependency>

Related

Using maven quarkus:dev target, why would I get an unresolved dep on com.fasterxml.jackson.annotation

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>

jenkins deploy war/ear to a container - why the .war file is renamed before it is deployed on the remoteserver

I'm new to jenkins and have a problem. I created a maven project (maven integration plugin 2.12.1) in jenkins (ver. 1.638). I got the source-code via git (maven web application).
Everything works fine, but at the end the .war which is moved/deployed via deploy plugin to the remote server has a wrong name.
I dont know why the .war file is renamed before it is deployed on the remoteserver.
It is called services.war instead of services_admin.war.
Screenshot jenkins:
https://i.stack.imgur.com/uc5wK.png
pom.xml:
<groupId>services_admin</groupId>[enter image description here][1]
<artifactId>services_admin</artifactId>
<name>services_admin</name>
<description>services_admin</description>
<build>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
<resource>
<directory>${basedir}/src/main/java</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<wtpversion>1.5</wtpversion>
<additionalProjectFacets>
<jst.java>6.0</jst.java>
<jst.web>2.5</jst.web>
</additionalProjectFacets>
<additionalBuildcommands>
<buildcommand>org.eclipse.wst.common.project.facet.core.builder</buildcommand>
<buildcommand>org.eclipse.wst.validation.validationbuilder</buildcommand>
<buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
</additionalBuildcommands>
<additionalProjectnatures>
<projectnature>org.eclipse.wst.common.project.facet.core.nature</projectnature>
<projectnature>org.eclipse.wst.common.modulecore.ModuleCoreNature</projectnature>
<projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
</additionalProjectnatures>
</configuration>
</plugin>
</plugins>
<finalName>services_admin</finalName>
</build>
Build log:
[INFO] ------------------------------------------------------------------------
[INFO] Building services_admin 2
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # services_admin ---
[INFO] Deleting D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # services_admin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 120 resources
[INFO] Copying 307 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:compile (default-compile) # services_admin ---
[INFO] Compiling 307 source files to D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target\classes
[WARNING] D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\src\main\java\de\...\services\java\util\Cryptographer.java:[34,40] BASE64Encoder is internal proprietary API and may be removed in a future release
[WARNING] D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\src\main\java\de\...\services\java\util\Cryptographer.java:[59,39] BASE64Decoder is internal proprietary API and may be removed in a future release
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # services_admin ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.0.2:testCompile (default-testCompile) # services_admin ---
[INFO] Compiling 48 source files to D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) # services_admin ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # services_admin ---
[INFO] Packaging webapp
[INFO] Assembling webapp [services_admin] in [D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target\services_admin]
[INFO] Processing war project
[INFO] Copying webapp resources [D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\src\main\webapp]
[INFO] Webapp assembled in [2328 msecs]
[INFO] Building war: D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target\services_admin.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.360 s
[INFO] Finished at: 2017-01-31T16:00:01+01:00
[INFO] Final Memory: 46M/447M
[INFO] ------------------------------------------------------------------------
Waiting for Jenkins to finish collecting data
[JENKINS] Archiving D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\pom.xml to services_admin/services_admin/2/services_admin-2.pom
[JENKINS] Archiving D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target\services_admin.war to services_admin/services_admin/2/services_admin-2.war
channel stopped
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Deploying D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target\services_admin.war to container Tomcat 7.x Remote
Redeploying [D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target\services_admin.war]
Undeploying [D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target\services_admin.war]
Deploying [D:\Programme_x64\Jenkins\jobs\Mavenproject - services Admin (Test)\workspace\target\services_admin.war]
Finished: SUCCESS
remoteserver log:
Feb 01, 2017 9:50:09 AM org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager] log
INFORMATION: Manager: list: Listing contexts for virtual host 'localhost'
Feb 01, 2017 9:50:09 AM org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager] log
INFORMATION: Manager: deploy: Deploying web application '/services'
Feb 01, 2017 9:50:09 AM org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager] log
INFORMATION: Manager: Uploading WAR file to D:\Programme_x64\tomcat\...\webapps\services.war
Feb 01, 2017 9:50:15 AM org.apache.catalina.startup.HostConfig deployWAR
INFORMATION: Deploying web application archive D:\Programme_x64\tomcat\...\webapps\services.war
Feb 01, 2017 9:50:15 AM org.apache.tomcat.util.digester.Digester begin
WARNUNG: [SetContextPropertiesRule]{Context} Setting property 'antiJARLocking' to 'true' did not find a matching property.
Feb 01, 2017 9:50:24 AM org.apache.jasper.servlet.TldScanner scanJars
INFORMATION: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
Feb 01, 2017 9:50:25 AM org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/services] log
INFORMATION: No Spring WebApplicationInitializer types detected on classpath
Feb 01, 2017 9:50:25 AM org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/services] log
INFORMATION: Set web app root system property: 'OsWebApp.root' = [D:\Programme_x64\tomcat\...\temp\6-services\]
Feb 01, 2017 9:50:25 AM org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/services] log
INFORMATION: Initializing Spring root WebApplicationContext
Feb 01, 2017 9:50:31 AM com.sun.faces.config.ConfigureListener contextInitialized
INFORMATION: Mojarra 2.1.13 ( 20120907-1514) für Kontext '/services' wird initialisiert.
Feb 01, 2017 9:50:32 AM com.sun.faces.spi.InjectionProviderFactory createInstance
INFORMATION: JSF1048: PostConstruct/PreDestroy-Annotationen vorhanden. Verwaltete Bean-Methoden, die mit diesen Annotationen markiert sind, lassen die entsprechenden Annotationen verarbeiten.
Feb 01, 2017 9:50:33 AM com.sun.faces.config.configprovider.BaseWebConfigResourceProvider getResources
WARNUNG: JSF1067: Ressource /WEB_INF/wickedcharts.taglib.xml, die von der Konfigurationsoption javax.faces.CONFIG_FILES angegeben wird, kann nicht gefunden werden. Die Ressource wird ignoriert.
Feb 01, 2017 9:50:33 AM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFORMATION: Running on PrimeFaces 5.3
Feb 01, 2017 9:50:33 AM org.apache.catalina.startup.HostConfig deployWAR
INFORMATION: Deployment of web application archive D:\Programme_x64\tomcat\...\webapps\services.war has finished in 17,323 ms
i dont use the "deploy plugin - deploy war/ear to a container" for this project. Instead of that im using now "Send files to a windows share - CIFS Publishers".
The problem with the "deploy plugin - deploy war/ear to a container" i could solve :(.
Anyway thx for ur help :).
Best regards

HttpSession class not found

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>

Maven Could not resolve dependencies for hadoop project

I wanted to build the sample projects from hadoop book but I got "Could not resolve dependencies error".
Here is my Error during build:
[INFO] Building Chapter 2: MapReduce 3.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.hadoop:hadoop-core:jar:0.23.10 is missing, no dependency information available
[WARNING] The POM for org.apache.hadoop:hadoop-test:jar:0.23.10 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Chapter 2: MapReduce .............................. FAILURE [1.409s]
[INFO] Hadoop: The Definitive Guide, Example Code ........ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.819s
[INFO] Finished at: Wed May 14 12:19:14 EEST 2014
[INFO] Final Memory: 6M/67M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project ch02: Could not resolve dependencies for project com.hadoopbook:ch02:jar:3.0: The following artifacts could not be resolved: org.apache.hadoop:hadoop-core:jar:0.23.10, org.apache.hadoop:hadoop-test:jar:0.23.10: Failure to find org.apache.hadoop:hadoop-core:jar:0.23.10 in https://repository.apache.org/content/repositories/releases/ was cached in the local repository, resolution will not be reattempted until the update interval of apache.releases has elapsed or updates are forced -> [Help 1]
and here is my pom.xml for ch02 project
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.hadoopbook</groupId>
<artifactId>hadoop-meta</artifactId>
<version>3.0</version>
<relativePath>../hadoop-meta/pom.xml</relativePath>
</parent>
<groupId>com.hadoopbook</groupId>
<artifactId>ch02</artifactId>
<packaging>jar</packaging>
<version>3.0</version>
<name>Chapter 2: MapReduce</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
</dependency>
</dependencies>
</project>
Any idea how can I build this code using maven and what the problem is ?
Thanks
What's happening is that Maven can't find the what it is looking for in the remote repository. So when it reaches out to Apache's Maven repository it's just not finding the resources for version 0.23.10 hadoop-test.
Particularly line #8 of the pom file in the question <relativePath>../hadoop-meta/pom.xml</relativePath> is directing Maven to look at hadoop-meta/pom.xml. On line #48 through #50 you'll see the specification for the hadoop-test repository:
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-test</artifactId>
<version>${hadoop.version}</version>
That ${hadoop.version} is the value that you specify in your maven command, ie 0.23.10.
So then maven goes out to the Apache repo and looks for hadoop-test v0.23.10, which isn't present. So then Maven falls over.
Now if you used a version that is present in the hadoop-test, or if you altered the pom files so that hadoop-test isn't a dependency.
I had this problem as well, it turned out it was because of NetBeans adding something to my pom.xml file. Double check nothing was added since previous successful deployments.

Why are Spring log messages listed as [ERROR] when there seem to be no errors?

I have a GWT/Spring application, building with Maven and the gwt-maven-plugin.
When I run
mvn gwt:run
the gwt-maven-plugin runs the application and everything starts up and runs fine. What's bothering me is that the log messages claim [ERROR] on every line even though there are no apparent errors, and no message ever says what the error might be.
My guess is that [ERROR] on every log line is from the gwt-maven-plugin, since what comes after seems to be Spring's log message like so... [ERROR] INFO:
and when I run the app with mvn jetty:run, I see only the INFO: part of the messages.
Attached is most of the log to standard out. Has anybody seen log output like this, or have any ideas about what could cause a plugin to log info messages as error messages?
[INFO] ------------------------------------------------------------------------
[INFO] Building GWT Maven Archetype 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> gwt-maven-plugin:2.4.0:run (default-cli) # gwt >>>
[INFO]
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # gwt ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # gwt ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-war-plugin:2.1.1:exploded (default) # gwt ---
[INFO] Exploding webapp
[INFO] Assembling webapp [gwt] in [/home/jay/workspace/buildtimer/target/gwt-1.0- SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/jay/workspace/buildtimer/src/main/webapp]
[INFO] Webapp assembled in [169 msecs]
[INFO]
[INFO] <<< gwt-maven-plugin:2.4.0:run (default-cli) # gwt <<<
[INFO]
[INFO] --- gwt-maven-plugin:2.4.0:run (default-cli) # gwt ---
[INFO] create exploded Jetty webapp in /home/jay/workspace/buildtimer/target/gwt-1.0- SNAPSHOT
[INFO] auto discovered modules [com.buildtimer.Main]
[ERROR] Nov 14, 2011 7:38:44 PM org.springframework.web.context.ContextLoader initWebApplicationContext
[ERROR] INFO: Root WebApplicationContext: initialization started
[ERROR] Nov 14, 2011 7:38:44 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
[ERROR] INFO: Refreshing Root WebApplicationContext: startup date [Mon Nov 14 19:38:44 EST 2011]; root of context hierarchy
[ERROR] Nov 14, 2011 7:38:44 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
[ERROR] INFO: Loading XML bean definitions from class path resource [META- INF/applicationContext.xml]
[ERROR] Nov 14, 2011 7:38:44 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
[ERROR] INFO: Loading XML bean definitions from class path resource [META- INF/applicationContext-persistence.xml]
[ERROR] Nov 14, 2011 7:38:44 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
[ERROR] INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory#1e42c6e: defining beans [org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.ann otation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.T ransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,tr ansactionManager,buildDao,dataSource,sessionFactory]; root of factory hierarchy
[ERROR] Nov 14, 2011 7:38:45 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassName
[ERROR] INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
[ERROR] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[ERROR] SLF4J: Defaulting to no-operation (NOP) logger implementation
[ERROR] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[ERROR] Nov 14, 2011 7:38:46 PM org.springframework.orm.hibernate3.LocalSessionFactoryBean buildSessionFactory
[ERROR] INFO: Building new Hibernate SessionFactory
[ERROR] Nov 14, 2011 7:38:48 PM org.springframework.orm.hibernate3.LocalSessionFactoryBean updateDatabaseSchema
[ERROR] INFO: Updating database schema for Hibernate SessionFactory
[ERROR] Nov 14, 2011 7:38:48 PM org.springframework.orm.hibernate3.HibernateTransactionManager afterPropertiesSet
[ERROR] INFO: Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource#1b0e438] of Hibernate SessionFactory for HibernateTransactionManager
My web.xml logging configuration is
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
...
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
...
</web-app>
my log4j.properties.xml file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="rootAppender" class="org.apache.log4j.FileAppender" >
<param name="file" value="app.log"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p %c - %m%n"/>
</layout>
</appender>
<root>
<priority value ="warn" />
<appender-ref ref="rootAppender" />
</root>
</log4j:configuration>
Not sure how much it is related, but your log indicates that the SLF4J logging framework is not properly initilaized
[ERROR] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[ERROR] SLF4J: Defaulting to no-operation (NOP) logger implementation
[ERROR] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Make sure that you have all three dependencies in your pom (SLF4J, The log4j binding and log4j itself)
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>compile</scope>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<scope>runtime</scope>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<scope>runtime</scope>
<version>1.2.16</version>
</dependency>

Resources