Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB simple client is not running

 
Pratik Patil
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have just started EJB.
I am trying to run sample examples.
While running I am getting NullPointerException.
Do I missing anything?


I am using Eclipse JEE .


following are code files:
package ejb3inaction.example;
import javax.ejb.Stateless;
@Stateless
public class HelloUserBean implements HelloUser {
public void sayHello(String name) {
System.out.println("Hello " + name + " welcome to EJB 3 In Action!");
}
}


package ejb3inaction.example;
import javax.ejb.Remote;
@Remote
public interface HelloUser {
public void sayHello(String name);
}



package ejb3inaction.example;

import javax.ejb.EJB;

import ejb3inaction.example.HelloUser;

public class HelloUserClient {
@EJB
private static HelloUser helloUser;

public static void main(String[] args) {


helloUser.sayHello("Curious George");
System.out.println("Invoked EJB successfully .. see server console for output");
}
}


Thanks in advance !

-- Pratik.

 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To inject a EJB in a standalone client, you will need a Application Client Container. See this thread for details.
 
Pratik Patil
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks !
What are the steps to create and deploy EJB application?

-- Pratik.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which application server do you use? Usually, you will find tutorials for deploying the EJBs in the application server documentation. The JavaEE guide is also a good starting point
 
Pratik Patil
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using JBoss 5.0 and Eclipse Galilo.
I have created new EJB project and source file which I have posted(Pl refer my first post).
When I do --> run on server --> I am getting error for persistance .xml .
Now, Pl tell me how to configure persistance.xml for MySql database.
And pl re correct my deployment steps if I am missing anything.

-- Pratik.
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pratik Patil wrote:I am using JBoss 5.0 and Eclipse Galilo.
I have created new EJB project and source file which I have posted(Pl refer my first post).
When I do --> run on server --> I am getting error for persistance .xml .


I personally never use IDEs to run the applications. So i won't be able to help there. If you are looking for tutorials on building, deploying and running EJB3 examples on JBoss, then follow the docs here
 
nav katoch
Ranch Hand
Posts: 246
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pratik,

This will help you a lot "Mikalai Zaikin's SCBCD 5.0 Guide, also available in Word and PDF format". The appendix of this guide will show you everything you need for your application.

Thanks,

Naveen
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic