2011-03-10

Problems with "org.hibernate.QueryException: unindexed collection before..."?

Hi again.

Lately, I have been struggling with the above issue when doing JPAQL query with Hibernate application on WebLogic 10.0.3 (Oracle 11g) server.

My setup to make the application work on WebLogic was:


  1. Remove all javax.* jars from WEB-INF/lib, including xml-api.jar and xerces

  2. Add weblogic.xml to WEB-INF with prefer-web-inf-classes set to true

  3. Set the hibernate property hibernate.query.factory_class to org.hibernate.hql.classic.ClassicQueryTranslatorFactory to avoid antlr class conflicts



Everything worked fine until I started to create som rather complex queries involving collections. Then I ended ut with "org.hibernate.QueryException: unindexed collection before..." exceptions.

The way I solved it was to replace the prefer-web-inf-classes setting in weblogic.xml with:

<prefer-application-packages>
  <package-name>antlr.*</package-name>
<prefer-application-packages>

and removing the hibernate property to use the ClassicQueryTranslatorFactory.

Then everything worked like a charm.

Hope this can help you resolve this issue :)

2009-01-04

LoadTimeWeaver in unit tests with EclipseLink

Are you having the following issue in your units test when using Spring and Maven with JPA?

java.lang.IllegalStateException: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation.

One solution that worked for me was to add the following in pom.xml:

<build>
  <plugins>
    <plugin>
      <artifactId>maven-surefire-plugin</artifactId>
      <configuration>
        <forkmode>pertest</forkmode>
        <argLine>-javaagent:${user.home}/.m2/repository/org/springframework/spring-agent/2.5.6/spring-agent-2.5.6.jar</argLine>
      </configuration>
    </plugin>
  </plugins>
  ...
</build>

In addition you have to make sure Maven has downloaded the artifact by adding this dependency:

<dependency>
  <groupid>org.springframework</groupid>
  <artifactid>spring-agent</artifactid>
  <scope>test</scope>
</dependency>