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 1838612
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:30:06+00:00 2026-05-17T06:30:06+00:00

This is the directory structure of the project (maven2 is used): pom.xml /src /main

  • 0

This is the directory structure of the project (maven2 is used):

pom.xml
/src
  /main
    /java
      Abc.java
    /resources
      hibernate.cfg.xml
      database.properties
      /META-INF
        persistence.xml
  /test
    /java
      AbcTest.java
    /resources
      database.properties

This is the content of hibernate.cfg.xml:

<hibernate-configuration>
  <session-factory name="java:hibernate/SessionFactory">
    <property name="hibernate.archive.autodetection">true</property>
  </session-factory>
</hibernate-configuration>

This is what I have in persistence.xml:

<persistence>
  <persistence-unit name="abc">
    <jta-data-source>java:/abcDS</jta-data-source>
    <properties>
      <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
    </properties>
  </persistence-unit>
</persistence>

And this is my Abc.java file:

import javax.persistence.*;
@Entity
public class Abc {
  @Id private int id;
}

After running mvn clean hibernate3:hbm2ddl I’m getting this output:

18:45:55,770  INFO org.hibernate.tool.hbm2ddl.SchemaExport - writing 
generated schema to file: ../target/hibernate3/sql/schema.ddl
18:45:55,770  INFO org.hibernate.tool.hbm2ddl.SchemaExport - schema export complete
[INFO] ————————————————————————————————————
[INFO] BUILD SUCCESSFUL

File schema.ddl is created, and it’s empty. Why? And besides that, what is wrong in my configuration files? Since when I’m trying to run unit tests with PersistenceContext injections they fail with NullPointerException. Looks like there is some problem in the configuration. Can’t find any manual online…

PS. There are two problems, I found them already. The first one is here (extra prefix should be removed):

<property name="archive.autodetection">true</property>

The second one is more interesting. When I’m running mvn hibernate3:hbm2ddl after compilation it works (because it has .class files to work with). Otherwise the schema is empty.. How to instruct this plugin to compile java classes beforehand?

  • 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-05-17T06:30:06+00:00Added an answer on May 17, 2026 at 6:30 am

    There are two problems, I found them already. The first one is here (extra prefix should be removed)

    Indeed. So I’ll skip this one.

    How to instruct this plugin to compile java classes beforehand?

    Not possible (but the other way around would be, i.e. running the plugin after compile, as we’ll see).

    The fact is that the Hibernate3 Maven Plugin, which predates annotations, has been initially designed to deal with hbm.xml mapping files. And that’s why hibernate3:hbm2ddl invokes the execution of the lifecycle phase process-resources prior to executing itself.

    When using annotation instead of XML files for the mappings, the goal would indeed have to run after the compile phase (the process-classes phase would be a natural candidate) but that’s not the current behavior of hibernate3:hbm2ddl.

    So you’ll have to run compile before invoking the goal:

    mvn compile hibernate3:hbm2ddl
    

    The other option would be to bind the hibernate3:hbm2ddl on the build lifecycle, e.g. on process-classes:

    <project>
      ...
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>hibernate3-maven-plugin</artifactId>
            <version>2.2</version>
            <executions>
              <execution>
                <phase>process-classes</phase><!-- compile would also work -->
                <goals>
                  <goal>hbm2ddl</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      ...
    </project>
    

    And then just run process-classes to trigger the plugin:

    mvn process-classes
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here is the structure of my project. proj ---src ----main ----java ----Main.java ----resources ----res.txt
I have this directory structure. In my project root directory I have a main
I have a python project with this directory structure and these files: /home/project_root |---__init__.py
I have a directory structure that looks like this: /a/f.xml /b/f.xml /c/f.xml /d/f.xml What
I have a project where the directory structure is like this: $projectroot | +---------------+----------------+
I have a Python project with the following directory structure: project/ project/src/ project/src/somecode.py project/src/mypackage/mymodule.py
Imagine this directory structure: app/ __init__.py sub1/ __init__.py mod1.py sub2/ __init__.py mod2.py I'm coding
For this directory structure: . |-- README.txt |-- firstlevel.rb `-- lib |-- models |
the directory structure I'm trying to achieve would be this: application/default/views/layouts/layout.phtml application/default/views/scripts/index/index.phtml application/admin/views/layouts/layout.phtml application/admin/views/scripts/index/index.phtml
I am a beginner in SVN.I have the SVN directory structure like this: |-trunk

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.