2016-02-04

maven configuration of the deploy on websphere and tomcat

<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.kropla</groupId>
<artifactId>testApp</artifactId>
<version>1.0.5-SNAPSHOT</version>
<packaging>war</packaging>


<scm>
<connection>scm:git:git://kropla/repo/testApp-nomvnstructure.git</connection>
<developerConnection>scm:git:ssh://git@10.215.121.78/home/git/repo/testApp-nomvnstructure.git</developerConnection>
<url>scm:git:ssh://git@10.215.121.78/home/git/repo/testApp-nomvnstructure.git</url>
<tag>v1.0.1</tag>
</scm>

<dependencies>

<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-ace</artifactId>
<version>3.3.0</version>
<exclusions>
<exclusion>
<artifactId>mail</artifactId>
<groupId>javax.mail</groupId>
</exclusion>
<exclusion>
<artifactId>jsp-api</artifactId>
<groupId>javax.servlet.jsp</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.icefaces</groupId>
<artifactId>icefaces-compat</artifactId>
<version>3.3.0</version>
</dependency>

<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>0.5.4</version>
</dependency>



<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.1.21</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.21</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.21</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>



<dependency>
<groupId>com.sun</groupId>
<artifactId>PDFRenderer</artifactId>
<version>0.9.1</version>
</dependency>


<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6.12</version>
</dependency>

<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>1.5.0</version>
<exclusions>
<exclusion>
<artifactId>activation</artifactId>
<groupId>javax.activation</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
<exclusions>
<exclusion>
<artifactId>axis-jaxrpc</artifactId>
<groupId>org.apache.axis</groupId>
</exclusion>
<exclusion>
<artifactId>axis-saaj</artifactId>
<groupId>org.apache.axis</groupId>
</exclusion>
<exclusion>
<artifactId>axis-wsdl4j</artifactId>
<groupId>axis</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>javax.xml</groupId>
<artifactId>jaxrpc</artifactId>
<version>1.1</version>
</dependency>


<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.3.0.GA</version>
<exclusions>
<exclusion>
<artifactId>dom4j</artifactId>
<groupId>dom4j</groupId>
</exclusion>
<exclusion>
<artifactId>antlr</artifactId>
<groupId>antlr</groupId>
</exclusion>
<exclusion>
<artifactId>jta</artifactId>
<groupId>javax.transaction</groupId>
</exclusion>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.4.3</version>
</dependency>

<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>5.2.0</version>
<exclusions>
<exclusion>
<artifactId>bctsp-jdk14</artifactId>
<groupId>org.bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>bcmail-jdk14</artifactId>
<groupId>bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>bcprov-jdk14</artifactId>
<groupId>bouncycastle</groupId>
</exclusion>
<exclusion>
<artifactId>castor</artifactId>
<groupId>org.codehaus.castor</groupId>
</exclusion>
<exclusion>
<artifactId>commons-beanutils</artifactId>
<groupId>commons-beanutils</groupId>
</exclusion>
<exclusion>
<artifactId>jackson-annotations</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
<exclusion>
<artifactId>jackson-core</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
<exclusion>
<artifactId>jackson-databind</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
</exclusion>
<exclusion>
<artifactId>jcommon</artifactId>
<groupId>jfree</groupId>
</exclusion>
<exclusion>
<artifactId>jdtcore</artifactId>
<groupId>eclipse</groupId>
</exclusion>
<exclusion>
<artifactId>jfreechart</artifactId>
<groupId>jfree</groupId>
</exclusion>
<exclusion>
<artifactId>xml-apis</artifactId>
<groupId>xml-apis</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.3</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.8</version>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.9.5</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>

<dependency>
<groupId>com.github.dblock.waffle</groupId>
<artifactId>waffle-tomcat8</artifactId>
<version>1.7.4</version>
</dependency>

</dependencies>

<build>
<finalName>testApp</finalName>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<!-- You may have a different path for your properties file -->
<directory>${basedir}/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>

<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>

