Archives 'Spring Framework'

18 June

In my former post (here) I described how to combine Spring WS with StAX parsing the SOAP messages. I ended with generating the WSDL as a test and said you could use Soap UI for testing the web service.
Well, I did. And I was running into the following error when I had deployed my web service at JBoss4.0.5.GA:

XML:
  1. <env:envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  2.    <env:header />
  3.    <env:body>
  4.       <env:fault>
  5.          <faultcode>env:Server</faultcode>
  6.          <faultstring>Operation only supported for javax.xml.soap.Node, this is a [#comment: Test comment]</faultstring>
  7.       </env:fault>
  8.    </env:body>
  9. </env:envelope>


Continue reading...


14 June

As I have posted before we are using XFire to implement our web service. Unfortunately, we are running into some serious issues with the framework, so we decided to look after another implementation. Since XFire is no longer supported by the community (or at least at a very low profile) and 'replaced' by CXF, we decided to have a look at Spring WS. We also have used the Spring Framework throughout our application elsewhere, so this would be a logical choice. After a quick look at the framework it convinced us that this would be the framework to use for our web services. It was easy to set up and well documented.
Continue reading...


25 July

As I posted before here I am using Quartz scheduler to schedule some batch jobs. It seemed to work fine but now while we were testing our application it appeared Quartz was showing some weird behaviour. I have scheduled 3 jobs, each with it's own trigger in one scheduler. However, 2 of the jobs are only triggered if the trigger of other remaining job has been fired before.
Continue reading...


28 June

In our project we have a webservice that receives a message, processes it and sends a response back. Very common for a webservice I think :-)
Now there was an extra request: log all messages in a database so we could get management info out of it, like in which hour of the day are we receiving the most messages, who is sending the most messages that are leading to errors, etc. In this post I will show you how I implemented this request.
Continue reading...


26 April

Just a small post about something I noticed in Quartz. I wanted to offer the user a screen with functionality so they could (re)schedule a batch job which then would do all kinds of batch stuf. To schedule the job in my application I used the following Java code:

JAVA:
  1. public void resetScheduleJob() throws CustomSystemException {
  2.  
  3.       StdScheduler scheduler = (StdScheduler)MyQueueContext.getContext().getBean("scheduler");
  4.  
  5.       CronTriggerBean trigger = (CronTriggerBean)MyQueueContext.getContext().getBean("batchProducerTrigger");
  6.  
  7.       try {
  8.            trigger.setCronExpression(getCronExpression());
  9.  
  10.            scheduler.scheduleJob(trigger.getJobDetail(), trigger);
  11.  
  12.       } catch (ParseException pe) {
  13.          throw new CustomSystemException (pe);
  14.       } catch (SchedulerException se) {
  15.          throw new CustomSystemException (se);
  16.       }
  17.       LOG.info("Next run will be at: " + trigger.getNextFireTime());
  18.    }
  19. }
  20. private String getCronExpression() {
  21.  
  22.       // Small trick to get the hours of the day correct.
  23.       String hours = null;
  24.       if (startTime> endTime) {
  25.          hours = endTime + "-23,0-" + startTime;
  26.       } else if (startTime <endTime) {
  27.          hours = startTime + "-" + endTime;
  28.       } else {
  29.          hours = "0";
  30.       }
  31.       return "0 0/" + interval + " " + hours + " ? * " + days;
  32.    }


Continue reading...


25 April

To store information in our PostgreSQL database we use Spring and Hibernate as I mentioned earlier in my posts. Some of our tables in the database also have GIS information with them. That's why we are also using PostGIS extension on our database. This GIS information (Geometry) is also reflected in the Hibernate objects we use to persist our data.
We have experienced that this Geometry data can be invalid, in which case the database (JDBC) is throwing an UncategorizedSQLException. This is the case, for example, when a Polygon has a different start and ending point.
In our application we have two kinds of exceptions: the CustomException (thrown and handled by ourselves) and all other exceptions not handled by us. With this distinction between the exceptions I can decide what to do when an exception occurs, for example, when storing data in the database: is it our CustomException, then it is most probably a problem with this instance and I will move to process the next instance. If there is thrown another Exception, then there is something seriously wrong and I will stop the processing.
Continue reading...


28 March

In my previous post I was rather enthousiastic about the Spring JMS library. However, that was before we did run some performance tests. It seemed that with using JMS Spring our code was at least 10 x slower then before! Although the code may be easier to maintain, this performance issue was unacceptable. For this reason I was browsing the internet and found this post. This nice post explains that there are situations in which using JMSTemplate is not the way to go. And apparently, that was the case in our code!
So after rewriting the code we had back our performance and still used some Spring JMS. This just proves Spring is not the solution to every problem.


12 March

Last week I discovered a piece of code in our project that didn't use Spring yet. It was the piece of code that used JMS to access some JBoss queues. Since we did use Spring everywhere in our code where it was possible, I decided to rewrite this piece so it also uses Spring (and so it also profits of all the advantages that Spring offers).
Continue reading...