-->
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.  [ 7 posts ] 
Author Message
 Post subject: org.hibernate.AnnotationException: No identifier specified f
PostPosted: Fri Dec 28, 2007 4:12 pm 
Newbie

Joined: Fri Dec 28, 2007 3:37 pm
Posts: 9
First things first ... the exception is very clear .... however, I really believe that I have specified an @Id - but it's obviously not being recognized/located in the superclass. What am I missing or doing wrong? I'm using JBoss AS 4.2.1.GA with it's included hibernate version (according to JBoss AS 4.2.1.GA release notes - Hibernate, hibernate-annotations and hibernate-entity-manager have all been upgraded. to v3.2.1 in that release.).

Please forgive the beginner question, but I've been searching for hours and keep coming up with the same Incomplete deployment error:

org.hibernate.AnnotationException: No identifier specified for entity: x.y.z.DefaultMyEvent

I'm also sorry if this is the wrong place for this question.

I'd appreciate any and all help as I am stuck!

TIA!


I have a base class such as:



Code:

@MappedSuperclass
public class DefaultEventBase
    implements IEventBase, Serializable
{

.....
    @Id
    @Column( name="ID", unique=true, nullable=false, updatable=false )
    public String getID()
    {
   return id_;
    }


.......
}



and a derived class such as:

Code:



@Entity
@Table( name="EVENTS", schema="foo",
   uniqueConstraints={@UniqueConstraint( columnNames="ID" )})
public class DefaultMyEvent
    extends DefaultEventBase
    implements ISMSEvent, Serializable
{

..... all other @Column definitions are here

}


I have a persistence.xml such as:

Code:


<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
 
  <persistence-unit name = "foobar"
                  transaction-type = "JTA">
        
     <provider>org.hibernate.ejb.HibernatePersistence</provider>
    
     <jta-data-source>java:/MyDS</jta-data-source>
    
     <mapping-file>META-INF/orm.xml</mapping-file>

     <class>x.y.z.DefaultEventBase</class>    
     <class>x.y.z.PayloadItem</class>
     <class>x.y.z.DefaultMyEvent</class>
    
     <properties>
          <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
          <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
          <property name="hibernate.format_sql" value="true"/>
     </properties>
  </persistence-unit>
</persistence>




Finally, I have an empty orm.xml (as everything is specified via Annotations) such as:


Code:


<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" version="1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm_1_0.xsd">
 
</entity-mappings>




The associated stack trace shows:

Code:



        at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:627)
        at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.
java:452)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:
268)
        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
        at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
        at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:154)

        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
        at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersi
stence.java:126)
        at org.jboss.ejb3.entity.PersistenceUnitDeployment.start(PersistenceUnitDeployment.java:246)

        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:597)
        at org.jboss.ejb3.ServiceDelegateWrapper.startService(ServiceDelegateWrapper.java:103)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)

        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy90.start(Unknown Source)
        at org.jboss.ejb3.JmxKernelAbstraction.install(JmxKernelAbstraction.java:120)
        at org.jboss.ejb3.Ejb3Deployment.startPersistenceUnits(Ejb3Deployment.java:627)
        at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:351)
        at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
        at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)

        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
        at $Proxy0.start(Unknown Source)
        at org.jboss.system.ServiceController.start(ServiceController.java:417)
        at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy33.start(Unknown Source)
        at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:512)
        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:597)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterce
ptor.java:142)
        at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
        at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport
.java:238)
        at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
        at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInt
erceptorSupport.java:188)
        at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy34.start(Unknown Source)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
        at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1015)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
        at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
        at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
        at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
        at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterce
ptor.java:142)
        at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
        at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
        at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
        at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
        at $Proxy9.deploy(Unknown Source)
        at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
        at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:610)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeplo
ymentScanner.java:263)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.loop(AbstractDeploym
entScanner.java:274)
        at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.run(AbstractDeployme
ntScanner.java:225)
   


_________________
TIA!


Top
 Profile  
 
 Post subject: Re: org.hibernate.AnnotationException: No identifier specifi
PostPosted: Fri Dec 28, 2007 6:04 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
I did a quite similar example and it seems to be working so I suggest you upgrade the hibernate jar file in the jboss lib directory and also make sure the other interfaces do not have a getId(). What Java version are you using?

If it still doesn't work then trim your classes and post an example that doesn't work for you. I need complete classes so I will be sure we are running the same code.


