-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: AssertionError thrown only when running in maven
PostPosted: Tue Mar 27, 2007 7:04 pm 
Newbie

Joined: Tue Mar 27, 2007 6:48 pm
Posts: 1
Location: Portland, Oregon
I'm having really weird issues where I can run all my tests in Idea with no problem (using same classpath/config/etc via Maven reloaded) and everything is fine. When I attempt to run the tests in Maven proper (i.e. mvn install) I'm having this assertion issue. Any help would be appreciated!

Hibernate version:
3.2.2.ga + 3.2.1.ga (annotations)

Mapping documents:

Code between sessionFactory.openSession() and session.close():
App blows up before sessionFactory is open...

Full stack trace of any exception that occurs:

where the only assert in AnnotationBinder.getElementsToProcess is this line: assert ! inheritanceState.isEmbeddableSuperclass;


org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.AssertionError
Caused by: java.lang.AssertionError
at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:770)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:622)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:804)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:744)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1118)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1085)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:429)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:250)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:247)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:161)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:270)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:346)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:92)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:68)


Name and version of the database you are using:
mysql 5.0.24

The generated SQL (show_sql=true):
n/a

Debug level Hibernate log excerpt:
INFO

Problems with Session and transaction handling?

no.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 07, 2007 2:10 pm 
Newbie

Joined: Sat Apr 07, 2007 2:08 pm
Posts: 1
I also have the same error as follow:


testFindPersonByLastName(com.feihoo.techmanager.dao.ProjectDAOTest) Time elapsed: 0.469 sec <<< ERROR!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [jar:file:/C:/Documents%20and%20Settings/liuzhr.ETHER/.m2/repository/org/appfuse/appfuse-hibernate/2.0-m4-SNAPSHOT/appfuse-hibernate-2.0-m4-SNAPSHOT.jar!/applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.AssertionError
Caused by: java.lang.AssertionError
at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:770)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:622)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1143)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:281)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:199)
at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:179)
at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:158)
at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:105)
at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:87)
at junit.framework.TestCase.runBare(TestCase.java:128)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)

testAddAndRemovePerson(com.feihoo.techmanager.dao.ProjectDAOTest) Time elapsed: 0.468 sec <<< ERROR!
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in URL [jar:file:/C:/Documents%20and%20Settings/liuzhr.ETHER/.m2/repository/org/appfuse/appfuse-hibernate/2.0-m4-SNAPSHOT/appfuse-hibernate-2.0-m4-SNAPSHOT.jar!/applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.AssertionError
Caused by: java.lang.AssertionError
at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:770)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:622)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:452)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:268)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1283)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:805)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:745)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:134)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1143)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:431)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:251)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:281)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.test.AbstractSingleSpringContextTests.createApplicationContext(AbstractSingleSpringContextTests.java:199)
at org.springframework.test.AbstractSingleSpringContextTests.loadContextLocations(AbstractSingleSpringContextTests.java:179)
at org.springframework.test.AbstractSingleSpringContextTests.loadContext(AbstractSingleSpringContextTests.java:158)
at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:105)
at org.springframework.test.AbstractSingleSpringContextTests.setUp(AbstractSingleSpringContextTests.java:87)
at junit.framework.TestCase.runBare(TestCase.java:128)
at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)


Top
 Profile  
 
 Post subject: Any Solution Found for this?
PostPosted: Thu Sep 11, 2008 9:52 am 
Newbie

Joined: Thu Sep 11, 2008 9:42 am
Posts: 1
I am having the same issue and am wondering if a solution was ever discovered for this issue. Thank you in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 26, 2008 9:35 am 
Newbie

Joined: Thu Sep 14, 2006 12:08 pm
Posts: 19
I am having the same problem after I added a new root class to my class hierarchy and annotated the new root with @MappedSuperclass.

The code in question seems to be in method getElementsToProcess in class:

http://viewvc.jboss.org/cgi-bin/viewvc.cgi/hibernate/annotations/trunk/src/java/org/hibernate/cfg/AnnotationBinder.java?revision=14761&view=markup&pathrev=14761

The code looks like:

assert !inheritanceState.isEmbeddableSuperclass;

Can someone from hibernate team please comment on why this assertion is there?

Does hibernate not support the @MappedSuperclass annotation? If it is supported then what condition could cause the above assertion to fail?

If it is a bug then please let us know a workaround, where is the issue logged and if not logged let us know to file one.

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 27, 2008 7:36 am 
Newbie

Joined: Sat Sep 27, 2008 7:21 am
Posts: 1
Hi all,

I have bumped into the same problem as well.

My configuration:

Maven version: 2.0.8
Java version: 1.6.0_04
OS name: "linux" version: "2.6.24-19-generic" arch: "i386" Family: "unix"


