[jboss-user] [JBoss Seam] - Shared Tomcat/JVM
Hello, I am building a Seam application which will be hosted in a share instance of Tomcat when it is done. I've been able to get the application to load. But there are permission problems with the JSF implementation I try to access one of the pages. | Jan 20, 2008 3:20:47 PM org.apache.catalina.core.StandardContext listenerStart | SEVERE: Exception sending context initialized event to listener instance of class com.sun.faces.config.ConfigureListener | javax.faces.FacesException: java.security.AccessControlException: access denied (java.util.PropertyPermission * read,write) | at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:387) | at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729) | at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187) | at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) | at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:121) | at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:143) | at java.security.AccessController.doPrivileged(Native Method) | at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:737) | at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) | at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608) | at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535) | at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470) | at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122) | at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310) | at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) | at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021) | at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) | at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013) | at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442) | at org.apache.catalina.core.StandardService.start(StandardService.java:450) | at org.apache.catalina.core.StandardServer.start(StandardServer.java:709) | at org.apache.catalina.startup.Catalina.start(Catalina.java:551) | 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.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) | at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) | Caused by: java.security.AccessControlException: access denied (java.util.PropertyPermission * read,write) | at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323) | at java.security.AccessController.checkPermission(AccessController.java:546) | at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) | at java.lang.SecurityManager.checkPropertiesAccess(SecurityManager.java:1252) | at java.beans.PropertyEditorManager.registerEditor(PropertyEditorManager.java:56) | at com.sun.faces.application.ApplicationImpl.addPropertyEditorIfNecessary(ApplicationImpl.java:706) | at com.sun.faces.application.ApplicationImpl.addConverter(ApplicationImpl.java:660) | at org.jboss.seam.jsf.SeamApplication.addConverter(SeamApplication.java:78) | at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:727) | at com.sun.faces.config.ConfigureListener.configure(ConfigureListener.java:489) | at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:381) | ... 27 more | I've been doing some research to see if there is an alternative JSF implementation I could use. But everything seems to require this Sun library be included. Has anyone been successful in deploying a Seam application in a shared Tomcat environment? If so, I could use some pointers on how to configure mine. Thanks for your help. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4121694#4121694 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4121694 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Error reporting
Thanks for posting that, but it might have helped if I wasn't such a dweeb! I had totally forgot about: |context-param | param-namefacelets.DEVELOPMENT/param-name | param-valuefalse/param-value |/context-param | I knew there was a debug flag there someplace I needed to change, but I was thinking it was the core:init debug=false /. Doh! View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4044578#4044578 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4044578 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Error reporting
I'm having a bit of trouble figuring out how error reporting is suppose to work. I have an exceptions.xml file to catch exceptions. | exception class=java.lang.RuntimeException | redirect view-id=/fatalError.xhtml | messageUnexpected error, please try again/message | endConversation / | /redirect | /exception | exception | redirect view-id=/fatalError.xhtml | messageUnexpected error, please try again/message | endConversation / | /redirect | /exception | Which seems to work if the Exception is thrown early enough in the page rendering process. However, it does not always seem to catch the exceptions. The best I can figure is that it doesn't work when the page is rendered partially, and then an Exception is encountered. The makes sense because once an HttpServletResponse has been committed you can't then decide to redirect. I need to find a way to configure Seam (or maybe it's JSF) when it reports Errors and/or Exceptions. The default, which includes StackTrace, Component Tree, Scoped Variables, etc, is fine while in development. But once the application goes to production (or test) I need to be able to eliminate all that and just print a nice message. Where, how can I configure the reporting of exceptions in my application? View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4043743#4043743 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4043743 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - s:cache / and h:selectOneListBox /'s
I'm having a bit of trouble using the s:cache JSF component in combination with my h:selectOneListBox's. If I place the s:cache / tags just after the ui:define / tags (just like the Blog example shows), like so | ui:define name=body | s:cache key=index region=pageFragments | ... | h:form id=foo | h:selectOneListBox id=foo value=#{myFoo} | si:selectItems var=foo value=#{fooList.resultList} / | /h:selectOneListBox | h:commandButton id=select action=#{select} value=Select Foo | /h:form | ... | h:form id=bar | h:selectOneListBox id=bar value=#{myBar} | si:selectItems var=bar value=#{barList.resultList} / | /h:selectOneListBox | h:commandButton id=select action=#{select} value=Select Bar | /h:form | ... | /s:cache | /ui:define | I can select an item from one of the lists and submit the form once. But when I come back to the page I have text in the page, and can no longer submit any of the forms on the page. If I put the s:cache / tag directly around each h:selectOneListBox / | ui:define name=body | ... | h:form id=foo | s:cache key=index-foo region=pageFragments | h:selectOneListBox id=foo value=#{myFoo} | si:selectItems var=foo value=#{fooList.resultList} / | /h:selectOneListBox | h:commandButton id=select action=#{select} value=Select Foo | /s:cache | /h:form | ... | h:form id=bar | s:cache key=index-bar region=pageFragments | h:selectOneListBox id=bar value=#{myBar} | si:selectItems var=bar value=#{barList.resultList} / | /h:selectOneListBox | h:commandButton id=select action=#{select} value=Select Bar | /s:cache | /h:form | ... | /ui:define | I can submit the forms but, I have to click the submit button twice. The first time I get value is not valid (as if there was no selected item). Pressing the button again, submits the form. Is there something special I have to do in order to get the s:cache / to work with my h:selectOneListBox / tags? View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4041123#4041123 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4041123 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: s:cache / and h:selectOneListBox /'s
OK, thanks for the info. I'll file a JIRA issue, and maybe look into it myself. Speaking of, I am having trouble finding out how to contribute patches and so forth. Can you post a link or tell me how to get there from maybe the labs.jboss.org site? Thanks. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4041219#4041219 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4041219 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Query caching with Seam
Is there a way to set Hints if the Query is defined in components.xml via the framework:entity-query / tag? Thanks. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4038605#4038605 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4038605 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Query caching with Seam
Ah. I actually had an old version of the xsd. Updated the xsd and whadda know, there they are. Thanks for the tip. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4038667#4038667 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4038667 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Need some help with mapping
Yeah, you are right. I think the primary key in this case is breaking a few rules. I think one column in this case would be sufficient, but being an application developer and not a database developer, what do I know. I will make some effort to push back (if even possible). But for now I need to keep trudging ahead. So changing the mapping to @ManyToOne did not seem to have the desired effect. | State: FAILED | Reason: org.hibernate.AnnotationException: A Foreign key refering com.foo.entities.Type from com.foo.entities.Store has the wrong number of column. should be 3 | | @ManyToOne | @JoinColumn(name=STORE_TYPE, referencedColumnName = TYPE_ID) | public Type getStoreType() { | return storeType; | } | You had multiple JoinColumns in your earlier post. But the STORE table doesn't have a TABLE_NAME column in it. So how do I map that column of the TypePK class to a static value? I would like to try something like the following, but I don't think this will work the way it is. | @ManyToOne | @JoinColumn(name=STORE_TYPE, referencedColumnName = TYPE_ID) | @DiscriminatorColumn(name=TABLE_NAME, discriminatorType=STRING,length=20) | @DiscriminatorValue(STORE) | @DiscriminatorColumn(name=FIELD_NAME, discriminatorType=STRING,length=20) | @DiscriminatorValue(STORE_TYPE) | public Type getStoreType() { | return storeType; | } | But I believe @DiscriminatorColumn and @DiscriminatorValue are class level annotations, not method level. Is that a correct assumption? If so, is there a way to get the results of those annotations another way? Thanks. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4035098#4035098 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4035098 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - home.update not being called.
I'm having a bit of trouble figuring out why my Home.update method is not being called. When I use an h:inputText ... / the form posts, and everything works fine. However, I need to have the input as a h:selectOneListbox .../. But when I put the h:selectOneListbox ... / tag in the page the forum doesn't post as expected. The Home.update is not called, the values are not set in the entity, and to top it all off when the page returns Home.isManaged seem to return false. I've turned up the logging output on org.jboss.seam.jsf and org.apache.myfaces to see if that would help me find the problem. I get a lot more output, but combing through it, I can not seem to find the reason for the change in behavior. So, what else can I do to begin debugging this? Which categor{y,ies} might I turn up to give me more info in the log? Which source files might I dig through to help me understand what is happening? The most troublesome part is that I have h:selectOneListbox .../ tags working in other pages with similar entities. So I suspect it has something to do with the entity itself, and not the h:selectOneListbox / tag, but I'm having trouble figuring out what the problem is. Thanks for any and all help. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4035112#4035112 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4035112 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Need some help with mapping
OK. I thought my original post was pretty clear, but apparently not. So for the purposes of this post, forget that there was ever mention of ITEM_ anything. TYPE_TABLE: | ++--+ | | Field | Type | | ++--+ | | TABLE_NAME | varchar(25) | | | TYPE_ID| varchar(10) | | | TYPE_FIELD | varchar(25) | | | TYPE_VALUE | varchar(255) | | ++--+ | STORE: | +---+--+ | | Field | Type | | +---+--+ | | STORE_NAME| varchar(255) | | | STORE_ID | varchar(10) | | | STORE_TYPE_ID | varchar(25) | | | STATUS_ID | varchar(25) | | ++-+ | The STORE_TYPE_ID value in the STORE table relates to a value in the TYPE_ID column of the TYPE_TABLE where TABLE_NAME is equal to STORE and TYPE_FIELD is equal to STORE_TYPE. The STATUS_ID value in the STORE table relates to a value in the TYPE_ID column of the TYPE_TABLE where TABLE_NAME is equal to STORE and TYPE_FIELD is equal to STORE_STATUS. Anyone have any thoughts on how to annotate a Store object to map the correct values? I can't seem to find anything like this in the examples, or via Google. Thanks. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034089#4034089 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034089 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Need some help with mapping
You are not annoying me. I apparently do not have the correct vocabulary to describe my situation adequately enough. So let me try again... Store has a one-to-one relationship with Type. However, simply using the following annotation is not adequate: | @OneToOne | @JoinColumn(name = STORE_TYPE, referencedColumnName = TYPE_ID) | public Type getStoreType() { | return storeType; | } | Because it produces the following error: | State: FAILED | Reason: org.hibernate.AnnotationException: Column name TYPE_FIELD of com.foo.entities.Type not found in JoinColumns.referencedColumnName | View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034267#4034267 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034267 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Need some help with mapping
Yeah, you're right it is a ManyToOne relationship. I was thinking a Store has one (and only one) type Type associated with it at any given time. Completely spaced looking at it from the Type's perspective. I think using a @ManyToOne annotation will give me what I need. After playing around with @PostLoad and @PrePersist in another part of the app. I think I can use this to ensure that the right Type's are being set in the right fields. BTW, yes, I do agree having a table_name column is a bit much, and in the case of this app not used at all (except as part of the PK). In fact, it would have likely been quicker and easier to just use a enum. But alas the tables are what they are, and I do what I am told (most of the time anyway). Thanks again for letting me work through this with you. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4034369#4034369 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4034369 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: Need some help with mapping
Thanks for your response Felix. But I'm not sure you are understanding the problem. I am not mapping Items in a store. I am mapping attributes *of* a store. If you look in the example code I posted, there is a Type of store. What is not in the post are other attributes like, Status, Region, etc. The possible values of these types is stored in the TYPE_TABLE. Think of them as enumerated types, but rather than being hard coded in a class file, the types are kept in a database. Also, note that I am mapping to a legacy system, so I have no control over the data model. So to answer your questions: * Yes, the TABLE_NAME is the name of the table that my Store object is mapped to. The only thing I am using it for at present is in the TypePK object to ensure uniqueness. * Store does not extend Item. What I had was a StoreType extending Type. Not because I thought I needed a StoreType, but because it seemed the only way to map the Type object to the appropriate sub elements in the Type table. * Also, I'm not sure @EmbeddedId and @Embeddable will work in this case. But feel free to correct me if I am wrong. The STORE table only has storage for one field in the PK (ITEM_ID). So it can not store the entire PK object. Thanks. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4033743#4033743 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4033743 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Re: @Column Annotation doesn't seem to work...
I can't answer the why, but I had the same problem. I worked around it by putting the @Column annotation in the Primary Key class. | public class Foo { | | @Id | public Long getFooId() { | } | | @Id | public Long getBarId() { | } | | public static class FooPK { | | @Column(name=FOO_ID) | public Long getFooId() { | } | @Column(name=BAR_ID) | public Long getBarId() { | } | } | } | Seems to have given me the result I needed. But I'm not sure how this will affect future mappings, annotations, etc. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4032406#4032406 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4032406 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [EJB 3.0] - Need some help with mapping
OK, I would appreciate a little help with a mapping issue I am running into. I have what I will call a Type table. This table looks something like this: | ++--+ | | Field | Type | | ++--+ | | TABLE_NAME | varchar(25) | | | ITEM_ID| varchar(10) | | | ITEM_FIELD | varchar(25) | | | ITEM_VALUE | varchar(255) | | ++--+ | The TABLE_NAME, ITEM_ID, and ITEM_FIELD columns make up the primary key. I have this table mapped to a Type object, with a TypePK @IdClass. This works fine. However, what I need to do is map certain rows in this table to a field in another object. For example, if my STORE table looks like: | ++--+ | | Field | Type | | ++--+ | | STORE_NAME | varchar(255) | | | STORE_ID| varchar(10) | | | STORE_TYPE_ID | varchar(25) | | ++--+ | The STORE_TYPE_ID value needs to be mapped to the ITEM_ID field in the TYPE table where TABLE_NAME = STORE and an ITEM_FIELD = STORE_TYPE. I've tried subclassing Type (with @Inheritance, and @DiscriminatorValue annotations) but that does not seem to be giving me the desired result. | @Entity | @Inheritance(strategy = InheritanceType.SINGLE_TABLE) | @DiscriminatorColumn(name=LIST_FIELD, discriminatorType = DiscriminatorType.STRING) | @DiscriminatorValue(STORE_TYPE) | public class StoreType extends Type { | } | |entityManager.createQuery(select storeType from StoreType storeType); | Generates the following error: | Caused by: java.sql.SQLException: ORA-00942: table or view does not exist | Any ideas how I might be able to annotate these objects in order to get the result I am looking for? | @Entity | @Table(name = STORE) | public class Store implements Serializable { | @Id | @Column(name = STORE_ID) | public Long getId() { | return id; | } | | public void setId(Long id) { | this.id = id; | } | | @OneToOne(mappedBy=id) | public StoreType getType() { | return type; | } | | public void setType(StoreType type) { | this.type = type; | } | | @Column(name = STORE_NAME) | public String getName() { | return name; | } | | public void setName(String name) { | this.name = name; | } | } | Thanks. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4032498#4032498 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4032498 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Overriding EntityHome.persist problems
OK, it seems the managed flag is not being set when I navigate to that page from my select list. However, it does get set correctly when I navigate to the region.xhtml from an s:link / within a h:dataTable / tag. I am apparently building and submitting my list incorrectly. So now my question becomes, how do I build a list of entities that allows the user to navigate to the entity's edit page? I haven't seen anything like this in the examples, and my guesses do not appear to be doing the correct things. Thanks. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4027262#4027262 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4027262 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Overriding EntityHome.persist problems
I've got some rules that will validate an entity before it is saved to the database, according to what I've read the best place to do that is in the Home.persist method. However, in the Home.persist method the getId and getInstance methods always return null. I expected them to contain the Entity that is about to be persisted, is this not a correct assumption? I injected an instance of the Entity and it seems to contain the form data. This works, and I'm cool with, but is this the *right* way? Thanks, View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4026810#4026810 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4026810 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Overriding EntityHome.persist problems
Thanks for the response. | @Name(regionHome) | public class RegionHome extends EntityHomeRegion | { | | @RequestParameter | Long regionId; | | @In(required=false) | Region region; | | @In | WorkingMemory regionManagerWorkingMemory; | | @Override | public Object getId() | { | if (regionId==null) | { | return super.getId(); | } | else | { | return regionId; | } | } | | @Override @Begin(join=true) | public void create() { | info(create()); | super.create(); | } | | @Override | public String update() { | info(update(+regionId+) ); | return super.update(); | } | | @Override | public String persist() { | info(getId() == #0, getId()); // #1 | info(region.getId() == #0, region != null ? region.getId() : null ); // #2 | info(persist(+regionId+,+ (getInstance() != null ? getInstance().getId() : null) +) ); // #3 | | if( region != null ) { | regionManagerWorkingMemory.assertObject(region); | regionManagerWorkingMemory.fireAllRules(); | setInstance(region); | } | return super.persist(); | } | | @Override | public String remove() { | info(remove(+regionId+) ); | return super.remove(); | } | } | In the persist method line #1 prints: | 17:17:08,163 INFO [RegionHome] getId() == null | #2: | 17:17:08,164 INFO [RegionHome] region.getId() == 1 | #3: | 17:17:08,165 INFO [RegionHome] persist(null,null) | I'm trying to get my head around this in the persist method using existing data (Entities) before tackling the update method... Actually, now that you mention it the page *should* be calling the update method. Maybe I need to be looking at the region.xhtml to see why it's calling persist instead of update first. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4026819#4026819 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4026819 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - Primary key object mapping
Hello, I have the following class structure: | @Entity | @Table(name=FOO) | @IdClass(FooPK.class) | public class Foo { | private Long id; | private String name; | private String description; | private ListFooBar bars; | | @Id @Column(name=FOO_ID) | public Long getId() { | return id; | } | public void setId(Long id) { | this.id = id; | } | | @Id @Column(name=FOO_NAME) | public String getName() { | return name; | } | public void setName(String name) { | this.name = name; | } | | public static class FooPK { | private Long id; | private String name; | | @Id @Column(name=FOO_ID) | public Long getId() { | return id; | } | public void setId(Long id) { | this.id = id; | } | | @Id @Column(name=FOO_NAME) | public String getName() { | return name; | } | public void setName(String name) { | this.name = name; | } | } | } | | | @Entity | @Table(name=BAR) | @IdClass(BarPK.class) | public class Bar { | private Long id; | private String name; | private String description; | | @Id @Column(name=BAR_ID) | public Long getId() { | return id; | } | public void setId(Long id) { | this.id = id; | } | | @Id @Column(name=BAR_NAME) | public String getName() { | return name; | } | public void setName(String name) { | this.name = name; | } | | public static class BarPK { | private Long id; | private String name; | | @Id @Column(name=BAR_ID) | public Long getId() { | return id; | } | public void setId(Long id) { | this.id = id; | } | | @Id @Column(name=BAR_NAME) | public String getName() { | return name; | } | public void setName(String name) { | this.name = name; | } | } | } | | | @Entity | @Table(name=FOO_BAR) | @IdClass(FooBarPK.class) | public class FooBar { | private Foo foo; | private Bar bar; | private Date effectiveDate; | private Date endDate; | | @Id @JoinColumn(name=FOO_ID) | public Foo getFoo() { | return foo; | } | @Id @JoinColumn(name=BAR_ID) | public Bar getBar() { | return bar; | } | @Id @Column(name=EFF_DATE) | public Date getEffectiveDate() { | return effectiveDate; | } | | public static class FooBarPK { | private Foo foo; | private Bar bar; | private Date effectiveDate; | | @Column(name=FOO_ID) | public Foo getFoo() { | return foo; | } | @Column(name=BAR_ID) | public Bar getBar() { | return bar; | } | @Column(name=EFF_DATE) | public Date getEffectiveDate() { | return effectiveDate; | } | } | } | The question I have relates to the FooBar class. The table behind it has FOO_ID and BAR_ID columns as part of the primary key. But I can't seem to figure out how to map these column values to appropriate Foo.id and Bar.id values. Any ideas on how I might be able to do this? Thanks for your help. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4023249#4023249 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4023249 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Setting a
petemuir wrote : So I think the thing is here that unless Seam actually started providing a basic User class (which would be a bad thing as this is domain model specific) there is no sensible way to store any information about the user on Identity. FWIW I just extend Identity and add get/setUser methods to it (where User is an entity I've defined). | | @Name(org.jboss.seam.security.identity) | | public class Identity extends org.jboss.seam.security.Identity { Thanks petemuir, that's exactly the kind of info, and solution I was looking for. Did I miss that in the docs somewhere? Thanks! View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4020816#4020816 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4020816 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Setting a
[EMAIL PROTECTED] wrote : Identity is the wrong place for this, it is purely concerned with authentication and only contains principals it needs to authenticate. Using a session-scoped component is perfectly valid for displaying the user's full name. The authenticator is what is concerned about authentication, and I would agree that the authenticator should only have authentication code in it. At least this is the direction Seam appears to be taking. (Note: that I said appears because I have not read the road map and am not 100% sure about that). But isn't the Identity object used to identify the user who has been authenticated? If this is true, then the attributes that identify a user could differ greatly based on the application. In normal cases the default Identity object might suffice. But it would be nice to be able to define a custom (subclass) Identity object where I can add attributes based on what my application needs. Anyway, I'm still just getting my feet wet with Seam, so take my thoughts as just that thoughts (and if you feel like it, suggestions). Thanks for the info. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4020403#4020403 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4020403 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Setting a
Good afternoon, I have an Authenticator that connects to the company's LDAP to authenticate. Which is working perfectly. In the LDAP there is a Display Name for the user. I think it would be nice to show this in the loginout.xhtml page rather than the username. Currently I am doing this via the following code: | org.jboss.seam.contexts.Contexts.getSessionContext().set(userDisplayName, displayName); | By think it might be cleaner to have something like: | Identity.instance().setName(displayName); | Or something similar. Is this possible at this point? Thanks. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4019524#4019524 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4019524 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: OneToMany does not load
Thanks for the reply petemuir. I sort of expected it to be a Hibernate issue. But I am unclear as to where Seam leaves off and Hibernate takes over, so I figured I'd start here. The show sql Hibernate option is on in seam-gen projects by defaut, but I need to look at the SQL a little closer next time. After looking though the SQL, I realized that | @OneToMany(cascade=ALL, mappedBy=id, fetch=EAGER) | public ListStore getStores() { | return stores; | } | Should have actually been... | @OneToMany(cascade=ALL, mappedBy=district, fetch=EAGER) | public ListStore getStores() { | return stores; | } | The mappedBy attribute should point to the property in the Store object which will contain the mapped District object. Anyway, thanks again for the response. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4019101#4019101 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4019101 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - OneToMany does not load
I have a couple Entities that have @OneToMany relationships with each other. I define them as so.. | @Entity | public class District implements Serializable { | | private Long id; | private String name; | private Region region; | private Manager manager; | @DataModel | private ListStore stores; | | @Id @GeneratedValue | public Long getId() { | return id; | } | | public void setId(Long id) { | this.id = id; | } | | @Length(max=150) | public String getName() { | return name; | } | | public void setName(String name) { | this.name = name; | } | | @ManyToOne @JoinColumn(name=region_id, nullable=false) | public Region getRegion() { | return region; | } | | public void setRegion(Region region) { | this.region = region; | } | | @OneToOne @JoinColumn(name=manager_id, nullable=false) | public Manager getManager() { | return manager; | } | | public void setManager(Manager manager) { | this.manager = manager; | } | | @OneToMany(cascade=ALL, mappedBy=id, fetch=EAGER) | public ListStore getStores() { | return stores; | } | | public void setStores(ListStore stores) { | this.stores = stores; | } | | } | | @Entity | public class Store implements Serializable { | | private Long id; | private String name; | private String street; | private String city; | private String state; | private String postalCode; | private District district; | | @Id @GeneratedValue | public Long getId() { | return id; | } | | public void setId(Long id) { | this.id = id; | } | | @Length(max=20) | public String getName() { | return name; | } | | public void setName(String name) { | this.name = name; | } | | public String getCity() { | return city; | } | | public void setCity(String city) { | this.city = city; | } | | @Column(name=postal_code) | public String getPostalCode() { | return postalCode; | } | | public void setPostalCode(String postalCode) { | this.postalCode = postalCode; | } | | public String getState() { | return state; | } | | public void setState(String state) { | this.state = state; | } | | public String getStreet() { | return street; | } | | public void setStreet(String street) { | this.street = street; | } | | @ManyToOne(optional=false, fetch=EAGER) | @JoinColumn(name=district_id, nullable=false) | public District getDistrict() { | return district; | } | | public void setDistrict(District district) { | this.district = district; | } | } | The relationship definition seems to work fine because when I create a Store it maintains the proper District relationship in the database. | mysql select * from District; | ++---+---++ | | id | name | region_id | manager_id | | ++---+---++ | | 1 | district1 | 1 | 1 | | ++---+---++ | | mysql select * from Store; | +++---+--+---+-+-+ | | id | name | street| city | state | postal_code | district_id | | +++---+--+---+-+-+ | | 1 | store1 | 123 my street | city | st| 12345 | 1 | | | 2 | store2 | 456 my street | city | st| 12345 | 1 | | +++---+--+---+-+-+ | However, when I try to load this District I am getting very odd behavior. With the @GeneratedValue annotations (as above) the following DataTable only shows Store store1. | h:dataTable var=store |value=#{districtHome.instance.stores} |rendered=#{ not empty districtHome.instance.stores } |id=stores | h:column | f:facet name=headerName/f:facet | h:outputText value=#{store.name}/ | /h:column | /h:dataTable | In reality I do not want @GeneratedValue's for the Id field. But when I remove the @GeneratedValue annotation and input the Id's via the form I get no results in the h:dataTable / at all. Nothing I have tried seems to be getting me anywhere. I've
[jboss-user] [JBoss Seam] - Re: SeamSelectItems - 1.1.1beta4
Yeah, OK. That makes sense, and I do agree, it is more elegant. I thought maybe there was a performance or functional reason why you were recommending it. I missed the JAR file description in the document, sorry about that. I'm still having a bit of trouble with this converter. | public class SubjectSelectConverter extends org.jboss.seam.selectitems.jsf.SelectItemsConverter { | | @Override | protected Object convertToObject(FacesContext arg0, UIComponent arg1, String arg2) | throws ConverterException { | log.debug(convertToObject(#0, #1, #2), arg0, arg1, arg2); | return new Subject(arg2, arg2); | } | | @Override | protected String convertToString(FacesContext arg0, UIComponent arg1, Object arg2) | throws ConverterException { | log.debug(convertToString(#0, #1, #2), arg0, arg1, arg2); | return arg2.toString(); | } | } | Gives me: | Converter must implement SelectItemsConverter: [EMAIL PROTECTED] | I even tried putting the selectitems-ui.jar in the EAR path to make sure the classloader could see the SelectItemsConverter when it instantiated SubjectSelectConverter. But no such luck. Doesn't make a lot of sense to me. On a similar subject, I saw someplace that I could define a converter for a specific class globally. According to your post I guess that would be in faces-config.xml. But I didn't bookmark that page, and now cannot seem to find it again. It's sort of off topic, but do you know how I can associate a Converter with a JavaBean globally? It looked something like below, but I can't be absolutely sure. | converter | bean-classcom.foo.app.Subject/bean-class | converter-classcom.foo.app.SubjectConverter/converter-class | /converter | Thanks again for your help. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4001066#4001066 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4001066 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: SeamSelectItems - 1.1.1beta4
Can this tag be used with non-Entity JavaBeans? I've tried just about every option discussed in the docs, but nothing seems to be working. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4000512#4000512 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4000512 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: SeamSelectItems - 1.1.1beta4
in home.xhtml: | h:form id=selectSubject | h:selectOneMenu value=#{subject} | si:selectItems value=#{subjects} var=s label=#{s.title} key=#{s.id} /si:selectItems | /h:selectOneMenu | /h:form | in Subject.java: | | @Name(subject) | public class Subject implements java.io.Serializable { | private static final long serialVersionUID = -1926918108184076192L; | private String id = ; | private String title = ; | private String description = ; | } | It also contains getters and setters, but for brevity I left them out. In SubjectFactoryBean.java | @Stateless | @Name(subjectFactory) | @Scope(APPLICATION) | public class SubjectFactoryBean implements SubjectFactory { | | @Logger | private Log log; | | @Out | private ListSubject subjects; | | @Factory(subjects) | public void load() { | log.debug(Loading subject list.); | | subjects = new ArrayListSubject(); | subjects.add( new Subject(sub-a, Subject A) ); | subjects.add( new Subject(sub-b, Subject B) ); | subjects.add( new Subject(sub-c, Subject C) ); | | log.debug(Subject list contains #0 entries., subjects.size() ); | } | } | I'm getting the following error: | Value is no String (class=mil.fits.survey.Subject$$EnhancerByCGLIB$$5cdc06c9, value=subject = ) and component selectSubject:_id12with path: {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /home.xhtml][Class: javax.faces.component.html.HtmlForm,Id: selectSubject][Class: javax.faces.component.html.HtmlSelectOneMenu,Id: _id12]} does not have a Converter | So I try adding a converter Adding this method to SubjectFactoryBean.java | public Converter getConverter() { | return new SelectItemsConverter() { | @Override | protected Object convertToObject(FacesContext arg0, UIComponent arg1, String arg2) | throws ConverterException { | log.debug(convertToObject(#0, #1, #2), arg0, arg1, arg2); | // TODO Auto-generated method stub | return new Subject(arg2, arg2); | } | | @Override | protected String convertToString(FacesContext arg0, UIComponent arg1, Object arg2) | throws ConverterException { | log.debug(convertToString(#0, #1, #2), arg0, arg1, arg2); | // TODO Auto-generated method stub | return arg2.toString(); | } | | }; | } | And in home.xhtml... | h:form id=selectSubject | h:selectOneMenu value=#{subject} converter=#{subjectFactory.converter} | si:selectItems value=#{subjects} var=s label=#{s.title} key=#{s.id} /si:selectItems | /h:selectOneMenu | /h:form | | Gives me the following error... | /home.xhtml @16,83 converter=#{subjectFactory.converter}: Exception | getting value of property converter of base of type : | org.jboss.seam.intercept.Proxy$$EnhancerByCGLIB$$4461012a | View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4000535#4000535 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4000535 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: SeamSelectItems - 1.1.1beta4
Thanks petemuir, using a String for the value worked. Not sure why I didn't see that based on the stack. Also, I actually copied and pasted my code wrong. I didn't have the 'key' attribute at the same time as I had the converter configured. When I did it was a completely different exception. Why would you recommend a custom converter over using a key? I still can't seem to get the converter to work. Seems no matter where I put the jar file I get NoClassDefFound exceptions. I'll have to keep digging into this. But before I spend a lot of time trying to figure it out, it would be nice to know why it would be a better approach. BTW, the docs specify that both jars go in the WEB-INF/lib dir. You may want to update this if it is not the case. Thanks again for the help. View the original post : http://www.jboss.com/index.html?module=bbop=viewtopicp=4000722#4000722 Reply to the post : http://www.jboss.com/index.html?module=bbop=postingmode=replyp=4000722 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user