[jboss-user] [Beginner's Corner] - Problem with my first EJB application

Liberino Covelli do-not-reply at jboss.com
Wed Aug 8 14:30:46 EDT 2012

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;
public interface CountryCapital {
    public String capitalName(String countryName);

I have create a SessionBean 

package ejb;
import javax.ejb.EJB;
import javax.ejb.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"))
        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 {
    private static CountryCapital countryCapital;
    public static void main(String [] args){

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

Start a new discussion in Beginner's Corner at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120808/27c767d7/attachment.html 

More information about the jboss-user mailing list