Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8406967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:15:33+00:00 2026-06-09T23:15:33+00:00

I have a problem, hopefully someone can give me some hints. Environment: maven project

  • 0

I have a problem, hopefully someone can give me some hints.

Environment:

  • maven project with two modules

  • one module is the ‘model‘, and has DataNucleus 3.1, HSQLDB and Spring 3 dependencies. HSQLDB runs embedded, in memory, configured from spring applicationContext.xml

  • the other module is the ‘web’ and has GWT dependencies

The application is built using some Spring Roo generated code as basis, later modified and extended.

The issue is that, when starting the app and trying to load the data, I receive the exception:

 Class Document for query has not been resolved. Check the query and any imports specification; nested exception is javax.persistence.PersistenceException: Class Document for query has not been resolved. Check the query and any imports specification

The weirdest thing is that the sample roo-generated aplication used as basis, with exactly the same dependencies, but a different modularization works like a charm, without this symptom, so I am puzzled now…
Please also note that I tried to replace the ‘Document’ with the explicit qualification ‘com.myvdm.server.domain.Document’ in the query, with no positive result:

return entityManager().createQuery("SELECT COUNT(o) FROM Document o", Long.class).getSingleResult(); 

Another thing, although it might not be relevant, on every request, this exception is thrown:

 DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils - Unexpected exception on closing JPA EntityManager [INFO] java.lang.IllegalStateException: EntityManager is managed by a container (JEE) and so cannot be closed by calling the EM.close() method. Please read JPA2 spec 3.1.1 for the close() method.

The last exception is thrown by DataNucleus. It’s also confusing, since I do not run in a Java EE container, but GWT development mode.

Here’s the document entity:

@RooJavaBean
@RooToString
@RooJpaActiveRecord
public class Document {

    @NotNull
    private String name;

    @ManyToOne
    private DocumentType type;

    @OneToMany(fetch = FetchType.EAGER,
        cascade = CascadeType.ALL)
    private Set<Field> fields;
}

The annotation @RooJpaActiveRecord adds EntityManager operations but these are declared in a separate file – ITD(inter-type declarations)

Any suggestions, please?
Thanks a lot in advance.

———– EDIT ————–

privileged aspect Document_Roo_Jpa_ActiveRecord {

    @PersistenceContext
    transient EntityManager Document.entityManager;

    public static final EntityManager Document.entityManager() {
        EntityManager em = new Document().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

    public static long Document.countDocuments() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Document o", Long.class).getSingleResult();
    }

    public static List<Document> Document.findAllDocuments() {
        return entityManager().createQuery("SELECT o FROM Document o", Document.class).getResultList();
    }

    public static Document Document.findDocument(Long id) {
        if (id == null) return null;
        return entityManager().find(Document.class, id);
    }

    public static List<Document> Document.findDocumentEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Document o", Document.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }

    @Transactional
    public void Document.persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

    @Transactional
    public void Document.remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Document attached = Document.findDocument(this.id);
            this.entityManager.remove(attached);
        }
    }

    @Transactional
    public void Document.flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

    @Transactional
    public void Document.clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

    @Transactional
    public Document Document.merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Document merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }
}

@Entity declaration

privileged aspect Document_Roo_Jpa_Entity {

    declare @type: Document: @Entity;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long Document.id;

    @Version
    @Column(name = "version")
    private Integer Document.version;

    public Long Document.getId() {
        return this.id;
    }

    public void Document.setId(Long id) {
        this.id = id;
    }

    public Integer Document.getVersion() {
        return this.version;
    }

    public void Document.setVersion(Integer version) {
        this.version = version;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:15:35+00:00Added an answer on June 9, 2026 at 11:15 pm

    Ok, I found a fix for this problem.
    As I posted earlier, using Spring’s applicationContext.xml and persistence.xml files as basic configuration I could not make it work. I deleted persistence.xml and instead I used this configuration (please note the usage of packagesToScan property and passsing DataNucleus properties – and basically all the info that was traditionally inside persistence.xml):

     <bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" 
          id="entityManagerFactory">
        <property name="persistenceUnitName" value="persistenceUnit"/>
        <property name="packagesToScan" value="com.myvdm.server.domain"/>
        <property name="persistenceProviderClass" value="org.datanucleus.api.jpa.PersistenceProviderImpl"/>
        <property name="jpaPropertyMap">
            <map>
                <entry key="datanucleus.ConnectionDriverName" value="org.hsqldb.jdbc.JDBCDriver"/>
                <entry key="datanucleus.storeManagerType" value="rdbms"/>
                <entry key="datanucleus.ConnectionURL" value="jdbc:hsqldb:mem:myvdm"/>
                <entry key="datanucleus.ConnectionUserName" value="sa"/>
                <entry key="datanucleus.ConnectionPassword" value=""/>
                <entry key="datanucleus.autoCreateSchema" value="true"/>
                <entry key="datanucleus.autoCreateTables" value="true"/>
                <entry key="datanucleus.autoCreateColumns" value="false"/>
                <entry key="datanucleus.autoCreateConstraints" value="false"/>
                <entry key="datanucleus.validateTables" value="false"/>
                <entry key="datanucleus.validateConstraints" value="false"/>
                <entry key="datanucleus.jpa.addClassTransformer" value="false"/>
            </map>
        </property>
        <property name="dataSource" ref="dataSource"/>
    </bean>
    

    So this is the only way I could make it work, could this be a Spring bug?

    And about that second (minor) issue, obviously the exception will be thrown since I am using Spring’s LocalContainerEntityManagerFactoryBean 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hopefully someone can help me with a slight problem/confusion I have with Viewpagers and
Let me explain my problem, and hopefully someone can offer some good advice. I
Hopefully someone can give me a pointer. I have an application that makes several
Hopefully someone can explain some behavior to me. I have a JSF page with
hopefully someone can help me with this odd problem. I have a database which
I have a weird date rounding problem that hopefully someone can solve. My client
Have a bit of a weird one and hopefully someone can help out. The
Hopefully someone can help me with this problem. I'm starting to work with Drupal
This is a problem I regularly bump into - hopefully someone can clarify to
I'm developing a Spring web app and am hoping someone can give me some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.