Java

Reloading pages in Wicket

Posted on August 7, 2009. Filed under: Java | Tags: , , , |

When developing software, and especially web frontends, is nice and handy to get some immediate feedback on the work you’ve done, without having to rebuild all dependent projects, killing servers, redeploying wars, etc.

At my current project, we have a simple web frontend which is using Wicket, which needs some changes now and then. Unfortunately, Wicket doesn’t reload pages out of the box, and you need some to make this work.

What is recommended to do (but not required), is to set Wicket in development mode. This can be done in multiple ways, but I’ve set the System property ‘wicket.configuration’ to ‘development’. Then, by changing some code in the WicketApplication (which extends WebApplication), you can enable the hot reloading of resource files. The following code is required for that:

String configurationType = getConfigurationType();
if (DEVELOPMENT.equalsIgnoreCase(configurationType)) {
  log.info("You are in DEVELOPMENT mode");  
  getResourceSettings().setResourcePollFrequency(Duration.ONE_SECOND);
}

This way, by recompiling the classes, Wicket detects the changes to HTML and will reload them for you, without having to redeploy the whole application, or needing to restart Jetty. Nice!

References

Wicket FAQ

Read Full Post | Make a Comment ( 1 so far )

ActiveMQ NullPointer exceptions when creating objectmessages.

Posted on March 24, 2009. Filed under: Java |

At the moment, I’m working with Flex, BlazeDS en ActiveMQ in a Spring application. I’m using Flex to display some of my database contents, and for direct communication, I use BlazeDS, and for updating the view, I use JMS (ActiveMQ) in combation with BlazeDS. It works by publishing information to topics, which can be easily done using the following code:

    private void sendJmsUpdate() {
        this.jmsTemplate.send(this.destination, new MessageCreator() {
            public Message createMessage(Session session) throws JMSException {
                return session.createObjectMessage(new ArrayList<TodoItem>(getList()));
            }
        });
    }

The above code uses the Spring JmsTemplate to created messages and send them to the topic. However, when I tried this, I got this exception:


java.lang.NullPointerException
at org.apache.activemq.ActiveMQMessageTransformation.copyProperties(ActiveMQMessageTransformation.java:188)
at org.apache.activemq.ActiveMQMessageTransformation.transformMessage(ActiveMQMessageTransformation.java:173)
at org.apache.activemq.ActiveMQSession.send(ActiveMQSession.java:1606)
at org.apache.activemq.ActiveMQMessageProducer.send(ActiveMQMessageProducer.java:227)
at org.apache.activemq.ActiveMQMessageProducerSupport.send(ActiveMQMessageProducerSupport.java:241)
at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:572)
at org.springframework.jms.core.JmsTemplate.doSend(JmsTemplate.java:549)
at org.springframework.jms.core.JmsTemplate$3.doInJms(JmsTemplate.java:516)
at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:447)
at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:514)
at org.epseelon.samples.todolist.business.TodoServiceImpl.sendJmsUpdate(TodoServiceImpl.java:77)
at org.epseelon.samples.todolist.business.TodoServiceImpl.save(TodoServiceImpl.java:39)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)

After a lot of Googling, I found nothing (well, a bug report somewhere, which was totally unrelated to what I had here). Why did I get this error?? I know my remoting was working (String were send), my objects were fine since I could get the list manually by doing a Refresh with the flex client itself (which used ≶mx:RemoteObject>) to call the Spring service…. And then it occured to me that the explanation was already here. I just overlooked it (hate it when that happens): the BlazeDS service apparently doesn’t require the objects (TodoItem) to be Serializable…. JMS ofcourse does! Argh! I forgot to implement Serializable here!

So, if you ever encounter this message, which is hardly descriptive at all, check your objects to see if they are all serializable. It saves a lot of debugging!

Read Full Post | Make a Comment ( 1 so far )

IntelliJ JSON Formatter Plugin 0.2

Posted on February 14, 2009. Filed under: IntelliJ JSON Formatter Plugin | Tags: , , , |

I’ve worked with my JSON Formatter plugin for a couple of days now to debug my Grails communication layer, and even though I created it myself, I want to say that I’m quite pleased with it. The only thing which annoyed me a bit is that it’s hard to see  if the JSON code is valid. Well, while it’s not 100% complete (and correct) yet, I’m happy to say that I’ve added simple validation to the Plugin, thanks to the JSON library of Bruno Ranschaert, who was quick to respond to a small bug in the ANTLR part of the JSON library. Since that’s fixed now, you can use the JSON plugin to further enjoy Grails and IntelliJ development! 🙂 (See the pictures for the feedback panel!)

picture-4

Read Full Post | Make a Comment ( None so far )

IntelliJ JSON Formatter Plugin

Posted on February 5, 2009. Filed under: Grails, IntelliJ JSON Formatter Plugin | Tags: , , , , , |

I’ve just created my first IntelliJ plugin, a JSON formatter. Since I work a lot with Groovy and Grails, and Grails supports JSON so nicely, it’s sometimes necessary to debug the JSON code going back and from the client to the Grails backend. However, since the JSON code is stripped from whitespaces, it’s a bit harder to read than a nested structure. To format the JSON, you can use various websites , but it requires a context switch (from IDE to Webbrowser), plus it requires an Internet connection. To solve this, I created an IntelliJ JSON Formatter plugin, which nicely hooks into IntelliJ. To give you an idea of what the plugin looks like, please take a look at the following image:

IntelliJ JSON Formatter plugin

This images gives an impression of a formatted piece of JSON code, and also includes brace matching and coloring thanks to the RSyntaxTextArea. The JSON code is parsed with the help of the JSON tools from Berlios.

You can install the plugin by using IntelliJ’s integrated plugin manager. If you’ve used it, please give me some feedback! I’d like it!

Read Full Post | Make a Comment ( 11 so far )

Liked it here?
Why not try sites on the blogroll...