I have developed a number of unit tests that use spring framework, hibernate and hibernate-annotations. All worked fine until I started using the @mappedsuperclass annotation. If I run the unit tests using Eclipse (Ganymede) with the built-in JUnit runner, everything runs perfectly fine. However, if I run the tests using mvn test from the console, then I'm getting the same error as stated on the previous post.

From my pom.xml:

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring</artifactId>
<version>2.5.5</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.1.GA</version>
</dependency>

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate</artifactId>
<version>3.2.6.ga</version>
</dependency>

Exception trace:
....

Caused by: java.lang.AssertionError
at org.hibernate.cfg.AnnotationBinder.getElementsToProcess(AnnotationBinder.java:817)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:666)
at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:534)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:286)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:673)
at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1368)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1334

Any help on debugging/solving the issue would be highly appreciated.

Regards,
Al.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 28, 2008 5:22 pm 
Newbie

Joined: Sun Sep 28, 2008 5:16 pm
Posts: 1
If you have an @Entity annotation on your mapped super class try removing it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 29, 2008 6:48 am 
Newbie

Joined: Fri Aug 27, 2004 5:21 am
Posts: 1
I am having the same problem too. Just want to know if anyone has found a solution to this issue.

I am developing an application using Spring and Hibernate (Hibernate core 3.3.1 and Annotations 3.4.0), and have written some DAO and unit test for them (using JUnit 4).

I can run the tests in Eclipse without any problem.

However, I got the same "AssertionError" when run "mvn test" in DOS prompt.

My entity classes are like this:

Base class:
@MappedSuperclass
public class BaseEntity implements Identifiable, Serializable {

private static final long serialVersionUID = 1L;

@Id
@GeneratedValue(generator = "hibernate-uuid")
@org.hibernate.annotations.GenericGenerator(
name = "hibernate-uuid",
strategy = "uuid"
)
@Column(name = "id")
private String id;

public String getId() {
return id;
}

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

}

Entity class:
@Entity
@Table(name="BATCH_JOB_INSTANCE")
@NamedQueries(value = {
@NamedQuery(name = "BatchJob.getByJobName",
query = "from BatchJob b where jobName=? order by b.id desc")
})
public class BatchJob implements Serializable {

private static final long serialVersionUID = 1L;

@Id
@Column(name="JOB_INSTANCE_ID")
private Long id;

@Column(name="JOB_NAME")
private String jobName;

@Column(name="JOB_KEY")
private String jobKey;

@OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
@JoinColumn(name="JOB_INSTANCE_ID")
private Set<BatchJobExecution> batchJobExecutions;

public Long getId() {
return id;
}

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

public String getJobName() {
return jobName;
}

public void setJobName(String jobName) {
this.jobName = jobName;
}

public String getJobKey() {
return jobKey;
}

public void setJobKey(String jobKey) {
this.jobKey = jobKey;
}

public Set<BatchJobExecution> getBatchJobExecutions() {
return batchJobExecutions;
}

}

I just can't figure out why it fail in Maven while success in Eclipse.

Any advice or clue is much appreciated.
Clarence

_________________
Working in Hong Kong


Top
 Profile  
 
 Post subject: Re: AssertionError thrown only when running in maven
PostPosted: Wed Oct 07, 2009 10:49 am 
Newbie

Joined: Wed Oct 07, 2009 10:32 am
Posts: 1
I also ran across this problem and was able to disable runtime assertions during a maven test by specifying -disableassertions in the <argLine> maven plugin configuration element. In my research I found that java runtime assertions are normally, by default, disabled (incuding running in JUnit), but they are enabled by default in maven.

The assertion in our case is due to our including a class with the @MappedSuperclass annotation in an array of annotated classes as an argument to AnnotationSessionFactoryBean.setAnnotatedClasses(). The class we included actually has both the @MappedSuperclass and @Table annotations. According to the annotation javadocs, a mapped superclass "has no separate table defined." We are evaluating which of the two annotations are correct for our class.


Top
 Profile  
 
 Post subject: Re: AssertionError thrown only when running in maven
PostPosted: Sat Nov 07, 2009 3:59 pm 
Newbie

Joined: Tue Dec 04, 2007 6:24 am
Posts: 13
I have the same problem with @MappedSuperclass and @Entity but no @Table annotation.
removing the @Entity is not an option for me.

adding this to my POM does the trick :
Code:
            <plugin>
               <groupId>org.apache.maven.plugins</groupId>
               <artifactId>maven-surefire-plugin</artifactId>
               <configuration>
                  <enableAssertions>false</enableAssertions>
               </configuration>
            </plugin>


but still I would like to know what is wrong with having both @MappedSuperclass and @Entity
can someone explain please?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.