Win a copy of Beginning Java 17 Fundamentals: Object-Oriented Programming in Java 17 this week in the Java in General forum!

Mike Litherland

Ranch Hand
+ Follow
since Aug 12, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mike Litherland

Thanks for the reply.

I did find out from browsing through the O'reilly EJB3 book (version 5) that I'm essentially doing things the right way. They recommend "always wire both sides" of a relationship. In this context it's saying do both to delete the object:



However, in this case that's when I get this exception. I'm going to ask on the JBoss forums and see if their gurus have any thoughts on what I'm doing wrong.

Thanks again.
Hi,

I'm really stuck trying to delete related entities in EJB3. I have a one to many relationship between two tables and I can't figure out how to delete the child entity.

Let's say my primary bean, the parent is using a list collection to hold the child beans



I haven't had any luck doing this:



It doesn't seem to actually remove the relationship, even if I do an em.merge(parent) on it. On the other hand if I try to remove the child directly I get exceptions:



produces:



So which way is the right way to get rid of the child entity and ensure it's deleted from the database? Is there something I need to do to ensure the object is unique in the session?

Thanks much for the help.
Mike
[ June 26, 2006: Message edited by: Mike Litherland ]
It never, ever fails. As soon as I post a query here on javaranch I figure out the solution. I'll post it here for posterity's sake. Basically I got rid of all the ejb-ref code from both web.xml and jboss-web.xml, then I just needed to change my context lookup to this:



Where CalcTest2 is the ear name, CalcBean the EJB and remote for the interface. That's it, and it works now.

Thanks for anybody that may have taken the time to look at this.
Mike
Hi,

I'm playing with EJB3 in an trivial enterprise application. Basically I'm using JSF to implement a simple calculator interface and trying to get a stateless EJB3 to do the work. I've created the front end and the back end, but when I try to lookup the EJB from the JSF managed bean I get a stack overflow exception. It's pretty clear that there's something wrong with how I'm referencing the EJB from faces, but I don't know what. This is my lookup code:



This is a snippit of the exception that the lookup line generates:



This is the EJB reference code in the web.xml:



