Archive for the ‘Java’ Category

Surf Stoked Android app – Record and share your surf sessions

Sunday, May 29th, 2011

Web Responsive launches the free app Surf Stoked the first in a series of surf applications for Android phones, that will increase your stoke after a good surfing session.

Surf Stoked helps you record your sessions, so you always have access to your best sessions. You can also easily share your session with your surf buddies with a simple click on a button.

Get Surf Stoked through the Android market here.

Post to Twitter

Flex, BlazeDS, ActiveMQ, Spring application context gotchas.

Thursday, April 15th, 2010

In one of my current projects I have been fighting a lot getting BlazeDS, ActiveMQ and Spring to dance together.

We are using the Spring BlazeDS integration project to connect our Flex frontend with our Java backend.

The project uses remoting AMF and messaging in the communication and the backend consists of three independent Java applications.

One of the toughest things is configuring ActiveMQ to work with BlazeDS.

Lately I had to build a session listener, that detects when users are logging in and logging out. This proved extra hard, as the the session listener is configured in the web.xml and doesn’t have access to the beans in the application context directly.

Inside the session listener I need to get the application context, to get the beans from the Spring context.

Unfortunately with ActiveMQ and BlazeDS, we need a separate context file, than the default applicationContext.xml, else there will be problems with the Flex message broker and ActiveMQ.

I solved this by getting the messaging context, instead of the application context inside the session listener. Here is an example:

public void attributeAdded(HttpSessionBindingEvent e)
{
  logger.info("Attribute added to session: " + e.getSession().getId());
e.getSession();
ServletContext servletContext = session.getServletContext();
WebApplicationContext appContext = (WebApplicationContext) servletContext.getAttribute(WEB_APPLICATION_CONTEXT_MESSAGING);
UserBrokerAccountManager userBrokerAccountManager = (UserBrokerAccountManager) appContext.getBean(USER_BROKER_ACCOUNT_MANAGER_BEAN_ID);
userBrokerAccountManager.doSomething();
}

Basically this shows how to get access to specific beans inside a specific application context.

Another useful method is getting all contexts from the servlet context. Here is a method to do exactly that:

/**
* Show servlet attributes.
*
* @param servletContext the servlet context
*/
@SuppressWarnings({ "unused", "unchecked" })
private void showServletAttributes(ServletContext servletContext)
{
  Enumeration<String> en = servletContext.getAttributeNames();
while (en.hasMoreElements())
  {
    logger.info("Servlet attribute - Enum: " + en.nextElement());
  }
}

Post to Twitter

Apache Tomcat Runtime environment installation in Eclipse

Sunday, April 11th, 2010

Recently while playing with vaadin I had the need for Apache Tomcat Runtime environment in my Eclipse installation.

The problem was, that when I created a new Dynamic Web Project, I didn’t have any Apache Tomcat target runtime installed. And when selecting: New… it would only show the Basic folder and no Apache.

It didn’t exist as default and following the tutorial on vaadin didn’t help. After looking around and wasting a lot of time I managed to get it installed in Eclipse like this:

1. Go to: Help -> Install New Software
2. Select (or add): “http://download.eclipse.org/releases/galileo”
3. Check the following: “JST Server Adapters” (there are two)

Now the adapters are installed, but not configured. Configuration is like this:

4. Go to: Eclipse -> Preferences (I am on a Mac)
5. Select: Server -> Runtime Environment
6. Click: “Add…”
7. Select: Apache -> Apache Tomcat v6.0 (or choose the version you need)

And finally, when I create a Dynamic Web Project, I can click: New… and select the Tomcat Runtime I need.

Post to Twitter

Java heap space problem with Flexmojos on Mac

Tuesday, March 30th, 2010

This is just a note to myself (and anyone else fighting with this problem).

I tried all types of memory expansions, like the most obvious:

export MAVEN_OPTS=’-Xmx=1024M’ and nothing worked.

The only way I could increase the 64MB standard allocated Maven memory, was to change the mvn script itself!

Basically adding:

“-Xmx1024M” \
“-XX:MaxPermSize=1024M” \
to /usr/share/maven/bin/mvn
The memory problems only happens when compiling Flex applications with Flexmojos. I never got any memory problems compiling Java applications, so I suspect that this has to do with the Flexmojos.

Post to Twitter

Stay critical to your darling tools

Friday, March 19th, 2010

As a developer I like to learn about all new Internet technologies being born and embrace the ones I think will benefit my skills. But it is always a balance between dominating a few and adding the best ones to your arsenal, as there are too many to rule them all.

Our main tools at Web Responsive for daily development are Flex and Java and we love them both. But we don’t love them unconditionally. They have to deserve our love. So we are the first to criticize when problems show.

Our main goal is to be productive perfectionist, which is a difficult combination. It basically means we need tools that solve problems in the most easy and simple, yet powerful way.

If we stay focused on one technology without comparing with all the other technologies, we end up being blind to its faults.

What all this comes down to is that, though we do most development with Flex and Java, we embrace when other projects with needs of different technologies come along, say with PHP, HTML and AJAX.

These projects gives us a perfect opportunity to see how far the competing technologies have come and how well our own are doing.

But it is not only technologies, but also frameworks. Nowadays, these become less and less dependent on the underlying technology and more and more implemented as generic templates. This is really interesting as it forces us to think more abstract about how the problem should be solved rather than how the specific technology would solve it.

Post to Twitter