<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<goals>install</goals>
<tagNameFormat>v@{project.version}</tagNameFormat>
<autoVersionSubmodules>true</autoVersionSubmodules>
<!-- do not release profile from Maven super pom -->
<useReleaseProfile>false</useReleaseProfile>
<!-- instead use our own one called release, see below -->
<releaseProfiles>release</releaseProfiles>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>was</id>
<build>
<plugins>
<plugin>
<groupId>com.orctom.mojo</groupId>
<artifactId>was-maven-plugin</artifactId>
<version>1.0.9</version>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<wasHome>${env.WAS_HOME}</wasHome>
<applicationName>${project.build.finalName}</applicationName>
<host>localhost</host>
<server>server1</server>
<node>SOFT-003Node01</node>
<virtualHost>default_host</virtualHost>
<contextRoot>/${project.build.finalName}</contextRoot>
<verbose>true</verbose>
<sharedLibs>jsf21</sharedLibs>
<parentLast>true</parentLast>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>tomcat</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:8080/manager/text</url>
<server>tomcat7</server>
<path>/testApp</path>

</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

2014-07-07

Logback colors

Coloring in Logback

Grouping by parentheses as explained above allows coloring of sub-patterns. As of version 1.0.5, PatternLayout recognizes "%black", "%red", "%green","%yellow","%blue", "%magenta","%cyan", "%white", "%gray", "%boldRed","%boldGreen", "%boldYellow", "%boldBlue", "%boldMagenta""%boldCyan", "%boldWhite" and "%highlight" as conversion words. These conversion words are intended to contain a sub-pattern. Any sub-pattern enclosed by a coloring word will be output in the specified color.

Below is a configuration file illustrating coloring. Note the %cyan conversion specifier enclosing "%logger{15}". This will output the logger name abbreviated to 15 characters in cyan. The %highlight conversion specifier prints its sub-pattern in bold-red for events of level ERROR, in red for WARN, in BLUE for INFO, and in the default color for other levels.

Example: Highlighting levels (logback-examples/src/main/java/chapters/layouts/highlighted.xml) View as .groovy


<configuration debug="true">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- On Windows machines setting withJansi to true enables ANSI
         color code interpretation by the Jansi library. This requires
         org.fusesource.jansi:jansi:1.8 on the class path.  Note that
         Unix-based operating systems such as Linux and Mac OS X
         support ANSI color codes by default. -->
<withjansi>true</withJansi>
<encoder>
<pattern>[%thread] %highlight(%-5level) %cyan(%logger{15}) - %msg %n</pattern>
</encoder>
</appender>
<root level="DEBUG">
<appender-ref ref="STDOUT" />
</root>
</configuration>



Here is the corresponding output:

[main] WARN c.l.TrivialMain - a warning message 0
[main] DEBUG c.l.TrivialMain - hello world number1
[main] DEBUG c.l.TrivialMain - hello world number2
[main] INFO c.l.TrivialMain - hello world number3
[main] DEBUG c.l.TrivialMain - hello world number4
[main] WARN c.l.TrivialMain - a warning message 5
[main] ERROR c.l.TrivialMain - Finish off with fireworks

It takes very few lines of code to create a coloring conversion word. The section entitled creating a custom conversion specifier discusses the steps necessary for registering a conversion word in your configuration file.

2014-03-09

spring 3.x +hibernate 4

test out div
test in div
pom.xml:

 4.0.0
 pl.kropladev
 spring-hibernate
 0.0.1-SNAPSHOT
 war
 

  
  1.6
  UTF-8
  1.6
  3.0
 
  
  2.2
  1.2
  2.5

  
  3.2.6.RELEASE
  1.5.0.RELEASE

  
  11.2.0.4

  
  4.1.5.Final
  4.2.0.Final

  
  1.0.13
  1.7.5

  
  4.11


 

 
  
   
    maven-compiler-plugin
    ${maven.version}
    
     ${compiler.version}
     ${compiler.version}
    
   

  
 
 
 
  
  
   org.springframework
   spring-context-support
   ${spring-framework.version}
  

  
  
   com.oracle
   ojdbc5
   ${oracle.ojdbc.version}
  

  
   org.springframework
   spring-jdbc
   ${spring-framework.version}
  

  
   org.springframework.data
   spring-data-jpa
   ${spring-jpa.version}
  

  
  
   org.springframework
   spring-orm
   ${spring-framework.version}
  
  
   
    org.hibernate
    hibernate-core
    ${hibernate.version}
   
  
   
    org.hibernate
    hibernate-validator
    ${hibernate-validator.version}
   
  
  

   
    org.slf4j
    slf4j-api
    ${slf4j.version}
    compile
   

   
    ch.qos.logback
    logback-classic
    ${logback.version}
    runtime
   

   
    commons-dbcp
    commons-dbcp
    1.4
   

   
   
    junit
    junit
    ${junit.version}
    test
   

   
    javax.servlet
    servlet-api
    ${servlet.version}
   

 



