Pages

Thursday, April 22, 2010

Running OpenPortal on Jetty

While running OpenPortal's portlet container on Jetty I've encountered the following error on a portlet deployment attempt:

SEVERE: PSPCD_CSPPD0023
java.lang.IllegalArgumentException: contextHandlerCollection should have been initialized in Jetty config
at com.sun.portal.portletcontainer.admin.deployment.JettyWebAppDeployer.deploy(JettyWebAppDeployer.java:88)
at com.sun.portal.portletcontainer.admin.mbeans.PortletAdmin.deploy(PortletAdmin.java:127)
at com.sun.portal.portletcontainer.driver.admin.PortletAdminDataImpl.deploy(PortletAdminDataImpl.java:78)
at com.sun.portal.portletcontainer.driver.admin.UploadServlet.deployPortlet(UploadServlet.java:149)
at com.sun.portal.portletcontainer.driver.admin.UploadServlet.uploadFile(UploadServlet.java:119)
at com.sun.portal.portletcontainer.driver.admin.UploadServlet.doPost(UploadServlet.java:80)


To fix this, I've added the following lines to my jetty.xml:
<Call 
  class="com.sun.portal.portletcontainer.admin.deployment.JettyWebAppDeployer"  
  name="setHandlerCollection">
    <!-- assuming that Handlers are configured by default -->
    <Arg><Ref id="Handlers"/></Arg>
</Call>

Friday, April 16, 2010

uCertify promotional codes

I have done reviews for uCertify PrepKits previously:

1) uCertify's PrepKit for SCJP6.0
2) uCertify's PrepKit for SCBCD5.0

Now, uCertify is giving out 20% discount on all its PrepKits. Use promotional code SPRING during the checkout to avail this offer. This offer is valid until 20 April, 2010 and it will work on all uCertify PrepKits. Full details of the sale can be found here.


Overall, it is a good investment if you're preparing for a professional certification. Good luck!

Saturday, February 20, 2010

Agile Saturday #1 in Tallinn

Agile Estonia has held its 1st event, called Agile Saturday. Here's the speech by Vasco Duarte (Agile Finland), the agile coach at Nokia:

Agile Saturday #1 Keynote by Vasco Duarte from Anton Arhipov on Vimeo.


See the other videos from the event at agile.ee.

Sunday, January 17, 2010

Continuing the BigDecimal's Game: Scala vs Clojure

After studying the issues with decimal types in Groovy and JRuby, with lafy, we discovered some funny things in Scala and Clojure as well.


Consider, if you need to accumulate 0.1 until the result is one. Groovy does it as expected


0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 + 0.1 = 1.0


Just because 0.1 is BigDecimal in Groovy.


In Clojure, the example is not that nice:


(+ 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1 0.1) results in 0.9999999999999999.


Basically, the problem is solved when you add the M qualifier to each of the numbers in the expression, like 


(+ 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M 0.1M) = 1.0


Or use rational numbers:

(+ 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10 1/10) = 1.0


The hypothetical problem is that, if a number (say, some money amount) is stored in the database, and the calculation is configured by the user in business rules via some DSL, then a user could create a calculation that   could lead to a loss of precision. For instance:


(* 100M 1.1) = 110.00000000000001
(class (* 100M 1.1)) = java.lang.Double


Double there is!!!


The same kind calculation gives BigDecimal as a result in Scala:


scala.BigDecimal(1.5) * 1.5
BigDecimal = 2.25


The question is what is the rationale behind such behavior and which result is correct? To me, when writing an application which operates with monetary amounts, it is the Scala which is correct.





Sunday, October 11, 2009

uCertify's PrepKit for SCJP6.0

NB! The blog readers are entitled to a 10% discount for PrepKit software, and the discount code is UCPREP.

I had a possibility to evaluate uCertify's PrepKit software again. The last time I have evaluated the PrepKit package for SCBCD5.0 exam. This time I have evaluated the package that is intended for Sun Certified Programmer for the Java Platform SE 6 exam preparation. The software itself could be downloaded from the uCertify website.



I really liked how the practice tests are organized and the way you can combine the tests while studying.
The GUI is quite intuitive and you can easily navigate within the software. It was even quite comfortable to use on my 10.1'' netbook's screen.

