11 Şubat 2010 Perşembe

java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V when deploying to glassfish

i have recently downloaded glassfish v2.1.1 and got the following error while trying to deploy my app:

javax.persistence.PersistenceException: No Persistence provider for EntityManager named CleanerPU: Provider named org.hibernate.ejb.HibernatePersistence threw unexpected exception at create EntityManagerFactory:
java.lang.NoSuchMethodError
java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.(Z)V
at net.sf.cglib.core.DebuggingClassWriter.(DebuggingClassWriter.java:47)
...

i googled for a while and found: http://tai-dev.blog.co.uk/2010/01/21/nosuchmethoderror-org-objectweb-asm-classwriter-when-deploying-your-app-to-a-new-instance-of-glassfish-v2-1-1-it-looks-like-the-upgraded-fins-are-7849068/
according to the link this is due to lib differences between glassfish v2.1.0 and v2.1.1
and the solution is manually deleting the asm-3.1.jar file in the glassfish-install-dir/lib/directory and copy an old version of asm-.jar in its place. i replaced with the asm.jar coming with netbeans 6.5.1 ide and it worked!

trouble in persisting type List <String> in jpa

Trying to persist an attribute with type List causes trouble in jpa.
here is a link: http://stackoverflow.com/questions/287201/how-to-persist-a-property-of-type-liststringin-jpa
the solution is changing from List to String with separated values with delimiter..
the explanation by Bill James at Nov 13 '08 at 15:34 (the above link) seems good..

10 Şubat 2010 Çarşamba

OpenJms

in this post, i note down some links related to openjms and i try to give a summary.. here is my prev post on the issue: http://hilaltarakci.blogspot.com/2010/02/intro-to-jms.html

http://www.devx.com/Java/Article/20903
here is a presentation about openjms: http://www.oreillynet.com/pub/d/834
a summary from the presentation by Jim Alateras:
  • two messaging models: Queues(point to point), Topics(publish and subscribe)
  • two message delivery modes: persistent (provider attempts to deliver the message at most once to the consumer. If the consumer is unavailable, provider persist the message and deliver it when the consumer is reactivated. ), non-persistent ( provider attempts to deliver non-persistent messages at most once. If the consumer is unavailable or inactive, then consumer will never receive the message. Non persistent messages should only be used if the subscribers can tolerate lost messages.)
  • five message types: text, byte, object map and stream. most applications use xml.
  • syncronous (consumers pull messages from the provider by calling receive ) & asyncronous (if consumer registers a listener, provider push messages to consumer ) message consumption
  • selectors, used by consumers to selectively process messages
  • 10 priority levels 1 being the lowest and 10 being the highest. Publishers assign priority levels to messages, which effect the order that they are queued by provider.
  • QueueBrowser, specific to queue destinations and is used to browse messages on a queue.
  • two transaction modes Local( use the chained transaction model and applied to transacted sessions) & Distributed (use 2 phase commit protocol and are defined by a set of XA interfaces. XA interfaces are part of the advanced server facility)

Queues:

  • Senders publish messages to queue and receivers consumer messages of queue.More than one sender or receiver can be attached to queue.
  • Messages on a queue are delivered to only one consumer and JMS does not define delivery semantics when more than one subscriber is attached to the queue. a message is only sent to one of the registered subscribers.
  • Priority effects the order that messages are queued for delivery. Higher priority messages are queued for delivery before lower priority messages
  • Non-persistent messages delivered at most once.
  • Persistent messages delivered exactly once.

Topics:

  • Publishers publish messages and subscribers consume them. A topic with once subscriber and one publisher acts similar to a queue.
  • When you have multiple publishers and subscribers ,the publishers send messages to the provider, who queues them for delivery and then each of the subscribers receive a copy of each published message.
  • As for Queues priority effects the order that messages queued for delivery and selectors effect the order that messages are consumed.
  • Similar to queues persistent and non-persistent delivery

9 Şubat 2010 Salı

intro to jms

some starters:
first attack:
http://java.sun.com/products/jms/tutorial/1_3_1-fcs/doc/jms_tutorialTOC.html
here is a simple jms example, a chat application: http://onjava.com/pub/a/onjava/excerpt/jms_ch2/index.html?page=1
with glassfish: http://today.java.net/article/2008/01/18/jms-messaging-using-glassfish
http://javadude.wordpress.com/2009/01/03/tutorial-starting-with-glassfish-and-jms/
unfortunately, i could not deploy the sample in this address, got the following error:

LDR5010: All ejb(s) of [MyJMS] loaded successfully!
Error attempting to process extensions from the manifest of JAR file /home/hilal.tarakci/htarakci/balistika2010sas/client/MyJMS/dist/gfdeploy/MyJMS-ejb.jar; ignoring it and continuing
java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:114)
...


So, lets move to OpenJms, http://openjms.sourceforge.net/.. (this is second attack, the example successfully worked.)
getting started: http://openjms.sourceforge.net/gettingstarted.html, excellent documentation support!
topic1 and queue1 are predefined topic and queue in jms.. they can be used to run the example coming with openjms package.