This blog is mainly about Java...

Monday, November 23, 2009

Axis 2 gotcha

Just wanted to give a quick GOTCHA I discovered with Axis 2. The other day I wanted to install and use lombok (which is AWESOME by the way).

However lombok needs Java 6 to run, and my WebService was compiled with Java 5, so I changed to Java 6, recompiled, but obviously forgot to recompile the WebService client stubs.
 I didn't get any exception that remotely told me that I had a class version issue. However, I got this exception:
com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
After reverting back to Java 5, everything worked just fine. So just a heads up.

Friday, November 20, 2009

Seam / Infinispan meetup in Devoxx

So I just returned from the Seam / Infinispan meetup here in Devoxx and there where a few GOTCHA that I will come back to.

Firstly, the meeting it self was pretty awesome. Although I feel that the Seam discussion wasn't that coordinated as the Infinispan talk. There were too much focus on Weld, but I guess thats not surprising since Weld was just recently released, and most Seam developers except poor Norman Richards, where working on Weld to get it finished before the deadline.
Don't take my words literally, Norman might have done some work towards Weld for all I know, but he was at least the only one working on Seam 2.

Anyways, the ones from the Seam team who where present (forgive me if I forget someone) where: Pete Muir, Dan Allen, Norman Richards, Shane Bryzak and Christian Bauer.
Dan held a quick intro on Seam, for the 3 people who didn't know what Seam was, and then Pete talked a bunch about Weld, and finally Dan closed with showing a very cool testing framework which I cannot remember the name of now which will be implemented for Seam 3, and also Rest on Seam. Of course with a lot of Q&A in between.

