2

A strange thing happens when I put my auto-generated entity classes with hibernate-tools 3.2.4-GA into Jboss 6.1.0-Final. My persistence.xml has every class record with the correct entity:

<class>package.server.persistence.base.entity.Groups</class>

I found the issue in a hibernate-tools bug: here

My entity is generated with a strange new line near the last bracket:

/** * Groups generated by hbm2java */
@Entity
@Table(name="GROUPS"
)
public class Groups  implements java.io.Serializable {

if I manually set:

@Entity
@Table(name="GROUPS")
public class Groups...

Everything works fine:

2012-01-12 17:52:46,489 INFO [org.hibernate.cfg.AnnotationBinder] (http-0.0.0.0-8080-2) Binding entity from annotated class: package.server .persistence.base.entity.Groups 2012-01-12 17:52:46,490 INFO [org.hibernate.cfg.annotations.EntityBinder] (http-0.0.0.0-8080-2) Bind entity package.server.persistence.base.entity.Groups on table GROUPS

edit: if I made tests with jUnit entities are correctly configured, even if they have the "new line" on annotation. Thus, it seems a jboss issue.

Please, any help will be much appreciated.

sebbalex
  • 397
  • 4
  • 15
  • 1
    Whitespace (including newlines) inside annotation parameters is entirely valid. Clearly it's "bug" as it's a bit ugly, but it shouldn't break anything. Morevoer, it's not like it's ported over inside the .class files, so it seems like a compiler bug. What are you using to compile? – Viruzzo Jan 13 '12 at 13:24
  • this is my env: `Apache Maven 3.0.3 (r1075438; 2011-02-28 18:31:09+0100) Maven home: C:\Program Files\Apache Software Foundation\apache-maven-3.0.3\bin\.. Java version: 1.6.0_21, vendor: Sun Microsystems Inc. Java home: C:\Program Files\Java\jdk1.6.0_21\jre Default locale: it_IT, platform encoding: Cp1252 OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"` – sebbalex Jan 13 '12 at 13:34
  • Can you post your `javap` output for the class (with the newline)? You have to run `javap Groups` where the .class file is. – Viruzzo Jan 13 '12 at 13:38
  • no problem: [link](http://nopaste.info/08f26278b1.html) ps: package was modified due to company rules – sebbalex Jan 13 '12 at 14:10
  • Apparently Java 6's javap doesn't extract annotation info: can you try with Java 7? Or this: http://types.cs.washington.edu/annotation-file-utilities/ – Viruzzo Jan 13 '12 at 14:28
  • Sorry for delay.. I was not in office those days.. anyway I tried annotation-file-utilities tool unsuccesfully.. it seems it has a bug [link](http://nopaste.info/18c78b877d.html). Later I'll try with Java7 API – sebbalex Jan 16 '12 at 10:55
  • Hi, same problem here: [jdk17](http://nopaste.info/16731f333e.html) even with jdk 1.7 – sebbalex Jan 16 '12 at 14:07
  • This was without the manual fix? And if you remove the line by hand it does show the annotation metadata? – Viruzzo Jan 16 '12 at 14:18
  • [jdk17_2](http://nopaste.info/c126caaa4b.html) this is with the correct annotation without new line or blank spaces, but I still can't see annotation. ps: there are some class member change – sebbalex Jan 17 '12 at 15:52

1 Answers1

0

this is, like you said, a bug in hibernate-tools. i ran into it when using jboss 6 in a previous project of mine as well.

it's currently unresolved and marked as a fix for hibernate 3.3.0beta1 but sadly there's no workaround or solution (at least that i know of) for it so far... guess you'll just have to wait

jere
  • 4,306
  • 2
  • 27
  • 38
  • Thanks for answer, yes I know it, but I would understand if there is a way to get jboss working with this "wrong" annotation. – sebbalex Jan 13 '12 at 13:00
  • there is no error, it just seems that jboss does not see classes as entity. – sebbalex Jan 13 '12 at 13:20