Wednesday, December 26, 2012

Technorati

Hi,

I just add my blog on Technorati with the reference : SNHEY74ZG7EV

Wednesday, December 12, 2012

Paper about CRaSH : a shell to extends the JVM

I've made an article about an interesting new project : CRaSH
It was published on www.developpez.com.Now it is in french but it will be translate.He is a direct link to this paper : http://damienrieu.developpez.com/article/crash_ehcache_spring/ 

CRaSH permits to access to the JVM by Shell and then execute scripts that you have mage in JAVA or Groovy ...

Saturday, November 10, 2012

IntelliJ : shortcut with kde

Recently, I use IntelliJ with KDE.
I notice that some keymap didn't work.For example, The shortcut ALT + 1 which open the projet window.
I replace it by ALT + NUMPAD 1.

I will try to fill an excel google drive document with shortcuts : here

Tuesday, October 16, 2012

Git reminder


Just a git reminder to work with github ...

git checkout master
git fetch upstream
git merge upstream/master


git checkout dashboard
git merge upstream/dashboard

git push --set-upstream origin dashboard


Merge


git mergetool -t kdiff3
git mergetool -t meld
git config --global merge.tool kdiff3

Clean d'un repository :

For example,

git fetch upstream
git checkout master
git reset --hard upstream/master  
git push origin master --force 


Revert

  • git checkout path/to/file
  • For a working copy : git reset --hard

Monday, October 8, 2012

Closure Lambda and Java 8


I found a good link about Closure (Lambda project) of Java 8.With this article, you will have a good idea of what is Lamda : http://java.amitph.com/2012/08/at-first-sight-with-closures-in-java.html

Keep in my, that Java 8 come next year !

Saturday, October 6, 2012

Junit @Rule

Recently, I've found an article on Junit about annotation @Rule.I didn’t know this annotation before.I will present you briefly how it works and I will give you some interesting links.

In earlier version of Junit, we need to declare @SetUp and @TearDown for each test class.
Now, with newer version of Junit, it’s possible to define its own rule with @Rule and you will have the possibility to execute code during test (Same thing than AOP).
To help you to understand, here is some standard rules :

  • ExpectedException: check if an exception is thrown during test
  • Timeout: check that one test doesn’t exceed a given time
  • ExternalResource: Open or close a resource.
  • TemporaryFolder: create and destroy a temporary directory.


Ref :
http://blog.objetdirect.com/divers/quoi-de-neuf-chez-junit
http://www.dzone.com/links/r/junit_rules_3.html

Friday, October 5, 2012

Can't import an existing Maven Project with Eclipse Juno and Maven Plugin 1.1.0

Problem

I do the following :
Import -> Maven -> Existing Maven Project
Then I choose My project on disk.





I click Next.I have the Maven Selector Plugin Screen :


If I click on Finish, I wait a long time and I finally I hava an error : Problem occured while performing ...

Solution

In Maven Selector Plugin Screen, just click on resolve All Later button.
It will permit to have the project on Eclipse and after you could resolve problem.


Wednesday, October 3, 2012

org.springframework.web.servlet.PageNotFound No mapping found for HTTP request with URI


Problem

I've met the following error on Jboss (7.1.1) with an application using Spring 3.1.1 :
14:35:03,357 WARN  [org.springframework.web.servlet.PageNotFound] (http--127.0.0.1-8080-1) No mapping found for HTTP request with URI [/sandbox-0.0.1-SNAPSHOT/css/design.css] in DispatcherServlet with name 'sandbox'

Solution

You have to add     <mvc:resources mapping="/resources/**" location="/resources/" />


http://stackoverflow.com/questions/1483063/spring-mvc-3-and-handling-static-content-am-i-missing-something

Thursday, September 27, 2012

Spring 3.1.1 and ehcache demo application


I've just commit a new version of demo application on GitHub
This application works on with JBoss 7.It uses Spring and Ehcache.
One important thing is that you could use Crash (a shell to extend the JVM) with it.
I will made a more complete article about Crash.See http://julienviet.com/crash/ for more information.

All source code is available at https://github.com/drieu/sandbox

Spring cache tutorial


Annotation about cache on Spring are properly explained at http://www.dzone.com/links/r/spring_31_caching_and_cacheevict.html

Wednesday, September 26, 2012

Fuzz Box: How to generate UML Diagrams from Java code in Ecl...

Fuzz Box: How to generate UML Diagrams from Java code in Ecl...: UML diagrams compliment inline documentation ( javadoc ) and allow to better explore / understand a design. Moreover, you can print and bri...

Sunday, September 23, 2012

Javadoc search engine

If you search a javadoc search engine :http://javasearch.developpez.com/ and click en

Why the site javasearch.developpez.com ?
Like any Java programmer, I regularly need the documentation.The javadoc is well made and rather clear. On the other hand, there is not any simple search engine making it possible to easily find the required classes or methods. Wearied to use the “CTRL+F” of my explorer to find the good word in the list of the 2700 classes, I decided to index the totality of the Java documentation (more than 200 Mo of HTML files !) to create a fast and simple search engine.