So finally I got a chance to speak with Dan, Norman and Pete. I really wanted to have a chat with Shane as well, but unfortunaltly by the time I went to get a beer and come back he was gone. :-(
First I got a chance to ask Dan about the strange behaviour I found regarding injection of a stateless EJB in Seam, discussed here , and he confirmed what I suspected all along, that it was infact a bug in Seam. Now, I he didn't actually say "That is a bug" per say, but he did say "If that doesn't work, it is a bug in Seam". But from my experience I can safely conclude that this is a bug in Seam.
Before you say "Hey, why don't you file a JIRA on it", I will tell you why I will not.
After talking with Pete, I discovered that infact there WILL BE NO MORE releases of Seam. Meaning, even if there are any bugs, or even if someone in the community upload a patch, or even some core devel0per fix the bug in the Seam 2.2 branch, there will be no official release of it. You can however checkout a version of that fix and build binaries for your self.
I know, pretty lame and to be honest a big surprise from my part. But Pete did explain why, and the reason is that before shipping an official release, it has to go to the QA team for testing, and probably some other branches and this takes up rescources that JBoss doesn't want to commit to. Instead they want to focus on the development and shipping Seam 3, which is planned to come around march 2010.
So you must ask your self "What about us who are using Seam 2.x and really need to fix this and that issue? Is all hope gone, other than fixing it our selves and running a build?" The answer is no. If you REALLY want something, basically all you have to do, is buy a support deal from JBoss or a certified JBoss partner (as we are), and ask them to fix it. JBoss will then put resources into fixing that and actually commiting the fix in the branch so that it is available for everyone to checkout and build, however, they still will not release a version of that fix. You have to build it your self.

Lastly, this blog post deserves to be mentioning what Seam 3 will look like. Though this is not official or final, it is what I know has been discussed and agreed upon.
Seam 3 will be what is missing from the Java EE 6 stack. Everything thats sort of extra that didn't get into the spec. It will obviously contain all the pdf, rss, excel goodies we are familiar to from Seam 2, including JBPM 4 and Drools 5 support. Not to forget all the goodies that comes with Java EE 6, Bean validation, Servlet 3.0, EJB 3.1, JPA 2 and so on. It will also be modular based, meaning, that if you only need certain parts of Seam, then it is no need to get anything else which is irrelevant to you. There is probably more that I have forgotten, but Pete will blog about this pretty soon.
Lastly, I want to mention that I did try to encourage the people to participate on the seam forums, and help people that are struggling with their Seam 2.x apps. Because face it; those people are most likely to move to Seam 3 and Weld, and if you want them to do that, you should try to make the learning curve of Seam 2.x as little as possible.
Pete did agree, however he did say that the reason why he couldn't reallly encourage the core developers to use more time on the forums is because of all the time they spent on getting Weld finished. 14 hour(!) days jikes. But hopefully in the future, they will have more time to help the users out there.

Good night from Devoxx.

Thursday, October 8, 2009

IE8 bug in Seam 2

There seem to be a problem with IE8 and Seam applications. We are running Seam 2.1, JSF 1.2 and Facelets, and I cannot say for sure where the bug is. For all I know its a bug with IE8.

There seem to be problems when creating long-running conversations. In link using IE8 the cid doesnt appear. Somehow it is stripped or doesn't render correctly, and it causes some strange behaviour.
When trying to create a long running conversation by pushing an edit link for instance, we get a "Your session has timeout" exception.

We fixed this IE8 problem by telling Internet Explorer to emulate IE7 in pages.xml
<page view-id="*">
<header name="X-UA-Compatible">IE=EmulateIE7</header>
</page>

I suggest you do the same until the bug is identified and fixed.

Thursday, August 20, 2009

Using Enum in your entity beans

It is quite handy to use an Enum, especially with type String. This means that the enum will be translated as a text field in your database.

Imagine the following Entity Simple.java:
@Entity
public class Simple {
Process process;

@Enumerated(EnumType.STRING)
public void Process getProcess() {
return process;
}
}

And Process.java:
public enum Process {
WHAT,
THE,
BUCK
}


Now, I initally thought, that since you are defining the enum type to be string, then you can simply query the database using string as well like this:
entityManager.createQuery("from Simple s where s.process=:process").setParameter("process","WHAT").getResultList();
However this doesn't work. You will need to use an Enum type. So the solution is to use Enum.valueOf()
entityManager.createQuery("from Simple s where s.process=:process").setParameter("process",Process.valueOf("WHAT")).getResultList();

Now the query will run and return your list :-)

Tuesday, August 4, 2009

Wicket error in Seam test

The Problem

Recently we upgrade to Seam 2.1.x and suddenly our testng test using ant failed with the following message:
No wicket components directory specified to give Seam super powers to
Wicket was added to Seam 2.1.0.BETA1.
This error message doesn't really say anything. Also it said further:
Must set application-class using  in components.xml 

But we where not using wicket and didnt want to add it.

The stacktrace was as following:
WARN  [org.jboss.seam.wicket.web.WicketFilterInstantiator] No wicket components directory specified to give Seam super powers to
[testng] FAILED: getDefaultContacts
[testng] java.lang.IllegalStateException: Must set application-class using in components.xml
[testng] at org.jboss.seam.wicket.web.WicketFilterInstantiator$1.init(WicketFilterInstantiator.java:107)
[testng] at org.jboss.seam.web.WicketFilter.doFilter(WicketFilter.java:124)
[testng] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[testng] at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
[testng] at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
[testng] at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
[testng] at org.jboss.seam.mock.AbstractSeamTest$Request.run(AbstractSeamTest.java:491)
[testng] at no.whatever.test.AddressBookTest.getDefaultContacts(AddressBookTest.java:18)
[testng] ... Removed 22 stack frames
[testng] FAILED: setup

The Solution


It seems like ant will just put all the libraries in the lib folder in the classpath, and eclipse obviously would not. Thus, when the wicket jars where removed, the tests where back online. I believe it is sufficient to remove jboss-seam-wicket.jar and jboss-seam-wicket-ant.jar, however I just removed all jars that included the name wicket.

Labels