Study and learn

You can find the "Study and Learn" section on the main screen. This is where you can study the material broken into topics by the content, and this is where the not-so-nice facts appear when using this PrepKit.



First of all, the explanations for the study material look quite boring. Just see the next screenshot - it just text, not attractive at all, and probably it will not even engage the users to read it. I do not know what to suggest (I'm not a usability expert) but it seems that this is a challenge for a professional designer to make such screens "sing".



Another strange example of the studies section behavior is when you are given a test question with a code snipper, like this:







To see the correct answer for this question you have to move forward with the 'next' button, which is quite inconvenient. Instead, it should have a 'show answer' button for this particular question. IMHO, this a usability issue again.

Questions in PrepKit

This PrepKit contains quite a lot of tests, easy and difficult ones. This is good when you have a lot of questions inside the package, specially in case you have paid for this software.

But lets be more critical. My annoyance comes from the text in the questions provided by this PrepKit - a-la "Mark works as a programmer in...", "Stella writes a program for ...", "Joe works as a programmer for...". I'm asking you now - who the hell cares?!?! This kind of text takes ~10% of my time to read this question and gives no value to it. This should definitely be amended. Here are some screenshots showing this issue.

Here's the small example ..



Here's an other one ..



And here's what it will look like after you have completed the test and want to see the result:



Meaningless, isn't it? OK, not that negative :), but it could be better without such sentences.

An other frustrating thing is the bad-formatted code and strange naming of the classes/variables. Perhaps, this is due to make the questions look exactly like in Sun's certification exam? Here are some screenshots:






The negative examples aside, the tests are well-prepared and there's a variety of questions that will make you think deeper, which parts of the exam you need to learn more. For me the good example is the drag'n'drop-like questions:





Explanations

The explanations for the test a rather comprehensive, but sometimes you may find some mistakes, like this one:



The code snippet looks odd, doesn't it?

Overall it is a very good idea to the the user not only if his answer was correct or not, but also explain, why was it correct or why it was incorrect.

Summary

I'm very sure that uCertify's PrepKit software is a good choice if you are looking for a training materials for Java certification. Although, the PrepKit still has some flaws in it, still with the continuous improvement and a discount code (UCPREP) it is a good investment in your education.

Sunday, October 4, 2009

My Complains To JMS

JMS is a mess! I do not understand, why it should be so complicated!?

Take a look at this example:

public boolean sendMessage() throws Exception {
      Connection connection = null;
      InitialContext initialContext = null;
      try {
         //Step 1. Create an initial context to perform the JNDI lookup.
         initialContext = getContext(0);

         //Step 2. Perfom a lookup on the queue
         Queue queue = (Queue) initialContext.lookup("/queue/exampleQueue");

         //Step 3. Perform a lookup on the Connection Factory
         ConnectionFactory cf = (ConnectionFactory) 
                                initialContext.lookup("/ConnectionFactory");

         //Step 4.Create a JMS Connection
         connection = cf.createConnection();

         //Step 5. Create a JMS Session
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

         //Step 6. Create a JMS Message Producer
         MessageProducer producer = session.createProducer(queue);

         //Step 7. Create a Text Message
         TextMessage message = session.createTextMessage("This is a text message");
         
         System.out.println("Sent message: " + message.getText());

         //Step 8. Send the Message
         producer.send(message);

         //Step 9. Create a JMS Message Consumer
         MessageConsumer messageConsumer = session.createConsumer(queue);

         //Step 10. Start the Connection
         connection.start();

         //Step 11. Receive the message
         TextMessage messageReceived = (TextMessage) messageConsumer.receive(5000);

         System.out.println("Received message: " + messageReceived.getText());

         return true;
      } finally {
         //Step 12. Be sure to close our JMS resources!
         if (initialContext != null) {
            initialContext.close();
         }
         if(connection != null) {
            connection.close();
         }
      }
   }

You have to make 12 (!!!) steps to send and receive the message correctly. I think that most of the steps could be amended so that JMS spec would provide some default behavior.

Luckily, you can write same code with Camel:

from("bean:myBean?methodName=send").to("jms:queue:exampleQueue");
   from("jms:queue:exampleQueue").to("bean:myBean?methodName=receive");

Disqus for Code Impossible