Comment : there is not the javadocs for Java 7.

Saturday, September 22, 2012

You want learn Groovy ?


If you want to learn Groovy without buying anything and with alittle fun, you should see
that link :  http://groovykoans.org/

In fact, you will download a Koans which contains exercises.
You ave to success unit tests to solve the problem.In each test method,
there are explanations about how to succeed.
For myself, I know a little Groovy.I want to learn more but there is always something to do ...
So with theses exercices, you just have to do your exercise.So it's more simple and it permit
to show you all language features ...
So ... I have exercises todo !




Wednesday, September 19, 2012

Crash Spring et ehcache

I test succesfully Crash with an Spring application deployed on Jboss 7.1.1.
This application put datas in Cache at startup and also with an Url.Then, I use Crash to connect
to the application and to call a script for seiing cache datas.
If you want to see the source code, it is available on GitHub (https://github.com/drieu/sandbox).

Tuesday, September 18, 2012

java.lang.NoSuchMethodError: org.springframework.core.convert.converter.ConverterRegistry.addConverter(Ljava/lang/Class;Ljava/lang/Class;Lorg/springframework/core/convert/converter/Converter;)V

 Problem :

When I deployed my war, I’ve the following error :


14:11:53,425 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/sandbox-0.0.1-SNAPSHOT]] (MSC service thread 1-1) Exception lors de l'envoi de l'évènement contexte initialisé (context initialized) à l'instance de classe d'écoute (listener) fr.dr.sandbox.listener.CacheListener: java.lang.NoSuchMethodError: org.springframework.core.convert.converter.ConverterRegistry.addConverter(Ljava/lang/Class;Ljava/lang/Class;Lorg/springframework/core/convert/converter/Converter;)V
       at org.springframework.core.convert.support.DefaultConversionService.addScalarConverters(DefaultConversionService.java:62) [spring-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.core.convert.support.DefaultConversionService.addDefaultConverters(DefaultConversionService.java:53) [spring-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.core.convert.support.DefaultConversionService.<init>(DefaultConversionService.java:42) [spring-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.core.env.AbstractPropertyResolver.<init>(AbstractPropertyResolver.java:44) [spring-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.core.env.PropertySourcesPropertyResolver.<init>(PropertySourcesPropertyResolver.java:42) [spring-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.core.env.AbstractEnvironment.<init>(AbstractEnvironment.java:101) [spring-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.core.env.StandardEnvironment.<init>(StandardEnvironment.java:54) [spring-core-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.<init>(AbstractBeanDefinitionReader.java:57) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.<init>(XmlBeanDefinitionReader.java:135) [spring-beans-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:83) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
       at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:467) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
       at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:397) [spring-context-3.0.5.RELEASE.jar:3.0.5.RELEASE]
       at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [spring-web-3.1.1.RELEASE.jar:3.1.1.RELEASE]
       at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392) [jbossweb-7.0.13.Final.jar:]
       at org.apache.catalina.core.StandardContext.start(StandardContext.java:3850) [jbossweb-7.0.13.Final.jar:]
       at org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
       at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
       at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
       at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_18]
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_18]
       at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_18]


Solution


If you look carrefully the error log, you will see that there is 2 versions of Spring.(3.0.5.RELEASE et 3.1.1.RELEASE).In fact, I use Spring 3/0.5.RELEASE in my pom.xml and I introduce a library which has a Spring 3.1.1.RELEASE dependency.
To resolve my problem, I update my pom.xml with Spring 3.1.1.RELEASE.

Monday, September 17, 2012

Java podcast


Here is a podcast I did'nt know : http://javapubhouse.libsyn.com/
If you have any comment about podcast, post -it !

jk's blog: Duck typing in Java ? Well, not exactly


jk's blog: Duck typing in Java ? Well, not exactly: What is it all about ? According to Wikipedia duck typing is style of dynamic typing in which an object's methods and properties determi...

Friday, September 14, 2012

ScriptRoom: Creating and configuring a MySQL DataSource in GlassFish Application Server.

ScriptRoom: Creating and configuring a MySQL DataSource in GlassFish Application Server.: http://dev.mysql.com/downloads/connector/j/3.1.html

Glassfish reminder


./asadmin start-domain domain1
./asadmin list-jndi-entries
./asadmin stop-domain

crash Could not start CRaSSHD Failed to register BouncyCastle as the defaut JCE provider

Problem:

I deployed crash.war in JBoss and  I’ve the following error : Could not start CRaSSHD

10:22:31,335 INFO  [SSHPlugin] Booting SSHD
10:22:32,826 INFO  [SecurityUtils] Trying to register BouncyCastle as a JCE provider
10:22:36,861 SEVERE [SecurityUtils] Failed to register BouncyCastle as the defaut JCE provider
10:22:36,862 SEVERE [SSHLifeCycle] Could not start CRaSSHD

java.lang.RuntimeException: Failed to register BouncyCastle as the defaut JCE provider


Caused by: java.security.NoSuchProviderException: JCE cannot authenticate the provider BC
       at javax.crypto.SunJCE_b.a(DashoA13*..)
       at javax.crypto.KeyAgreement.getInstance(DashoA13*..)
       at org.apache.sshd.common.util.SecurityUtils$BouncyCastleRegistration.run(SecurityUtils.java:97)
       at org.apache.sshd.common.util.SecurityUtils.register(SecurityUtils.java:77)
       ... 79 more
Caused by: java.util.jar.JarException: Cannot parse jar:file:/opt/jboss/jboss-eap-5.1/jboss-as/server/all/deploy/crash.war!/WEB-INF/lib/bcprov-jdk16-1.46.jar


Solution :

- Download  bouncycastle library at http://www.bouncycastle.org/latest_releases.html (For me its bcprov-jdk15on-147.jar and bcprov-ext-jdk15on-147.jar).

- Copy theses files (eg: bcprov-jdk15on-147.jar and bcprov-ext-jdk15on-147.jar) in /path_to_your_jvm/jre/lib/ext. (e.g: /opt/jdk/jdk1.6.0_18/jre/lib/ext)
- vi /path_to_your_jvm/jre/lib/security/java.security and add the following line : security.provider.9=org.bouncycastle.jce.provider.BouncyCastleProvider

java.security

security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=com.sun.net.ssl.internal.ssl.Provider
security.provider.4=com.sun.crypto.provider.SunJCE
security.provider.5=sun.security.jgss.SunProvider
security.provider.6=com.sun.security.sasl.Provider
security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI
security.provider.8=sun.security.smartcardio.SunPCSC
security.provider.9=org.bouncycastle.jce.provider.BouncyCastleProvider

- Restart jboss.

http://www.randombugs.com/java/javalangsecurityexception-jce-authenticate-provider-bc.html
http://nyal.developpez.com/tutoriel/java/bouncycastle/#L1

http://julienviet.com/crash/

Monday, April 23, 2012

How to apply Checkstyle format automaticaly ?





Problem :


You want to format your code with checkstyle rule with CTRL-ALT-F.




Solution :


Right clic on the project -> Checkstyle -> Create a Formatter


Then go Windows -> Preferences -> Code Style -> Formatter 


Next, you just have to select the formatter you have created.
After that, you can make CTRL - ALT - F to format you code

Saturday, April 21, 2012

java 1.8 lambda example


I saw at Devoxx France, a conference about java 1.8 and the use of lambdas by Guillaume Tardif. (http://www.devoxx.com/display/FR12/JDK+8+demo++lambdas+in+Action)

In this article, I will show you an example.You can dowload the jdk here : http://jdk8.java.net/lambda/

To install jdk1.8 on Ubunutu, you can do :



sudo mv ./jdk1.8.0 /usr/lib/jvm/
sudo update-alternatives --install “/usr/bin/java” “java” “/usr/lib/jvm/jdk1.8/bin/java” 1
sudo update-alternatives --install “/usr/bin/javac” “javac” “/usr/lib/jvm/jdk1.8/bin/javac” 1

sudo update-alternatives --config java


Then, you just have to choose the jdk.


Note : I have a bug when I use javac because javac -version show me always 1.6 and not 1.8
So to compile, I've done the following :

/usr/lib/jvm/jdk1.8.0/bin/javac Main.java
java Main


Here is my file Main.java:

import java.util.ArrayList;
import java.util.List;


public class Main {

public static void main(String[] args) {
List names = new ArrayList();
names.add("superman");
names.add("batman");
names.forEach( (String s) -> { System.out.println(s);} );
}

}


Then we show on the screen :

superman
batman


An other important point, Java 1.8 should support multiple inheritance !
If you have comment, post it !

Tuesday, April 17, 2012

Devoxx FRANCE


Tomorrow it's the beginning of a great conference.

During 3 days, there will be technical session on JAVA, HTML5, NOSQL, CASSANDRA ... et all new technologies !
Go to the web site to see trend of the moment devoxx



Thursday, March 29, 2012

Import Existing Maven in Eclipse : project has no J on the folder project


Problem

I made the following :
- Import  Existing Maven project
- Browse -> Choose Maven project (It has pom Module)

Then I saw in Package Explorer, that my project has a M for Maven but has no J for Java Project !
And therefore package are not managed .

Solution 

Right Clic --> Configure --> Convert to facet form

Saturday, March 17, 2012

Go : read and write in a file


To read or write in a file, you can use the package io/ioutil which contains méthods like ReadFile orWriteFile

Example :

package main
import ("fmt";"io/ioutil")
func main() {
fmt.Print("Lecture \n");
contents,_ := ioutil.ReadFile("/home/damikde/tmp/server.log")
   println(string(contents))
        fmt.Print("Ecriture \n");
   ioutil.WriteFile("/home/damikde/tmp/toto", contents, 0x777)
}

Wednesday, March 7, 2012

You can create a free Git open source project by using https://github.com/plans