Bests,
Farzad-


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 28, 2007 9:29 pm 
Newbie

Joined: Fri Dec 28, 2007 3:37 pm
Posts: 9
Thanks for the reply Farzad.

I'm using JDK 1.6. I have no annotations in the interfaces and am sure that there is only one @Id as shown. Finally, I did not include this before, but the classes are packaged in a jar inside and ear.

I will test out upgrading to the lastest hibernate.jar and see if that makes a difference.

Thanks again for any ideas you make have!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 29, 2007 9:47 pm 
Newbie

Joined: Fri Dec 28, 2007 3:37 pm
Posts: 9
Sorry for the hassle, after extensive hair pulling, I discovered that a had an older version of the class unexpectedly still on my classpath! Removing it got me beyond this problem.


Top
 Profile  
 
 Post subject: Confused EJB3 Beginner - Ignored EJB3 Annotations
PostPosted: Sat Dec 29, 2007 10:19 pm 
Newbie

Joined: Fri Dec 28, 2007 3:37 pm
Posts: 9
I'm sure this is a simple beginner error, but I've been pouring over both the JBoss and Hibernate docs and wikis and and am not finding the key missing points.

I'm using JBoss 4.2.2.GA with it's included hibernate3. I'm attempting to build EJB3 standard Entities. I have several classes that are annotated with the javax.persistence.Entity anotation (@Entity) as well as the associated @Column, @Id, etc. All of the annotations I use are from the javax.persistence package (i.e. I'm not using any hibernate or JBoss specific ones). My classes are built into a jar with an associated persistence.xml file which maps to my Datasource (a PostgreSQL one) and sets the hibernate.hbm2ddl.auto property to create. This jar fle is then bundled together with another MDB bean in an ear and deployed.

It all deploys fine and associated table are created. However, it appears that my Annotations are ignored! It seems that hibernate is reflecting upon the classes in question and building it's own view of them for persistance purposes. Specifically, the @Column name and length attributes are NOT as coded in my @Column annotations - they are based upon the actual class attribute name and what must be default lengths. Additionally, the @Enumerated (EnumType.STRING) annotation is similiarly ignored as the created DB tables have integer types.

I've been looking at many different version of documentation as EJB3 support within both hibernae and JBoss have evolved. Yet, I'm fundamentaly missing something. Hence I'm starting to question my understanding.

Is there some configuration that must be done to cause hibernate to honor the Annotations in preference to it's reflect and/or to disable it's reflection? Is it sufficient to have just EJB3 annotated classes with a persistence.xml file or are other configurations and/or files still required in and EJB3 environment - the book I've been working from, 'EJB3 In Action', seems to indicate that this is all it takes.

Are the hbm.xml and/or hibernate config files still required? If so, can they be built from the Anotations? How? It seems that a HAR based deployment once was preferable, but perhaps no longer is? I've additonally added a hibernate-service.xml service module in the ear's jboss-app that refernces the org.jboss.hibernate.jmx.Hibernate mbean. This made no difference in the ignored annotations behavior? Is this approach still needed/relavant?

Any and all guidence to a bewildered EJB3 beginner will be greatly apreciated!

_________________
TIA!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 9:54 am 
Newbie

Joined: Fri Dec 28, 2007 3:37 pm
Posts: 9
Aha! It turns out that my Annotations are not being ignored - I just did not understand that I can (apparently) not mix both field and method level Annotations.

My class has several read-only attributes (i.e. there is no associated set methods). In general, I would prefer to put my Annotations on the method level for code clarity sake. However, when doing this for the read-only attributes, I got an error complaining that a setter could not be found. This error message went away when I moved those Annotations to the field. Apparently though, this had the undersired effect of making all attributes 'field' access and effectively ignored all of my other method-based Annotations for columne name, length, etc.

So, my questions now are:

1. Is there an EJB3 standard way of mixing both field and method access types? I would like to have my default for method, but be able to override in exception cases such as the read-only attribute discussed above.

2. Is there a better way to handle read-only attributes that do NOT have an associated setter?

_________________
TIA!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 10:01 am 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
skidvd wrote:
1. Is there an EJB3 standard way of mixing both field and method access types? I would like to have my default for method, but be able to override in exception cases such as the read-only attribute discussed above.



As far as I know you can only mix annotation and XML. I don't believe you can mix method level annotation with field annotations.


Farzad-


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.