(Note that I had to add that home line, and I'm not sure what value I should put in that line.)

And here is the reference from my jboss-web.xml:



For the record I'm using JBoss 4.0.4GA and I'm trying to use a daily build of NetBeans 5.5 for development (has some nice bug-fixes over the beta).

I get the feeling that the problem lies somewhere in that XML i posted above. Can anybody help?

Thanks much,
Mike
I'm using NetBeans (5.5 beta) to package my code. It looks like it puts the library jar files (like the jstl.jar and jsf-impl.jar) in the root of the archive. I tried moving them to WEB-INF/lib without luck. I guess the daily builds of NB 5.5 do things a bit differently so I'm trying to download it now to see how it does it. (It can also use the JBoss supplied MyFaces instead of its own Faces RI, which will eliminate at least that problem.)

At the moment I'm much confused over how this packaging is supposed to be and nothing I do seems to allow these packages to be picked up. Is it documented anywhere?

Thanks,
Mike
Hi,

I'm testing with EJB3 on JBoss 4.0.4GA. My application uses a JSF front end tied to an EJB3 backend using both stateless and entity beans. When I perform the lookup of the stateless beans from the faces managed bean I get a StackOverflowError. Using a simple EJB client application seems to work fine, so the problem appears to be with the lookup (and debugging statements in the code seem to reinforce this). This is the line that errors:



This is what appears to be the important part of the exception:



This may be related to the problem too - I'm deploying the EJBs in a jar separately from the web war. I tried using an ear but then it couldn't find jstl so the web app wouldn't load. I suppose if anybody knows the answer to that problem it'd be helpful too as doing this as an ear is probably the right way to go.

Thanks for any help you can provide and if there's more information that I can post that would be helpful please let me know.

Thanks again,
Mike
For some bizarre reason I've written a number of small, test bed style IM applications, using both J2EE and plain Java. The only reason I would recommend J2EE over plain java is if the IM application is going to be web-based, that is browser-based chat. With AJAX and J2EE you could write an awfully nice chat service. The other reason you might choose J2EE is if you wanted to use something like XMLRPC or SOAP for the back-end protocol.

My preference has been to use straight sockets coding (NIO would be key on the server if you want to scale fairly large) and just have a Java process running to listen on a port. Then you can use a rich client (like Swing or SWT) for the IM client and have something that's more like a AIM or IRC chat.

Writing an IM type application is surprisingly challenging. You'll learn a lot. Good luck.

(If you want to look at one of the IM programs I've written for some inspiration, check out the code here: http://nule.org/wp/?page_id=74 and a screenshot of some clients chatting here: http://nule.thot.us/public/messenjerworking.png It's actually a working program, but I lost interest when the person I was developing it for adopted another solution. Maybe someone here will re-inspire me.)
15 years ago
Hi all,

I'm writing a program where the user of the program is allowed to create "business logic" (i.e. a Java class that implements a supplied interface) and to configure the program at runtime to use their logic class or one supplied for it. I'd like a friendly interface that displays a list of all classes that implement the interface so the user can select one without typing in the full package and class name. IDEs like NetBeans do things like this so I *know* there has to be a way to programmatically generate a list of packages and therefore of all available classes. From there it would be trivial to scan through them all finding just the ones that implement my interface.

Unfortunately I'm stuck. I know I can use Package.getPackages() to produce a list of all packages known to a given classloader. How do I get a more comprehensive list?

Thanks in advance,
Mike
15 years ago
Well, you want to clear out that bean attribute after the user clicks submit, right? So after your process the value of attrib you set it to "" to clear it out, then it won't redisplay in your form.

Make sense?
15 years ago
JSF
In your submit method you could just say attrib=""; Or perhaps I'm not understanding your problem?
15 years ago
JSF
Hi,

I was wondering what other people do to handle session timeouts in JSF applications. Right now my users either get kicked back to the login screen (less obnoxious) or sometimes get null pointer exceptions over managed beans (more obnoxious, but I think I've fixed this). Ideally I'd like them to go to a page where they are reminded that being idle for 30 minutes will disable their session and potentially cause them to lose data.

As a follow-up question, is there a way to see what managed beans are active in the application? It'd be neat if I could tell who was logged on (as they all get a managed user bean) by seeing which beans were instantiated.

Thanks,
Mike
15 years ago
JSF
I wish I could offer help, all I can add is a 'me too!'. I'm nesting a dataTable within a dataTable and when I click on the commandLink which should take me to a page where I can edit the details of the data contained in the inner table I don't necessarily get the right data. Specifically if the outer table has three rows (each table has only one column) and the inner table has four rows within the first of the outer table's rows, clicking on the inner tables will always return the first of the inner rows. It's bizarre, looking at the HTML it seems like Faces is keeping track of things correctly, but it's not keeping the inner table data straight.

Anybody seen this? Are nested tables not supposed to be done in Faces?

Thanks!
Mike
16 years ago
JSF
I *always* manage to find my own solution just after I post it here... Buried in the small print of my Core JSF book I notice a mention about using the <f:verbatim> tag within <h:column> tags. That's going to produce some ugly JSP pages, but I guess there's no other choice.

Thanks anyway,
Mike
16 years ago
JSF
Hi,

I'm doing some pretty complex stuff with dataTable, including nesting dataTables within dataTables. I'm a little suprised that any HTML markup I include with the <h:column> appears before the table and not within the cell. Here's an example:

There's just one column for the table and a number of rows pulled from a database.

Any idea why this won't work? I don't particularly want to include a pile of <h utputText value="markup" escape="false"/>...

Thanks,
Mike

[ January 10, 2006: Message edited by: M Litherland ]
[ January 10, 2006: Message edited by: M Litherland ]
16 years ago
JSF
OK, after remembering that my work has a Safari subscription I looked up how to do this in the O'reilly JavaServer Faces book. It was much more clear than the Sun book was. And the answer really did end up being 'wrap your data in ListDataModel and Faces does the rest'.

I had to modify my user bean to store the data model as an instance variable, then when the row detail was clicked on I could retrieve the bean representing the row that was clicked on by calling the getRowData method of the data model.

Anyway, I wanted to post my discovery in case someone else came here looking for the same solution. Thanks.
16 years ago
JSF