Announcement Announcement Module
Collapse
No announcement yet.
Spring 2.5, JPA, JSF app AND toplink QueryException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring 2.5, JPA, JSF app AND toplink QueryException

    Hello together,

    I have a Spring 2.5 web application with JPA and JSF running on Glassfish and a PostgreSql database. Everything is running perfect on localhost but on a real enterprise Glassfish Server I'm getting the following error:
    Code:
    javax.servlet.ServletException: #{mybean.search}: Exception [TOPLINK-6137] (Oracle TopLink Essentials - 2.1 (Build b60e-fcs (12/23/2008))): oracle.toplink.essentials.exceptions.QueryException
    Exception Description: An Exception was thrown while executing a ReportQuery with a constructor expression: java.lang.NoSuchMethodException: com.company.util.CustomerDetail.<init>(com.company.db.Customer)
    Query: ReportQuery(com.company.db.Customer)
    after triggering the JPA query:
    Code:
    Query q = em.createQuery("SELECT NEW com.company.util.CustomerDetail(c) FROM Customer c");
        List<CustomerDetail> result = q.getResultList();
    applicationContext.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:p="http://www.springframework.org/schema/p" 
           xsi:schemaLocation="
               http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-2.5.xsd
               http://www.springframework.org/schema/tx
               http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
    
         <tx:annotation-driven />    
         <context:annotation-config/>
         <bean id="entityManagerFactory"
              class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
              p:dataSource-ref="dataSource" >        
            <property name="jpaVendorAdapter">
                <bean class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter"
                      p:databasePlatform="${jpa.databasePlatform}"
                      p:showSql="${jpa.showSql}" p:database="${jpa.database}" />
            </property>
            <property name="loadTimeWeaver" >
                <bean class="org.springframework.instrument.classloading.glassfish.GlassFishLoadTimeWeaver"/>
            </property>
        </bean>
    
        <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" 
              p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"  p:username="${jdbc.username}"
              p:password="${jdbc.password}" />    
    
        <bean id="propertyConfigurer"
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
              p:location="/WEB-INF/config/jdbc.properties" />
         <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>    
         <bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
    persistence.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence 
                        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
    
       <persistence-unit name="MyPU" transaction-type="JTA">
        <provider>oracle.toplink.essentials.PersistenceProvider</provider>
        <jta-data-source>jdbc/company</jta-data-source>
        <properties/>
      </persistence-unit>
    </persistence>
    Customer class looks like this
    Code:
    package com.company.db.Customer;
    
    import ...
    
    @Entity
    @Table(name = "Customer")
    public class Customer implements java.io.Serializable {
    
    //	private static final long serialVersionUID = 1L;
    
    	private String username;
    	private String password;
    	
    	public Customer() {
    	}
    
    	public Customer(String username, String password) {
    		this.username = username;
    		this.password = password;
    	}
    
    	@Id
    	@Column(name = "USERNAME", nullable = false, length = 50)
    	public String getUsername() {
    		return this.username;
    	}
    
    	public void setUsername(String username) {
    		this.username = username;
    	}
    
    	@Column(name = "PASSWORD", nullable = false, length = 50)
    	public String getPassword() {
    		return this.password;
    	}
    
    	public void setPassword(String password) {
    		this.password = password;
    	}
    ...
    }
    and CustomerDetail class
    Code:
    package com.company.util.CustomerDetail;
    
    import ...
    
    public class CustomerDetail implements java.io.Serializable {
    
    	private Customer user;
    	private String password;
    	private String username;
    	
    	public CustomerDetail() {
    	}
    
    	public CustomerDetail(Customer user) {
                  this.user=user
    	}
    setter...
    getter...
    and some methods...
    I tried different configurations but the TopLink Error above still remains on the enterprise Glassfish Server.
    Any suggestions?
    Thank you.
    Last edited by banifou; Dec 11th, 2009, 09:11 AM.

  • #2
    Further informations:
    on both machines are the same java version ("1.6.0_17") and Glassfish-v2.1 version running.
    The only difference between the two computers is that the localhost pc has a 64-bit processor.
    Last edited by banifou; Dec 9th, 2009, 05:59 PM.

    Comment


    • #3
      Does anybody have an idea?
      I tried everything I got in the web like the suggestions in this Thread http://forum.springsource.org/showthread.php?t=66216
      but nothing could make the problem solved.

      Why should the same app works fine on a Glassfish (developer mode) and not on another enterprise Glassfish?

      Please help

      Comment


      • #4
        Problem resolved

        I tried with EclipseLink, same problem.

        I finally managed to get Hibernate as JPA provider in Glassfish and Tataa the problem disappeared!
        Last edited by banifou; Dec 11th, 2009, 07:35 PM.

        Comment

        Working...
        X