Recent Posts
Archives

PostHeaderIcon (long tweet) “Hello world” with JSF 2.0, Tomcat 7 and IntelliJ IDEA 12 EAP “Leda”

(disclaimer: this “long tweet” has absolutely no interest, except playing with Tomcat 7 and “Leda”)

Friday is technical scouting… Today it will be a “Hello World!”.

  • Get the code and project available on this page: http://www.mkyong.com/jsf2/jsf-2-0-hello-world-example/
  • Get and install Tomcat 7 (very nice new home page)
  • Get and install IntelliJ IDEA 12 EAP “Leda”
  • Launch IDEA
  • Create a new project on existing sources, select the pom.xml of the project above.
  • Build with Maven
  • In IDEA:
    • Run Configuration
    • Tomcat Server
    • Startup Page: http://localhost:8080/
    • Deployment
    • Add
    • Artifact…
    • select the WAR
    • OK
  • This launches Tomcat 7. You can connect http://localhost:8080/

Actually, I’m sure you can deploy with Tomcat-Maven plugin, ie without actual Tomcat install.

PostHeaderIcon Depart de Sungard Global Services

Apres plusieurs annees au sein de Cadextan puis Sungard Consulting Services et enfin Sungard Global Services, j’ai souhaite donner une nouvelle impulsion a ma carriere et affronter de nouveaux challenges. Voila pourquoi, corollairement a ma fin de mission chez Amundi AM, j’ai quitte Sungard Global Services vendredi dernier.

7 annees, 4 missions (Sungard-Finance / GP3, Ixis CIB, BNP Arbitrage, Amundi AM), des dizaines d’heures de formations dispensees, des douzaines de CVs recus/tries/selectionnes/forwardes, des centaines de jours de travail, des centaines de kilometres parcourus et une seule passion: Java!

Je tiens a remercier les equipes de Sungard Global Services -consultants, administratifs, managers, direction, etc.- pour ces 7 annees passees a travailler a leurs cotes. J’ai appris enormement de choses et rencontre beaucoup de personnes ayant de grandes qualites humaines. Sungard Global Services est une belle reussite, passee en quelques annees de 100 personnes en France a plus de 500 en Europe, dans des conditions macro-economiques pas toujours les plus favorables. Je suis fier des accomplissements effectues et d’avoir apporte ma contribution a cette aventure.

PostHeaderIcon Leaving Sungard Global Services

After seven years in Cadextan, then Sungard Global Services, I wanted to give new impetus to my career and face new challenges. That is why, at the end of my position in Amundi AM, I left Sungard Global Services last Friday.

I’d like to thank the staff of Sungard Global Services-consultants, administrators, managers, etc. – for these seven years spent working on their sides. I learnt much and met many people with great human qualities. Sungard Global Services is a great success, that changed in a few years from a 100-people company in France to than 500-people in Europe. I am proud to have been part of these successful achievements and adventure.

PostHeaderIcon Leaving Amundi AM

After a couple of months spent as technical expert, transverse architect and manager of project “Reliability and Stabilization”, I left Amundi AM last Friday. I faced exciting and arduous subjects, such us OSGi, JOnAS, JVM customization, EJB2 to EJB3 migration, webservices upgrade, Decalog AS leaks, etc.

I would like to thank the whole teams that greeted me, and especially among them Antoine BODY and Jean-Guillaume BATTAGLIA.

PostHeaderIcon Why “contract first” approach won’t work with CXF or SpringWS for Axis-generated WSDLs

Case

My previous subject was the following: considering a WSDL that was generated by Axis 2, develop a webservice with CXF and/or SpringWS in “contract first” (ie the contract seen as an API is given, Java code comes afterwards) approach.

It cannot work easyly, unless you are ready to spend time, money and energy in creating adapters and adding layers in your application architecture.

CXF

With CXF, the first step is to generate Java code with the wsdl2java embeded in Maven CXF plugin. The output is explicit:

[java]Failed to execute goal org.apache.cxf:cxf-codegen-plugin:2.6.1:#wsdl2java on project PocEjb3: Rpc/encoded wsdls are not supported with #CXF[/java]

(cf my tweet)

RPC vs Encoded

Actually, the SOAP envelope has two ways to transport the message: RPC and Document. More detail is available here: Which style of WSDL should I use?
Axis 2 generates RPC/encoded webservice ; this method is deprecated, CXF does not support it.

Spring WS

I then tried to use Spring WS. I thought “Spring WS is only contract-first, it should work”. The first pitfall I fell on was that SpringWS bases on XSD files, not on actual WSDL. For instance, if you follow SpringWS tutorial, you will find such a block:

[xml]    <sws:dynamic-wsdl id="holiday" portTypeName="HumanResource" locationUri="/holidayService/"
targetNamespace="http://mycompany.com/hr/definitions">
<sws:xsd location="/WEB-INF/hr.xsd"/>
</sws:dynamic-wsdl>
[/xml]

To workaround, you can specify use tag, such as:

[xml]<sws:static-wsdl id="precomputed-holiday" location="/WEB-INF/precomputed-holiday.wsdl"/>[/xml]

Anyway, the next issue appears: SpringWS expects to deal with document webservices, ie blocks like:

[xml]<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sch="http://mycompany.com/hr/schemas">
<soapenv:Header/>
<soapenv:Body>
<sch:HolidayRequest>
<!–You may enter the following 2 items in any order–>
<sch:Holiday>
<sch:StartDate>?</sch:StartDate>
<sch:EndDate>?</sch:EndDate>
</sch:Holiday>
<sch:Employee>
<sch:Number>?</sch:Number>
<sch:FirstName>?</sch:FirstName>
<sch:LastName>?</sch:LastName>
</sch:Employee>
</sch:HolidayRequest>
</soapenv:Body>
</soapenv:Envelope>>

