Saturday, September 29, 2012

Exception without sans try catch ou throws

If you want to throw an exception without using try, catch, see that link :
http://www.dzone.com/links/r/throw_checked_exceptions_like_runtime_exceptions.html

Strange !

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/