Liberino Covelli [
https://community.jboss.org/people/rino.covelli] created the discussion
"Problem with my first EJB application"
To view the discussion, visit:
https://community.jboss.org/message/752694#752694
--------------------------------------------------------------
Dear friends , i have a problem with my first EJB application.
I hava create this bussiness interface
package ejb;
import javax.ejb.Local;
import javax.ejb.Remote;
@Local
public interface CountryCapital {
public String capitalName(String countryName);
}
I have create a SessionBean
package ejb;
import javax.ejb.EJB;
import javax.ejb.Stateless;
@Stateless
public class CountryCapitalBean implements CountryCapital,CountryCapitalLocal{
public String capitalName(String countryName)
{
String capital=new String("No such country");
if (countryName.equalsIgnoreCase("India"))
{
capital="New Delhi";
}
if (countryName.equalsIgnoreCase("United States Of America"))
{
capital="Washington DC";
}
if (countryName.equalsIgnoreCase("China"))
{
capital="Beijing";
}
return capital;
}
}
Finally, I implemented a client and wanted to inject the bean but it does not work
package appclient;
import javax.ejb.EJB;
public class ApplicationClient {
@EJB
private static CountryCapital countryCapital;
public static void main(String [] args){
countryCapital.capitalName("India");
}
}
This is the error , the injection does not work
Exception in thread "main" java.lang.NullPointerException
at appclient.ApplicationClient.main(ApplicationClient.java:25)
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/752694#752694]
Start a new discussion in Beginner's Corner at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]