[EJB/JBoss] - Recover EJB Stateful
by thiagomontovaneli
Hi,
I have a EJB stateful working in my server Jboss 5.0.
So, I cried one application Web for be a client of the EJB. In client project has two JSP pages, one for to list the content in EJB and the other for add in EJB.
In jsp that working for to list, call the EJB, so:
InitialContext ic = new InitialContext();
| CarrinhoHome home = (CarrinhoHome) ic.lookup("LivrariaEAR/CarrinhoEJB/home");
| Carrinho carrinho = home.create();
| this.total = carrinho.getTotal();
| this.livrosList = carrinho.getLivrosList();
| this.nome = carrinho.getNome();
And in jsp for to create, I do:
public String AddCarrinho() {
| try {
| InitialContext ic = new InitialContext();
| CarrinhoHome home = (CarrinhoHome) ic.lookup("LivrariaEAR/CarrinhoEJB/home");
| Carrinho carrinho = home.create();
| this.total = carrinho.getTotal();
| this.livrosList = carrinho.getLivrosList();
| this.nome = carrinho.getNome();
| livro = new Livro(45, "Sujeiro");
| carrinho.addLivro(livro);
| } catch (Exception ex) {
| ex.printStackTrace();
| }
| return "listLivro";
| }
I need to find the same EJB for the jsp that list the content and the jsp that create the content. And for each client one EJB different.
Help me please.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4202558#4202558
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4202558
17 years, 5 months
[Beginners Corner] - What to use when simple Thread neededd
by jaymcmeans
I am very new to this JBoss / J2EE stuff. But I know Java inside and out. We are creating a system that allows users to manage some telecom equipment. We doing this using JBoss 4.2 and Seam 1.2.
I have a legacy system that I have to constantly poll to retrieve information. I need something that will constantly run so that I can regularly scrape information from it and store the results. It needs to do this process 24x7 regardless of whether someone is interacting with the system or not.
In a normal Java application I would simply create a Thread and just scrape away. I have created a bean that has a scope of Application and has the @Startup annotation. That way it starts up when JBoss creates stuff. Inside the method associated with the @Create annotation I am spinning up a Thread and doing all of the scrapping work. This thread runs the whole time JBoss is alive. I also shut the thread down in the method associated with @Destroy.
I have been told that I really should not create my own thread from within a Managed Bean. If that is the case then what is the best way to have something constantly running and gathering data independent of everything else?
Because of my rookiness with this stuff, any examples would be greatly appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4202555#4202555
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4202555
17 years, 5 months