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

Checking which services will be started on linux boot

- list of all services with levels of run
ls /etc/rc*.d

- install configuration editor
sudo apt-get install rcconf sysv-rc-conf



Switching on log to file during start on Debian system

According to what debian users says about new version of Debian (after the Wheezy edition) to turn on the log from system start (boot) we must install package responsible for this - bootlogd.:

- sudo apt-get install bootlogd

After installation logs should be saved in /var/log/boot file.

2014-02-22

How to install sonarqube(sonar) on debian


- get source from www:
wget http://dist.sonar.codehaus.org/sonarqube-4.1.zip

- unzip package:
unzip sonarqube-4.1.zip

- move unzipped folder into/usr/local 
mv sonarqube-4.1 /usr/local/

- create symbolic link to operate without version number
ln -s /usr/local/sonarqube-4.1 /usr/local/sonar

- now we can operate on sonar directory name and check if it works:
/usr/local/sonar/bin/linux-x86-32/sonar.sh start

- edit configuration file:
vim /usr/local/sonar/conf/sonar.properties

-- set user and password to db and sql url:
sonar.jdbc.username=sonarqube
sonar.jdbc.password=sonarqube
sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube

- restart server
/usr/local/sonar/bin/linux-x86-32/sonar.sh restart

- implement sonar as a linux service:
sudo cp /usr/local/sonar/bin/linux-x86-32/sonar.sh /etc/init.d/sonar

- now change configuration of sonar
sudo vim /etc/init.d/sonar 

-- add home variables and reconfig command line command
SONAR_HOME=/usr/local/sonar
PLATFORM=linux-x86-32

WRAPPER_CMD="${SONAR_HOME}/bin/${PLATFORM}/wrapper"
WRAPPER_CONF="${SONAR_HOME}/conf/wrapper.conf"

PIDDIR="/var/run"

- now we can set this as a service wtihcommand (in debian):
sudo update-rc.d 

- and we can chack if it works:
sudo /etc/init.d/sonar restart
-or:
sudo service sonar restart