The abstract schema type 'sec$User' is unknown

I need to build a business web app which will update an existing relational database (designed by others of which I don’t have permission to create tables). So this is what I have done so far.

  1. Reverse engineered the database and placed those entities into a persistence unit called “default”.
  2. Within another database that I have full control over, I have build the standard CUBA tables, etc. I called this persistence unit “cuba”. I have listed all the CUBA entities in the “cuba” persistence unit.
  3. I have added spring-instrument and spring-instrument-tomcat jar files to ${CATALINA_HOME}/lib

I can now start the app without any exceptions in the log, and then when I attempt to log in (admin/admin) I get the following exception

Caused by: org.eclipse.persistence.exceptions.JPQLException:
Exception Description: Problem compiling [select u from sec$User u where u.loginLowerCase = ?1 and ( = true or is null)].
[14, 22] The abstract schema type 'sec$User' is unknown.
[31, 47] The state field path 'u.loginLowerCase' cannot be resolved to a valid type.
[58, 66] The state field path '' cannot be resolved to a valid type.
[77, 85] The state field path '' cannot be resolved to a valid type.
        at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildException( ~[eclipselink-2.6.1.cuba7.jar:2.6.1.cuba7]
        at org.eclipse.persistence.internal.jpa.jpql.HermesParser.validate( ~[eclipselink-2.6.1.cuba7.jar:2.6.1.cuba7]
        at org.eclipse.persistence.internal.jpa.jpql.HermesParser.populateQueryImp( ~[eclipselink-2.6.1.cuba7.jar:2.6.1.cuba7]
        at org.eclipse.persistence.internal.jpa.jpql.HermesParser.buildQuery( ~[eclipselink-2.6.1.cuba7.jar:2.6.1.cuba7]
        at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery( ~[eclipselink-2.6.1.cuba7.jar:2.6.1.cuba7]
        at org.eclipse.persistence.internal.jpa.EJBQueryImpl.buildEJBQLDatabaseQuery( ~[eclipselink-2.6.1.cuba7.jar:2.6.1.cuba7]
        at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>( ~[eclipselink-2.6.1.cuba7.jar:2.6.1.cuba7]
        at org.eclipse.persistence.internal.jpa.EJBQueryImpl.<init>( ~[eclipselink-2.6.1.cuba7.jar:2.6.1.cuba7]
        at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery( ~[eclipselink-2.6.1.cuba7.jar:2.6.1.cuba7]
        ... 72 common frames omitted

Any suggestions?


Perhaps the EntityManagerFactory which is used by CUBA mechanisms is initialized from your non-standard persistence unit. Add the following element to your spring.xml in core module:

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
        <property name="persistenceXmlLocation" value="file:${cuba.dataDir}/persistence.xml"/>
        <property name="dataSource" ref="cubaDataSource"/>
        <property name="jpaVendorAdapter" ref="jpaVendorAdapter"/>
        <property name="persistenceUnitName" value="cuba"/>

Here the settings from cuba-spring.xml are duplicated and the name of persistence unit is added explicitly.

Thanks for the tip.
I got over this problem by

  1. Rebuilt the app from scratch and pointed to the existing cuba database and all worked well.
  2. Introduced the second persistence unit into the global/persistence.xml, ensuring I didn’t overwrite the standard cuba persistence unit.
  3. And finally, introduced the foreign (non cuba related) datasource, entityManagerFactory and transactionManager into core/spring.xml

Once this was done, the above problem went away.