repository.xml:



  

  
    
    
    
      
        org.hibernate.dialect.Oracle10gDialect
        true
      
    
  

  
  
    
   



2014-03-06

Eclipse jstl errors

The error message: 

Can not find the tag library descriptor for “http://java.sun.com/jsp/jstl/core”

 Overview: 

JSTL (JSP Standard Tag Library) is a JSP based standard tag library which offers tags usefull for page creation.
The jstl/core resides in jstl jar package. Till version 1.0 it was placed inside the main directory and definition to it was:
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>

 From version 1.1 the correct definition is:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

Solution: 

In the project preferences check the Target servers settings. When those settings are ok, try to remove and add one more time the server.

more details:
http://stackoverflow.com/tags/jstl/info

2014-02-23

Spring mvc framework context loaded twice??

Context

I have developed the simple scheduler (task timer) application using spring framework with mvc.
Application only log "Hello!!" string every 10 seconds.

Code example

spring-servlet.xml:



web.xml:






Surprisingly in logs I've noticed double logs with hello string?? WTF?

Looking into context start logs

2014-02-23T23:18:08|INFO: PWC1412: WebModule[null] ServletContext.log():Initializing Spring root WebApplicationContext
2014-02-23T23:18:08|INFO: Root WebApplicationContext: initialization started
2014-02-23T23:18:08|INFO: Refreshing Root WebApplicationContext: startup date [Sun Feb 23 23:18:08 CET 2014]; root of context hierarchy
2014-02-23T23:18:09|INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/springmvc-servlet.xml]
2014-02-23T23:18:09|INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2014-02-23T23:18:09|INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@88fb55: defining beans [helloController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,runScheduler,org.springframework.web.servlet.view.InternalResourceViewResolver#0,org.springframework.context.annotation.internalAsyncAnnotationProcessor,org.springframework.context.annotation.internalScheduledAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
2014-02-23T23:18:09|INFO: Hello!!
2014-02-23T23:18:09|INFO: Root WebApplicationContext: initialization completed in 838 ms
2014-02-23T23:18:09|INFO: PWC1412: WebModule[null] ServletContext.log():Initializing Spring FrameworkServlet 'springmvc'
2014-02-23T23:18:09|INFO: FrameworkServlet 'springmvc': initialization started
2014-02-23T23:18:09|INFO: Refreshing WebApplicationContext for namespace 'springmvc-servlet': startup date [Sun Feb 23 23:18:09 CET 2014]; parent: Root WebApplicationContext
2014-02-23T23:18:09.590+0100|INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/springmvc-servlet.xml]
2014-02-23T23:18:09|INFO: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
2014-02-23T23:18:09|INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3d2bac: defining beans [helloController,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,runScheduler,org.springframework.web.servlet.view.InternalResourceViewResolver#0,org.springframework.context.annotation.internalAsyncAnnotationProcessor,org.springframework.context.annotation.internalScheduledAnnotationProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@88fb55
2014-02-23T23:18:09|INFO: Mapped URL path [/welcome] onto handler 'helloController'
2014-02-23T23:18:09|INFO: Mapped URL path [/welcome.*] onto handler 'helloController'
2014-02-23T23:18:09|INFO: Mapped URL path [/welcome/] onto handler 'helloController'
2014-02-23T23:18:09|INFO: Hello!!
2014-02-23T23:18:09|INFO: FrameworkServlet 'springmvc': initialization completed in 383 ms

 Solution

Context was loaded twice from /WEB-INF/springmvc-servlet.xml config file.  
contextConfigLocation is uncorrectly invoke. It should point on spring application context definition (different than servlet definition - springmvc-servlet.xml).
Changing to other applicationConfig.xml should help fix the problem:


Eclipse glassfish error

When I'm trying to run glassfish (ver. 3.1) from the eclipse servers view, its only show error message:

bootstrap jar not found

Solution:
Check if glassfish server is proper configured on Window->Preferences-Server->Runtime Environment-GlassFish 3.1