NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

JSF naming conflict with Entity "Resource"

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
David Bender
Posted via mailing list.





PostPosted: Wed Aug 19, 2009 7:01 pm    Post subject: JSF naming conflict with Entity "Resource" Reply with quote

I've hit a snag building my first significant JSF application in Glassfish
(v2 in Netbeans 6.1). An entity in the database for which this application
is being built is named 'resource' and this seems to be confusing JSF or the
JPA EntityManager.

I came across the naming conflict after running the "Entity class from
database" and "JSF from Entity Class" wizards. (Those are handy wizards, by
the way! Thanks to whoever built them.)

In my application, a class named my.package.Resource conflicts with
javax.annotation.Resource

In my Java code, I was able to give my Resource class references fully
qualified names and that seemed to resolve conflicts with the @Resource
annotation, at least for the compiler. But when this runs in Glassfish, I
get this error when I try to call up a page to edit any of my Resources:


exception
javax.servlet.ServletException: #{resource.editSetup}:
java.lang.IllegalArgumentException: Unknown entity bean class: interface
javax.annotation.Resource, please verify that this class has been marked
with the @Entity annotation.

root cause
javax.faces.FacesException: #{resource.editSetup}:
java.lang.IllegalArgumentException: Unknown entity bean class: interface
javax.annotation.Resource, please verify that this class has been marked
with the @Entity annotation.

root cause
javax.faces.el.EvaluationException: java.lang.IllegalArgumentException:
Unknown entity bean class: interface javax.annotation.Resource, please
verify that this class has been marked with the @Entity annotation.

root cause
java.lang.IllegalArgumentException: Unknown entity bean class: interface
javax.annotation.Resource, please verify that this class has been marked
with the @Entity annotation.


My Resource class is marked with the @Resource annotation. And I've tried
using a fully qualified name for the annotation --
@javax.annotation.Resource -- which compiles but doesn't make the
FacesException go away.

I've looked through faces-config.xml and anywhere else I can look but I'm
stumped. I see that JSF or JPA or SOT (Some Other Thing) is confusing my
Resource with the Resource annotation, but where is that happening and how
to I correct it?

Any help would be appreciated.


Dave
Back to top
David Bender
Posted via mailing list.





PostPosted: Mon Aug 24, 2009 4:07 pm    Post subject: JSF naming conflict with Entity "Resource" Reply with quote

I solved this.

The solution was to specify the fully qualified class name in the first
parameter of the EntityManager.find(Class, Object) method. So:

em.find(package.name.Resource.class, id);

not, the default

em.find(Resource.class, id);


Maybe the wizard can be adjusted to fully qualify class names if they could
create a naming issue.



Dave (talking to himself, again)





-----Original Message-----
From: nbusers-return-142430-dbender=address-removed
[mailto:nbusers-return-142430-dbender=address-removed] On Behalf Of
David Bender
Sent: Wednesday, August 19, 2009 2:02 PM
To: address-removed
Subject: [nbusers] JSF naming conflict with Entity "Resource"

I've hit a snag building my first significant JSF application in Glassfish
(v2 in Netbeans 6.1). An entity in the database for which this application
is being built is named 'resource' and this seems to be confusing JSF or the
JPA EntityManager.

I came across the naming conflict after running the "Entity class from
database" and "JSF from Entity Class" wizards. (Those are handy wizards, by
the way! Thanks to whoever built them.)

In my application, a class named my.package.Resource conflicts with
javax.annotation.Resource

In my Java code, I was able to give my Resource class references fully
qualified names and that seemed to resolve conflicts with the @Resource
annotation, at least for the compiler. But when this runs in Glassfish, I
get this error when I try to call up a page to edit any of my Resources:


exception
javax.servlet.ServletException: #{resource.editSetup}:
java.lang.IllegalArgumentException: Unknown entity bean class: interface
javax.annotation.Resource, please verify that this class has been marked
with the @Entity annotation.

root cause
javax.faces.FacesException: #{resource.editSetup}:
java.lang.IllegalArgumentException: Unknown entity bean class: interface
javax.annotation.Resource, please verify that this class has been marked
with the @Entity annotation.

root cause
javax.faces.el.EvaluationException: java.lang.IllegalArgumentException:
Unknown entity bean class: interface javax.annotation.Resource, please
verify that this class has been marked with the @Entity annotation.

root cause
java.lang.IllegalArgumentException: Unknown entity bean class: interface
javax.annotation.Resource, please verify that this class has been marked
with the @Entity annotation.


My Resource class is marked with the @Resource annotation. And I've tried
using a fully qualified name for the annotation --
@javax.annotation.Resource -- which compiles but doesn't make the
FacesException go away.

I've looked through faces-config.xml and anywhere else I can look but I'm
stumped. I see that JSF or JPA or SOT (Some Other Thing) is confusing my
Resource with the Resource annotation, but where is that happening and how
to I correct it?

Any help would be appreciated.


Dave
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo