2014-02-23

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

2013-09-30

[Android] Intent i wybór wynikowego activity

Problem

Uruchomienie odpowiedniego activity w zależności od tego czy powiadomienie (notification) jest odpalone przy aktywnym obecnie activity czy też nie.

Rozwiązanie

  • do nowego obiektu typu Intent przypisujemy odpowiednią klasę na podstawie metody sprawdzającej czy activity jest obecnie aktywne. Jeśli klasa ListOfOrdersActivity maw tej chwili aktywną reprezentację w postaci activity to Intent odwoła się właśnie do tej klasy. Jeśli nie to powołana do życia  zostanie  nowa activity klasy MainActivity.
  • metoda sprawdzająca czy dane activity jest w tej chwili aktywne:

2013-09-27

[Spring] Simple tutorial

How to start with java spring framework

prerequisites
  1. Maven (v 3)
    1. configured connection to Nexus;
2.     configured connection via proxy;
Maven settings.xml
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    c:\REPO\MVN\main\
    
            
            
              optional
               true
                     http
                     10.0.5.232
                     8080
                     10.*|112.*
            
    
    
    
            
                     nexus
                     *
                     Nordea Nexus repo
                     http://10.0.52.97:9001/nexus/content/groups/nordea-repos/
            
            
                     nexus-plug
                     *
                     Nordea Nexus repo
                     http://10.0.52.97:9001/nexus/content/groups/nordea-repos/
            
    
    
    1. optionally you can set Environment/User variable parameter for M2_REPO (used by eclipse):
    2. and also MAVEN_HOME param:
  1. Eclipse environment with Maven plugin (m2e - Maven Integration for Eclipse) or VMware Spring Tool Suite (based on Eclipse);
  2. Configured  Local repository (don't know why Remote repo doesn't work (smile) ) for Maven Archetype:
    1. go to url: http://repo1.maven.org/maven2/archetype-catalog.xml
    2. store xml on local disk
    3. configure the Archetypes on Maven menu under project Preferences:
      1. Catalog file: /archetype-catalog.xml
      2. Description:

creating project
  1. Create new Maven project structure



  2. find Archetype with spring-mvc pattern. Choose co.ntier (GroupId) with artifactId: spring-mvc-archetype


  3. Provide Archetype parameters


  4. After confirming Finish button, you'll get the new project created:

Runing project
§  in the controller code you can see that main, root path of project request is set to test() method:
@RequestMapping(value="/") 
HomeController.java
package com.nordea.spring.controller;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class HomeController {
  @RequestMapping(value="/")
  public ModelAndView test(HttpServletResponse response) throws IOException{
           return new ModelAndView("home");
  }
}

  • method test() returns the "home" as a view and model which should be refilled (in this case model is empty);
§  going to the MvcConfiguration class, where there is configured the views prefix and suffix, you can see that "home" value of the HomeController.test method result will give the "/WEB-INF/views/home.jsp" path;
MvcConfiguration.java
package com.nordea.spring.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
@Configuration
@ComponentScan(basePackages="com.nordea.spring")
@EnableWebMvc
public class MvcConfiguration extends WebMvcConfigurerAdapter{
  @Bean
  public ViewResolver getViewResolver(){
           InternalResourceViewResolver resolver = new InternalResourceViewResolver();
           resolver.setPrefix("/WEB-INF/views/");
           resolver.setSuffix(".jsp");
           return resolver;
  }
  
  @Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
           registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
  }
}
the same configuration can be done with use of xml config file.

2013-09-25

Maven, eclipse i spring framework. Problemy z odpaleniem podstawowego projektu maven.

Po załadowaniu przykładowego projektu wykorzystującego Spring Framework (przy użyciu maven archetype), eclipse zgłasza szereg wyjątków. Między innymi widzimy coś takiego:

Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:aspectj-maven-plugin:1.0:compile (execution: default, phase: process-classes)

Replikacja błędu

  • W eclipse wybieramy nowy projekt maven tworzony na podstawie archetypu :
    • groupId: co.ntier
    • artifactId: spring-mvc-archetype
  • Po ściągnięciu i utworzeniu projektu możemy zauważyć powyższe wyjątki związane z sekcją build pliku pom:

  • po dodaniu węzła pluginManagement przed plugins wszystko jest ok:


  • co dziwne po wyczyszczeniu projektu, wykonaniu maven update i wyrzuceniu dodanego węzła wszystko jest ok - brak błędu?!