[/xml]
whereas Axis-generated WSDL look like:
[xml]<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://interfaces.api.lalou.jonathan">
<soapenv:Header/>
<soapenv:Body>
<int:sayHello soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</soapenv:Body>
</soapenv:Envelope>

[/xml]

In other words, I have just fallen on the exact same issue as with CXF: SpringWS cannot support RPC/encoded WSDLs.

PostHeaderIcon Hot Redeploy EJBs on JOnAS

Case

I ogten have to redeploy my JEE application on JOnAS. Basically, I stopped the server, copied the files (EAR, JAR, etc.), then started up again the server. I was fed up with implementing this method.
How to speed up?

Solution

Below is a proposal of solution, without any pretention (I am not fond of JOnAS…), based on an Ant script running under Maven. The code is commented, in a summary: build the EAR (or JAR, WAR, etc.), then copy it to JOnAS deploy folder, undeploy the beans, check which beans are still deployed, deploy the new version of the beans, check which beans are deployed:

[xml] <build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copyToJonas</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property name="jonas.root" value="${env.JONAS_ROOT}"/>
<property name="jonas.base" value="${env.JONAS_BASE}"/>
<echo>Copy files</echo>
<copy todir="${jonas.base}/deploy" overwrite="true">
<fileset dir="${build.directory}/">
<include name="*.*ar"/>
</fileset>
</copy>
<echo>Undeploy beans</echo>
<exec executable="${jonas.root}/bin/jonas.bat">
<arg line="admin -r ${jonas.base}/deploy/${artifactId}-${version}.${packaging}"/>
</exec>
<echo>Currently deployed beans:</echo>
<exec executable="${jonas.root}/bin/jonas.bat">
<arg line="admin -j"/>
</exec>
<echo>Deploy beans:</echo>
<exec executable="${jonas.root}/bin/jonas.bat">
<arg line="admin -a ${jonas.base}/deploy/${artifactId}-${version}.${packaging}"/>
</exec>
<echo>Currently deployed beans:</echo>
<exec executable="${jonas.root}/bin/jonas.bat">
<arg line="admin -j"/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>[/xml]

At first glance I assume I should swap the phases of copying file and undeploying beans. Anyway, this scripts works for me and allows to redeploy after each mvn clean install 😉

PostHeaderIcon Blog Upgrade onto WordPress 3.3.1 on Free.fr

Yesterday I upgraded the blog to WordPress 3.3.1. Last version was a but old (2.8 branch), I installed it in october 2009.

Being hosted on Free.fr, I had to use a customized version of WordPress, released by Gaetan Janssens on his blog Petit Nuage’s Stunning World.

The process I followed is basic:

  • back up database via PhpMyAdmin
  • export the blog full content
  • backup current state of (former) remote WordPress code
  • upload WordPress 3.3 via FTP
  • reupload once more (I often happened to have files that Free.fr FTP “missed” to receive, or received partially ; I don’t think FileZilla is the root cause)
  • add a .htaccess (the former one vanished in outer space, I ignore why)
  • login to admin
  • disable all plugins
  • restore default them
  • display the blog
  • enable theme
  • enable each plugin one per one

I encountered some issues, that I fixed after a short look in PHP code. Well… I was a PHP expert ; I am no more :-D. I may speak Spanish better than PHP.

Now it seems to work. So far, having kept the same theme, almost no differences are visible. I only added links and social sharing sections on the left column. Anyway I’d like to change the theme (even though I enjoy it and its Tux 😉 , and I’d like to keep a Linux-oriented style)

Akismet does not work anymore  (more information on Pascal Ledisque’s bloc, in French). I may use Antispam Bee instead.

I also was unable to display Twitter flow: this issue is linked to the previous one: Free.fr prevents WordPress from accessing external HTML, XML and/or RSS flows.

PostHeaderIcon (long tweet) Increase choice with mvn archetype:generate

By default, mvn archetype:generate offers ~50 template projects. How to offer more templates?

Actually, Maven bases itself on a archetype-catalog.xml file, in Maven’s local repository. Updating this file is possible, by mvn archetype:crawl (and/or archetype:update-local-catalog ?).
Anyway, Maven can base on a remote repository, using archetypeCatalog, such as:
[java]mvn archetype:generate -DarchetypeCatalog=http://download.java.net/maven/2[/java]

You can hint at the remote repository available in settings.xml file, for instance.

PostHeaderIcon (long tweet) JOnAS / GenIC / Method … of interface … should NOT throw RemoteException

Case

On generating Locals and Remotes of EJBs (let’s say JonathanBean) to be deployed on JOnAS, the GenIC raises:
[java]GenIC.fatalError : GenIC fatal error: Cannot read the Deployment Descriptors from /foo/goo/jonathan-server.jar: Method foo of interface lalou.jonathan.JonathanLocal should NOT throw RemoteException[/java]

Within the EJB2, the method foo is declared to be Local and to throw RemoteException

Quickfix

The error is explicit.

A Local EJB cannot throw RemoteException.
Especially, the considered method can be declared with the right XDocLet tag, ie:

[java]* @ejb.interface-method view-type="remote"[/java]

but can with neither:
[java]* @ejb.interface-method view-type="both"[/java]

nor:
[java]* @ejb.interface-method view-type="local"[/java]

As a quickfix, I suggest to surround with a try/catch block a throw a RuntimeException if needed.

PostHeaderIcon (long tweet) Tip: How to know the location of a resource?

Case:

You have many files with the same names (log4.xml, applicationContext.xml, etc.), you need know which of them is loaded.

Tip:

On the debugger and/or in the logs, use an instruction similar to:

getClass().getClassLoader().getResource("log4j.xml")