Blogging Spring

Starting on the 3rd week of may, I'll work for ideyatech, a company that uses spring framework as its main technology. I'll be posting topics about spring and related technologies that is usually used with it.

Though I'm more of an seam guy now, working with spring will help me see the real difference between ejb/seam and spring. By working with both frameworks, I can determine the pros and cons of each framework and maybe in the future use them at the same time.

In the following days, I'll be posting more about Spring MVC, Spring Webflow and probably Spring Security (also known as ACEGI Security)

JBoss Tools on Ubuntu 8.04

I finished the installation of Ubuntu 8.04 last night. I just became a 100% open source developer by completely dumping windows. The installation was not very straight forward because I encountered several problems with eclipse running on Ubuntu. The following are the things I needed to solve while trying to install my Java development tools:

1. Eclipse keeps on crashing

This problem was really annoying because eclipse keeps on crashing every 5-10 minutes.

Solution:

Just add this at the end of your eclipse.ini (considering that no previous modification to that file was made):

-XX:MaxPermSize=90M

You will need to adjust the size depending on your computers memory.


2. Cannot open any file with JBoss Tools HTML Editor

When opening any file using JBoss Tools HTML Editor, I get a message box with the following error:

/home/jexter/app/eclipse/plugins/org.mozilla.xulrunner.gtk.linux.x86_1.8.1.3-20070904/xulrunner/libjavaxpcomglue.so: libstdc++.so.5: cannot open shared object file: No such file or directory

Solution:

Just install libstdc++5 by simply running this:

apt-get install libstdc++5

Don't forget to update your packages first.

When using seam framework and ajax4jsf, there is a bug when trying to re render an area using aj4:poll. Here is my code:

<h:outputText id="currentDateTime" value="#{currentDatetime}" styleClass="dateTime">
<s:convertDateTime pattern="MMMM dd, yyyy - hh:mm:ss a"/>
</h:outputText>

<h:form>
<a4j:poll interval="1000" reRender="currentDateTime" eventsQueue="timerQueue"></a4j:poll>
</h:form>


The solution is not yet clear as some say they need to tweak the concurrent-request-timeout in components.xml and others say that you need to simply make sure that the ajax request is not aschronous by using the eventsQueue property. Although the idea worked for me, some knowledgeable people say that tweaking those things depends on app by app.

Here are some useful links:

http://sfwk.org/Community/ConversationEndedTimedOutOrWasProcessingAnotherRequest
http://docs.jboss.com/seam/2.0.1.GA/reference/en/html/conversations.html#d0e5208

Ajax4JSF is a library that easily adds ajax functionality to existing jsf components. As oppose to Icefaces which is a set of jsf components that already have built in ajax functionalities, Ajax4JSF offers a much flexible way to add ajax functionalities to jsf components. It offers refreshing of display without the need to refresh the entire form. On the downside, Ajax4JSF is harder to use for very complex jsf components.

Using Ajax4JSF in seam 2.0 is easy. Just remove the line in your faces-config.xml:

<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
and add the following code on your web.xml just aboe the seam listener definition:
<context-param>
<param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
<param-value>com.sun.facelets.FaceletViewHandler</param-value>
</context-param>
You will also need to define the following on you xml schema:
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax
The following code is an example of a simple clock functionality that updates its time by polling / reRendering the component. I didnt use a backing bean on this example:

<h:outputText id="currentDateTime" value="#{currentDatetime}" styleClass="dateTime">
<s:convertDateTime pattern="MMMM dd, yyyy - hh:mm:ss a"/>
</h:outputText>

<h:form>
<a4j:poll interval="1000" reRender="currentDateTime"></a4j:poll>
</h:form>

When using JBoss Tools 2.0.0 GA, the generated test project doesn't allow me to provide a custom persistence.xml. I'm not sure if this is a bug or the feature is not yet included on the given version. The persistence.xml being used when the application is deployed and when running test is the same. So what I did is update the hbm2ddl.auto property of the projectname-ejb/META-INF/persistence.xml to create/create-drop when running test and then when deploying the application, i switch it back to update.

Right now I don't want to waste my time just figuring out how to run test that uses a different persistence context. I have already spent 2 days just doing that but nothing happened. Its either I wait for a major JBoss Tools update or I'll try solving the problem again once I get some free time.

Newer Posts Older Posts Home

Blogger Template by Blogcrowds