Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Not able to locate Session bean thru sar

 
Amee Dabo
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a abc1.sar file which calls a POJO --> abc.java which inturns calls SessionBean.
In jboss-service.xml I have an etry like:
<server>
<MyMbean code="abc"
name="abc">
</MyMbean>
</server>

My problem is :
If I deploy abc1.jar --> It calls session Bean & it works fine
But the moment I make abc1.sar & deploys the application I get following error:
javax.naming.NameNotFoundException: ejb not bound

In short, when renamed as SAR file the way I want it, it is not able to locate Session Bean!

Can you please help?

Thanks,
Ameeta
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well couldn't you seperate out the EJB side from the service side and have two deployments 1. the sar and the other a jar or ear. Think of it like the Tomcat sar. Would you include all your Servlets in that sar? No you wouldn't you have seperate applications.

I think that is probably the best OO approach, in that other services and applications can now all access the EJB without always having to go through the service.

Mark
 
Amee Dabo
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I need to pass a parameter from my start() method of my MBean to EJB;
I want to call sessionbean in the same sar file only.
I know that EJB Container needs to get called prior to MBean service. But just not getting how this can be done!! Tried in many ways but was of no use..
Can anybody help please..
Thanks in advance,
-Ameeta
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Funny thing, last night I was reading the JBoss Admin book, and was reading about creating MBeans and how some MBeans are dependant on EJBs being already deployed. Now I don't remember the exact part, but I do know that there is a dependcy with the Naming service, so in your XML you use a depends tag. If you have the book, it is near page 100, and you can download the PDF from jboss.org website.

I don't have the book with me right now. And of course, since I just read it, I don't remember the exact details.

Mark
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually page 128 to be exact. In the depends tag service=ejb, and the jndi name of the Bean in the JNDI service. The depends is not on Naming but on ejb.

Mark
 
Amee Dabo
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot..

But still I am getting an error:

My jboss-service.xml is as follows:

<server>
<mbean code="com.gameteclabs.bizlogic.workflow.CheckForDraw" name="com.gameteclabs.bizlogic.workflow:service=CheckForDraw"> <depends>jboss.j2ee:service=EJB,jndiName=ejb/ADMDrawResults1Bean</depends> </mbean>
</server>

When I run sar file it gives me following error:

--- MBeans waiting for other MBeans ---
ObjectName: com.gameteclabs.bizlogic.workflow:service=CheckForDraw
State: CONFIGURED
I Depend On:
jboss.j2ee:service=EJB,jndiName=ejb/ADMDrawResults1Bean

--- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
ObjectName: jboss.j2ee:service=EJB,jndiName=ejb/ADMDrawResults1Bean
State: NOTYETINSTALLED
Depends On Me:
com.gameteclabs.bizlogic.workflow:service=CheckForDraw

I dont know where I am going wrong!

Please help me!!
Thanks,
Ameeta
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at:

How can a MBean depend on a Session Bean
 
Amee Dabo
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jaikiran..I referred to same link before & it worked.
Thanks Mark for your note too..I have seperated out ejb from sar.
But sar is working when I invoke start method in JMX console manually.
Actually it should run start method continuously & automatically..
Ranchers..any idea how to achieve this?
Thanks,
Ameeta
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amee Dabo:
Actually it should run start method continuously & automatically..


I agree that the start should be called automatically, but i did not get what you mean by continuously. The start method will be called only once when the MBean is deployed.

How is your sar packaged? Did you try out by putting a System.out.println message in the start method to check whether that method is invoked when the MBean is deployed?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's one of the example MBean on JBoss:

HelloWorldMBean in JBoss

See if it helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic