Hibernate Search and Glassfish

Using Hibernate Search in combination with Glassfish throws following Exception:

Add an additional

to your persitence.xml in order to use Hibernate JPA for Persistence Management.

Continue reading “Hibernate Search and Glassfish”

Message-Driven Beans, Message not send / received

When sending a message via JMS (transactions enabled) this message is not received by other MessageListener.

Add an additional session.commit(); before closing the session.

Continue reading “Message-Driven Beans, Message not send / received”

javax.jms.JMSException: no valid constructor

Deserialization causes Exception.


  1. Make sure all your classes, that are send trhough the wire, implement java.io.Serializable
  2. If your class extends other class(es), first class in inheritance tree, that does not implement java.io.Serializable, must provide a zero-argument standard-constructor!

NoClassDefFoundError while deploying EAR

  • Problem:
    When deploying an EAR (enterprise archive file) to an application server like JBOSS,
    is thrown.
  • Solution:
    Fix your EAR package structure.

    In Eclipse, go to EAR-Project properties, select "Java EE Module Dependencies" and toggle "In Lib Dir" for your shared Java Project
  • Further information:

    • All projects/files have been created with Eclipse
    • application.ear: Exported “Enterprise Application Project”
    • app-ejb.jar: Exported “Enterprise Java Beans Project”
    • app-web.war: Exported “Dynamic Web Project”
    • app-shared.jar: Exported “Java Project”, that contains classes that are used by more than one of the sub-projects. Can also be a third party jar-File with library classes.
    • Exception occurs, since app-web.war or app-ejb.jar may be deployed just before app-shared.jar has been deployed. A workaround for that would be to first deploy app-shared.jar separately and remove it from your enterprise application compilation.

EJB ClassCastException

  • Problem:
    [Ljava.lang.Object; cannot be cast to x.y.z.beanEJB: java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to x.y.z.beanEJB
  • Solution:
    Add a “SELECT” statement to your (named) query.
    e.g. change :

    FROM beanEJB e
    INNER JOIN e.tags AS t
    WHERE t LIKE :ttt


    SELECT e FROM beanEJB e
    INNER JOIN e.tags AS t
    WHERE t.string LIKE :ttt

  • Further information:
    A (named) query may return more than one distinct Object. An additional SELECT clause will specify the return type.
  • Code snippets:
    • </named-query>
      <named-query name=”namedQuery”>
      <![CDATA[SELECT e FROM beanEJB e
      INNER JOIN e.tags AS t
      WHERE t LIKE :ttt]]>

    • Query q = em.createNamedQuery(“namedQuery”);
      q.setParameter(“ttt”, s);