Archive

Archive for the ‘java’ Category

@PostConstruct method called twice for the same request

December 17, 2013 Leave a comment

Hi there,

for those of you fighting with CDI and JSF when getting this error:  http://stackoverflow.com/questions/9077966/postconstruct-method-called-twice-for-the-same-request

Be sure that you did not import javax.enterprise.context.SessionScoped instead of javax.faces.bean.SessionScoped.

Both compile, but only the latest is the one you want for dealing with session scope bean in JSF.

cdi

Categories: java, JSF

Mule ESB set up with Maven under Eclipse (OSX)

January 22, 2010 2 comments

I have followed the Mule ESB tutorial and found that it did not work with Java5 on OSX. I have switched to Java6 and everything was back to normal.

Everything is explained very well on Mule web site, here is what I did to get it running with Maven 2 under Eclipse on OSX.

Firstly I have of course downloaded Mule (community edition) on their download page and expanded everything in /opt folder with the following command:

tar -xvzf mule-standalone-2.2.1.tar.gz

I’ve also downloaded the mule ide plugin for eclipse and followed the instructions here

To get it running with Maven, I used the command line in my project folder :
mvn mule-project-archetype:create -DartifactId=MMuleProject -DmuleVersion=2.2.0

and then I have the following command:
mvn eclipse:eclipse

to make it available as a project in eclipse.

Then I have launched Eclipse and imported the project:

File->import->Existing project into workspace

and I have selected the MMuleProject folder as root folder. Once the project was imported i have right-clicked on the project name MMProject in the package explorer and added Mule libraries:

project properties under eclipse

the project finally appears like the following inside the package explorer:

With Java 5 enabled I had this issue when trying to run the project : (right-click on mule-config.xml -> run as -> Mule Server)

INFO 2010-01-22 14:15:41,561 [main] org.mule.MuleServer: Mule Server initializing...
ERROR 2010-01-22 14:15:41,648 [main] org.mule.MuleServer: A Fatal error has occurred while the server was running: [[B
java.lang.ClassCastException: [[B
at java.net.InetAddress.getAddressFromNameService(InetAddress.java:1215)
at java.net.InetAddress.getLocalHost(InetAddress.java:1350)
at org.mule.config.DefaultMuleConfiguration.(DefaultMuleConfiguration.java:116)
at org.mule.context.DefaultMuleContextBuilder.getMuleConfiguration(DefaultMuleContextBuilder.java:125)
at org.mule.context.DefaultMuleContextBuilder.buildMuleContext(DefaultMuleContextBuilder.java:84)
at org.mule.context.DefaultMuleContextFactory.buildMuleContext(DefaultMuleContextFactory.java:197)
at org.mule.context.DefaultMuleContextFactory.doCreateMuleContext(DefaultMuleContextFactory.java:186)
at org.mule.context.DefaultMuleContextFactory.createMuleContext(DefaultMuleContextFactory.java:168)
at org.mule.MuleServer.initialize(MuleServer.java:351)
at org.mule.MuleServer.run(MuleServer.java:257)
at org.mule.MuleServer.start(MuleServer.java:244)
at org.mule.MuleServer.main(MuleServer.java:121)
ERROR 2010-01-22 14:15:41,671 [main] org.mule.MuleServer:

Switching to JDK 6 solved it :

INFO 2010-01-22 14:18:18,142 [main] org.mule.DefaultMuleContext:
**********************************************************************
* Mule ESB and Integration Platform *
* Version: 2.2.0 Build: 14110 *
* MuleSource, Inc. *
* For more information go to http://mule.mulesource.org *
* *
* Server started: 1/22/10 2:18 PM *
* Server ID: 999d182b-0758-11df-82a2-811cd9e5dabf *
* JDK: 1.6.0_15 (mixed mode) *
* OS encoding: UTF-8, Mule encoding: UTF-8 *
* OS: Mac OS X (10.5.8, x86_64) *
* Host: loic-talbots-macbook-pro.local (192.168.0.10) *
* *
* Agents Running: None *

pheeewww… it should have taken a few minutes, it took a few hours to figure out I should not use JDK5. Now I’ll experience this lightweight SOA architecture to expose SOAP web services. Something for a next post.

Categories: SOA Tags: , , ,

Could not see my WSDL using Apache Axis 2 with Eclipse WTP

December 7, 2009 Leave a comment

I have spent some time figuring out why I could not see any WSDL despite everything else seemed to be OK.

After having followed these kind of steps: Creating web services with Eclipse (Bottom up) it appears that I could not see any WSDL.
So I have typed http://localhost:8080/Axis2/axis2-web/index.jsp , then clicked on services and the following screen was displayed:

Axis main screen

Axis main screen

The service  – Converter – seemed to be running ! but when trying to reach the WSDL by clicking on the Converter link I had this:

WSDL page

WSDL page

After some experiments I have found that the WSDL was actually correct (!) . it was just not displayed in Safari. Running the same URL on Firefox confirmed it.

It’s not the first time something is hidden by Safari unfortunately. It seems it waits a really clean html code. It’s still viewable by clicking on view-> view Source but you don’t expect immediately such a thing to happen.

Categories: java, Web services Tags: , , ,