• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can I do It?

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please, I'm trying to do a simple test EJB project in Netbeans 6.5 and Glassfish V2, but It is terrible.

Look... I just do It. First a created a project in New Project -> Java EE -> EJB Module. Ok!
In directory "Source Code Packeages" I created one package called "stateless" with yours two ejb. They are:

package stateless;

import javax.ejb.Stateless;

/**
*
* @author Higor
*/
@Stateless
public class TesteEJBBean implements TesteEJBRemote {

public String getMessage() {
return "Hello EJB World";
}

}


And the Remote:

package stateless;

import javax.ejb.Remote;

/**
*
* @author Higor
*/
@Remote
public interface TesteEJBRemote {

public java.lang.String getMessage();

}

In Enterprise Beans directory it have the same code of TesteEJBBean. I think Netbeans do it automaticaly, I dont remember if I put it there.

Ok,it's work!
But How can I try test it???

I tryed to put a simple java class in "Test Package" directory like it:

package Teste;
import javax.ejb.EJB;
import stateless.TesteEJBRemote;
/**
*
* @author Higor
*/
public class NewClass {
@EJB
private static TesteEJBRemote teste;

public static void main(String[] args) {
//System.out.println(teste.getMessage());
System.out.println("teste");
}
}

The compilation is Ok, but when I select it and select Execute option it have a error.

The compilation step I'm doing with all this classes is: Select the project and right mouse click and select BUILD.
Later I just select NewClass in Test Package directory and try Compile -> Execute.

Anyone can help me please??

Thank you a lot if you can help me!!!
Higor
 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Higor,

Sorry for the delay in replying, I just came back from vacation...

Feel free to use the example code for EJB 3 in Action: http://www.manning.com/panda/. The problem is that you will need an application client container (ACC) to use injection inside a command-line class: http://forums.java.net/jive/message.jspa?messageID=177032. Remember, something in your commsn-line app will need to understand the @EJB annotation. Inside a WAR or EAR file, the application servers "sees" the @EJB annotation and performs the injection.

I would just use look-ups in your test client for now. Our JBoss code examples does this since JBoss doesn't have an application client container.

Hope this helps,
Reza
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic