Can an EJB extend another EJB?
Can an EJB extend another EJB?
Are there any limitations?
Thank you in advance, Kostas
Refer
http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=ejb-interest&F=&S=&P=31185
Similar Messages
-
Error when One EJB calls anothe EJB
Hi,
I got the following error when I use one EJB call another EJB in OAS 4.0.8.1, the code is developed in JDeveloper 3.0/Win NT 4.0/SP5.
Can anyone give me some ideas? or is there any samples in this case?
Thanks a lot!
Creating an initial context
Looking for the EJB published as 'APP/APPEJB'
Creating a new EJB instance
Calling APPEJB methods...
CORBA: org.omg.CORBA.BAD_OPERATION: ; nested exception is:
org.omg.CORBA.BAD_OPERATION:
java.rmi.ServerException: CORBA: org.omg.CORBA.BAD_OPERATION: ; nested exception is:
org.omg.CORBA.BAD_OPERATION:
at javax.rmi.oas.corba.CorbaRemoteExceptionHelperValue.OBVObjFrom(Compiled Code)
at TwoEJB._stub_APPEJB.callEJBMapping(Compiled Code)
at TwoEJB.TwoEJBClient.main(Compiled Code)
nullHome handle is an object that identifies an enterprise bean. A client may serialize the handle, and then later deserialize it to obtain a reference to the enterprise bean.
The javax.ejb.HomeHandle is similar to javax.ejb.Handle. Just as the Handle is used to store and retrieve reference to EJB objects, the HomeHandle is used to store and retrieve remote references to EJB homes. HomeHandle can be stored and later used to access an EJB home remote refrence the same way that a Handle can be serialized and later used to access an EJB object's remoe reference.
import java.io.*;
import javax.ejb.EJBHome;
import javax.ejb.HomeHandle;
public class WorkingWithEJBHandles {
public static void main( String[] args ) throws Exception {
EJBHome aHome = null;
// get hold of a home interface
HomeHandle handle = aHome.getHomeHandle();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream( bos );
oos.writeObject( handle );
byte[] handleAsBytes = bos.toByteArray();
// store in the database, on file. howwever you want
FileInputStream fis = new FileInputStream( "fileobj" );
ObjectInputStream ois = new ObjectInputStream( fis );
HomeHandle theHandle = (HomeHandle) ois.readObject();
// get back the EJBHome from the HomeHandle
aHome = theHandle.getEJBHome();
// the same kind of logic also holds for EJBHandles, as well as
// HomeHandles
Transfer Object is a Design pattern. Refer to Core J2EE Design Pattern.
http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html
Rgds,
Seetesh -
EJB calling another EJB - special considerations
I am trying to call an EJB from another EJB in the same container. I am able to get hold of the home interface but get an error when I try to narrow and get the Bean.
The error I get is a class cast exception. Cannot narrow ....
I read in some place that we need to do soemthing special with the DD's to achieve this. Any answers. I can post more code examples or send you samples.
Any help will be gr8tly appreciated.
VijayHi,
If ure able to get the Home then you must call the create method on the home to create the Bean and not narrow it again. I think you use narrowing to get the Home and not the bean.
I hope this helps
neo -
How to call one EJB in another EJB?
How to call one EJB in another EJB? Please explain with some example code.
To refer a Ejb from another Ejb include <ejb-ref> element in ejb-jar.xml
<session>
<ejb-name>EjbA</ejb-name>
<ejb-ref>
<ejb-ref-name>EjbB</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>com.ejb.EjbBHome</home>
<remote>com.ejb.EjbB</remote>
</ejb-ref>
</session>
Include a <reference-descriptor> in weblogic-ejb-jar.xml
<weblogic-enterprise-bean>
<ejb-name>EjbA</ejb-name>
<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>EjbB</ejb-ref-name>
<jndi-name>com.ejb.EjbBHome</jndi-name>
</ejb-reference-description>
</reference-descriptor>
</weblogic-enterprise-bean>
In EjbA Bean class refer to EjbB with
a remote reference to EjbB.
InitialContext initialContext=new InitialContext();
EjbBHome EjbBHome=(EjbBHome)
initialContext.lookup("com.ejb.EjbBHome");
EjbB ejbB=EjbBHome.findByPrimaryKey(primarykey); -
I need to make a several calls to the methods inside EJB1 from EJB2. I was getting
the remote reference of the EJB2 inside the ejbCreate() of the EJB1, is it a good
practice ?? If not, do I need to get remote reference of the EJB2 every time I
need to call EJB2 method??
Thanks in advance.To refer a Ejb from another Ejb include <ejb-ref> in ejb-jar.xml
<session>
<ejb-name>Ejb1</ejb-name>
<ejb-ref>
<ejb-ref-name>Ejb2</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<home>com.ejb.Ejb2Home</home>
<remote>com.ejb.Ejb2</remote>
</ejb-ref>
<session>
Include a <reference-discriptor> in weblogic-ejb-jar.xml
<weblogic-enterprise-bean>
<ejb-name>EjbSession</ejb-name>
<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>Ejb2</ejb-ref-name>
<jndi-name>com.ejb.Ejb2Home</jndi-name>
</ejb-reference-description>
</reference-descriptor>
</weblogic-enterprise-bean>
In Ejb1 bean class refer to Ejb2 method with a remote reference to Ejb2.
InitialContext initialContext = new InitialContext();
Ejb2Home ejb2Home = (Ejb2Home)initialContext.lookup("com.ejb.Ejb2Home");
Ejb2 ejb2 = ejb2Home.findByPrimaryKey();
Alex Pratt wrote:
I need to make a several calls to the methods inside EJB1 from EJB2. I was getting
the remote reference of the EJB2 inside the ejbCreate() of the EJB1, is it a good
practice ?? If not, do I need to get remote reference of the EJB2 every time I
need to call EJB2 method??
Thanks in advance. -
Error in calling an EJB from another EJB
Hello All,
I have a scenario where i need to call a method of an ejb from another ejb.
Both the EJB's are in different DC's.
EG: DC1 using DC2
I have added the public part of DC2 in DC1.
The following code is written in DC1 to access the EJB of DC2
MyRemote l_remote;
MyHome l_home;
InitialContext l_ctx = new InitialContext();
>> l_home = (MyHome)l_ctx.lookup("JNDI Name");
l_remote = (MyRemote)l_home.create();
There is no error at build time and deploy time, but at run time "MyHome" class is not found.
Even i am not able to access the helper class defined in the DC2 at runtime.
Please help.
Thanks in AdvanceFirst off, wrong forum section.
Check if your JNDI name is correctly placed for the bean you're calling -- check j2ee-engine.xml for that. Check the EJB container if the ear file you deployed is there and updated.
Try placing "localejbs/JNDI name" on your lookup parameter.
Regards,
Jan -
How tom invoke an EJB from another EJB using the sun rmi protocl in Weblogi
Hi,
I am particularly new to EJB.
My scenario is
client invoking-->EJB-----invoking ----(Either a webService or an EJB)
in WEBLOGIC
Is it possible that a call from EJB to another EJB or WebService use Sun's RMI as underlying protocol instead of t3 or IIOP which are used in Weblogic ?
Would be really a great help if you could provide me some sample on it on weblogic.Hi Stefan,
You don't need to provide the InitialContextFactory for running a standalone client. The following should work just fine:
Context initial = new InitialContext();
System.out.println("Looking up ...");
Object objref = initial.lookup(EJB); //the lookup name should be a global JNDI name //and not from the java:comp namespace
System.out.println("Looked up EJB");The JNDI implementation looks for the jndi.properties file in your classpath. So make sure that you have the appserv-rt.jar from your <server_installation>/lib directory in your classpath.
HTH,
Sheetal -
HELP!!! How I can call to EJB from another EJB??
I have two EJBs, for each EJB I have a jar, how I can call to EJB jar to another???
I have tried the following, in the first EJB I have import the second EJB jar and call it with context, lookup, PortableRemoteObject etc.. but the instruction lookup not find the second EJB reference.
The name in the lookup instruction is the JNDI name of the second EJB but not find a reference to it.
Please help me!!! Thanks!!
The error is:
javax.naming.NameNotFoundException: Missing node. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:34)
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.extract(NotFoundHelper.java:50)
at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:161)
at com.inprise.j2ee.jndi.java.CorbaContext.resolveName(CorbaContext.java:242)
at com.inprise.j2ee.jndi.java.CorbaContext.lookup(CorbaContext.java:261)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:483)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:493)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:493)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:937)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:942)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at ejbclient.EnterpriseClientBean.addition(EnterpriseClientBean.java:115)
at ejbclient.EnterpriseClientBean.actionPerformed(EnterpriseClientBean.java:97)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1450)
at avax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstrok.. Here it goes.. I am writing a sample code..
public class EJB1LogBean implements SessionBean {
// test is a method of stateless session beam
public void test ( TestVal val )
throws RemoteException{
try {
EJB2LogHome ejb2Home= (EJB2LogHome)getHome("java:comp/env/ejb/EJB2LogHome",1);
EJB2Log ejb2Log = ejb2LogHome.create ( val );
} catch ( CreateException e ) {
System.out.println("Create Exception occurred ");
e.printStackTrace();
} catch ( RemoteException e ) {
System.out.println( "RemoteException Occured");
e.printStackTrace();
throw new RemoteException () ;
} catch(Exception ee) {
ee.printStackTrace();
private EJBHome getHome(String jndiName,int type) {
try {
Context context = new InitialContext();
Object ref = context.lookup( jndiName );
switch(type)
case 1:
EJB2LogHome ejb2LogHome = ( EJB2LogHome )
PortableRemoteObject.narrow( ref, EJB2LogHome.class );
return ejb2LogHome;
} catch ( Exception e ) {
e.printStackTrace();
return null;
}//EJB1LogBean ends
Here as you can see, EJB1LogBean(session bean) is calling a second EJB, EJB2LogBean (entity bean). TestVal is a sample value object passed. It is plain java class and can vary from app to app and it has got nothing to do with ejbs.
"java:comp/env/ejb" is a J2EE standard and while getting a home interface, you have to append the home interface class name to "java:comp/env/ejb". Here I am passing "java:comp/env/ejb/EJB2LogHome" and "1" to getHome method, whose job is to get a reference to a home interface. getHome method is a local method. "1" is passed just to give a flexibility to getHome method as you can have more ejbs to invoked. In that case, you can go on adding different case statements for 2, 3 etc.
The only thing you have to keep in mind is that your deployment descriptor for EJB1LogBean will contain the entires for both the beans i.e. for EJB1LogBean and EJB2LogBean. This is because EJB2LogBean is wrapped by EJB1LogBean.
Hope this helps.
Please let me know if you need anything more.
- Amit -
How do I reference an EJB inside anothe EJB ,both are on different hosts
Hi,
I want to reference an EJB on one host inside another EJB in another
host. Even if i hardcode the url of the host on which the EJB is
deployed , it gives me the error regarding the no such ejb found.
I would appreciate your help.
ThanksRobert,
We've been trying to implement this type of multi-server setup for some
time now. Our application consists of 260+ EJBs with a large team of
developers actively working against it. The business logic in our
application puts the EJBS in a highly interrelated situation. This
degree of interrelation makes it necessary for each developer to deploy
the entire application before any work can get done.
Starting a weblogic server, on a Windows Workstation, with 260+ beans is
very time consuming. But to get around this development bottle neck, we
are attempting the same scenario described in this thread. We have
recently upgraded from WL4.5.x to WL5.1 SP8. With WL5.1, we get the
CommunicationException seen previously in this thread. But the Error
message in WL5.1 is less descriptive. The 5.1 error message is missing:
WL6.0 Error Text: "This error could indicate that a component was
deployed on a cluster member but not other members of that cluster. Make
sure that any component deployed on a server that is part of a cluster
is also deployed on all other members"
It is obvious that weblogic's clustering depends on classes being
available to each server in the cluster, including the ejbc generated
_WLStub classes. To me, it seems wrong that a weblogic server can only
use standard JNDI to lookup HomeInterfaces on other weblogic servers if
the hidden _WLStub classes are available to both servers. I say this
because non-weblogic clients have JNDI lookup abilities without these
requirements. This whole experience was frustrating because all along
I knew that the solution was simply to take the hacker route and put the
classes in the the client classpath. I guess I just want to know if
this is bug? If not, I think it should be.
Thanks for listening
Steve Dodge
Steve Dodge
Realeum Inc.
Robert Patrick wrote:
Here is an example:
On server1, I have a Bean called TellerBean that calls the AccountBean
that lives on server2. To make this work, I need to deploy the
TellerBean.jar file AND any/all AccountBean Stub classes (any file in the
deployed version of the AccountBean.jar file matching the pattern
AccountBean*Stub.class) on server1. Server2 only needs to deploy the
AccountBean.jar file
Hope this helps,
Robert
kamps wrote:
Thanks.
I did include the files using import and they are alsso packaged
into the jar file .
I have done this , TradeCheck is the ejb i am trying to reference
in Trader EJB.
I package them into the jar file as follows:-
@REM Compile EJB classes into the build directory (jar preparation)
javac -d build TradeCheck.java TradeCheckHome.java Trader.java
TraderHome.java TraderBean.java TradeResult.java
@REM Make a EJB jar file, including XML deployment descriptors
cd build
jar cv0f std_ejb20_basic_statelessSession2.jar META-INF examples
images
cd ..
@REM Run EJBC on jar file
java -classpath
%WL_HOME%/lib/weblogic_sp.jar;%WL_HOME%/lib/weblogic.jar weblogic.ejbc
-compiler javac build\std_ejb20_basic_statelessSession2.jar
%APPLICATIONS%\ejb20_basic_statelessSession2.jar
It still gives the same error not finding the stub class.... Could
you kindly elaborate on what needs to be done.
I would appreciate your help.
Thanks,
Sunitha
Robert Patrick <[email protected]> wrote:
The problem is that the client that downloads the stubs
at runtime cannot
be another WebLogic Server. We do not support downloading
classes into a
running server so you will need to make sure that the
stubs are
"available" to the server that is acting as a client (e.g.,
packaged in
the EAR file) on the server acting as a client.
kamps wrote:
Thanks Mahendra. I am using WebLogic 6.0. Should I importthe package
in the first ejb which references the 2nd ejb or evenin the client
which references the first ejb.
Thanks again,
Sunitha
"Mahendra Dhamdhere" <[email protected]> wrote:
You are not getting the reference of stub.
try this. In your client program, import the package
in
which ejb classes
are present. As client downloads the stub from weblogic,
you have to import
the package where your stubs are present.
which version of weblogic are you using?
Mahendra
kamps <[email protected]> wrote in message
news:[email protected]...
Thanks,
I have 2 ejbs: one is TraderBean and a client RefClient.
TraderBean in turn calls a method of another bean
TradeCheckBean.
I tried making the changes as suggested but I amgetting
the following
error on the client side.
java examples.ejb20.basic.tatelessSession.RefClient"t3://localhost:7001"
javax.naming.CommunicationException. Root exceptionis
java.rmi.UnmarshalException:
failed to unmarshal class java.lang.Object; nested
exception
is:
java.lang.ClassNotFoundException:examples.ejb20.basic.statelessSession.Trade
CheckBeanHomeImpl_WLStub: This error could indicatethat a component
was deployed on
a cluster member but not other members of that
cluster.
Make
sure that any componen
t deployed on a server that is part of a cluster
is
also deployed
on all other member
s of that cluster
java.lang.ClassNotFoundException:examples.ejb20.basic.statelessSession.TradeCheckBea
nHomeImpl_WLStub: This error could indicate that
a
component was
deployed on a clus
ter member but not other members of that cluster.
Make
sure that
any component deploy
ed on a server that is part of a cluster is also
deployed
on all
other members of tha
t cluster
<<no stack trace available>>
I would appreciate any help.
Thanks,
kamps
"Mahendra Dhamdhere" <[email protected]> wrote:
you need to get initialcontext of that server.
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
try
ctx = new InitialContext(ht); // Use
the
context
in your program
} catch (NamingException e)
{ // a failure occurred }
finally { try {ctx.close();}
catch (Exception e)
{ // a failure occurred } }
use url of that other server. After getting initialcontext,
lookup for your
ejb.
Mahendra
kampu S <[email protected]> wrote in message
news:[email protected]...
Hi,
I want to reference an EJB on one host inside
another
EJB in another
host. Even if i hardcode the url of the host on
which
the EJB is
deployed , it gives me the error regarding the
no
such
ejb found.
I would appreciate your help.
Thanks -
How to call an EJB from another EJB
Hi
I have a problem here. I need to execute a second EJB which has to get the input from the first EJB as data for execution. So when I call the first EJB, the first EJB should give the data to the second EJB and execute it and provide the result.
Cheers,
Rajok.. Here it goes.. I am writing a sample code..
public class EJB1LogBean implements SessionBean {
// test is a method of stateless session beam
public void test ( TestVal val )
throws RemoteException{
try {
EJB2LogHome ejb2Home= (EJB2LogHome)getHome("java:comp/env/ejb/EJB2LogHome",1);
EJB2Log ejb2Log = ejb2LogHome.create ( val );
} catch ( CreateException e ) {
System.out.println("Create Exception occurred ");
e.printStackTrace();
} catch ( RemoteException e ) {
System.out.println( "RemoteException Occured");
e.printStackTrace();
throw new RemoteException () ;
} catch(Exception ee) {
ee.printStackTrace();
private EJBHome getHome(String jndiName,int type) {
try {
Context context = new InitialContext();
Object ref = context.lookup( jndiName );
switch(type)
case 1:
EJB2LogHome ejb2LogHome = ( EJB2LogHome )
PortableRemoteObject.narrow( ref, EJB2LogHome.class );
return ejb2LogHome;
} catch ( Exception e ) {
e.printStackTrace();
return null;
}//EJB1LogBean ends
Here as you can see, EJB1LogBean(session bean) is calling a second EJB, EJB2LogBean (entity bean). TestVal is a sample value object passed. It is plain java class and can vary from app to app and it has got nothing to do with ejbs.
"java:comp/env/ejb" is a J2EE standard and while getting a home interface, you have to append the home interface class name to "java:comp/env/ejb". Here I am passing "java:comp/env/ejb/EJB2LogHome" and "1" to getHome method, whose job is to get a reference to a home interface. getHome method is a local method. "1" is passed just to give a flexibility to getHome method as you can have more ejbs to invoked. In that case, you can go on adding different case statements for 2, 3 etc.
The only thing you have to keep in mind is that your deployment descriptor for EJB1LogBean will contain the entires for both the beans i.e. for EJB1LogBean and EJB2LogBean. This is because EJB2LogBean is wrapped by EJB1LogBean.
Hope this helps.
Please let me know if you need anything more.
- Amit -
Calling one EJB form another EJB
Hi,
i have 2 EJBs (Session Beans). Inside first EJB in one of its methods, i have to call the second EJB's one method. What are the steps invlovled in this operation?
ThanksIt's the same as calling an EJB from a client application. I'm not very good at it, but as much as I know, you need to lookup for the EJB Home object using JNDI and obtain the Remote object from it. Then you can call all the methods on the Remote object.
If the two EJBs reside in a different container, you would need to obtain a new InitialContext by passing the environment properties of the other container and then lookup as usual.
The only precaution you need to take is that you need the EJB-client JAR (containing the home and remote interfaces only) for the other EJB available so that ClassNotFoundException and similar exceptions are not thrown.
I hope I was helpful!
Regards,
UW -
Trouble in communicating with another EJB from an EJB
I have created a stateless session bean, and inside this bean I have methods that calls methods in another stateless session bean (called myEJB, for example). When I run the code, it kept giving me the "noClassDefFoundError":
java.rmi.RemoteException: Error in ejbCreate:; nested exception is:
java.lang.NoClassDefFoundError: com.mybean.myEJBHome
Someone suggested to me that this is because they aren't remote objects, so I created local interfaces for "myEJB". When I run the code again (by binding to the Local interface now), I got this error:
javax.naming.LinkException: [Root exception is javax.naming.NameNotFoundException: Unable to resolve
'app/ejb/mybeans.jar#myEJB/local-home' Resolved: 'app/ejb/ Unresolved:'mybeans.jar#myEJB' ;
remaining name 'mybeans.jar#myEJB/local-home']; Link Remaining Name:
'java:app/ejb/mybeans.jar#myEJB/local-home'
Any ideas??
ThanksTo refer a Ejb from another Ejb include <ejb-ref> in ejb-jar.xml
<session>
<ejb-name>EjbA</ejb-name>
<ejb-ref>
<ejb-ref-name>Ejb2</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.ejb.Ejb2Home</home>
<remote>com.ejb.Ejb2</remote>
</ejb-ref>
<session>
Include a <reference-discriptor> in weblogic-ejb-jar.xml
<weblogic-enterprise-bean>
<ejb-name>EjbA</ejb-name>
<reference-descriptor>
<ejb-reference-description>
<ejb-ref-name>Ejb2</ejb-ref-name>
<jndi-name>protocol://<Ejb2host>:<PortNumber>/com.ejb.Ejb2Home</jndi-name>
</ejb-reference-description>
</reference-descriptor>
</weblogic-enterprise-bean>
Example <jndi-name>:http://localhost:7001/com.ejb.Ejb2Home
In EjbA bean class refer to Ejb2 method with a reference to Ejb2 remote interface.
InitialContext initialContext = new InitialContext();
Ejb2Home ejb2Home = (Ejb2Home)initialContext.lookup("protocol://<Ejb2host>:<PortNumber>/com.ejb.Ejb2Home"); -
Can EJB method return another EJB?
Hello,
I am new to EJB technology. I am working with Sun Application Server bundled in Netbeans 4.1
Is it po[b]ssible a method of a session bean to return another EJB which is instantiated with arguments depended on the method?
If no, is there an alternative way?
thank you in advance, KostasIs it possible within the SessionBean method to
call another Session Bean, create it using the
local interface, pass some parameters using setter
methods, then cast it from local interface to
remote and send it to the user?I think it's not possible casing Local Interface into Remote Intrface, because they inherit from different classes.
Remote interface extends EJBObject and Local interface extends EJBLocalObject
Fil -
Monitoring EJB from another application
Hi!
Let's say: We have some EJB deployed of Application Server. Each EJB (doesn't metter if session or entity) has its methods that can be called. (All EJB are in the same application)
Can I from another application see what methods has been called and at what time? I can extend monitored application with its log files, but want to use application to be monitored as is.
I guess it depends on Application Server functionality. I would like to do it on SUN reference implementation (from J2EE SDK). If there is another App Server (the best free one) please note.
I would be very thankfull for any answer.
MarcinYou could use the opensource EJB-container JBOSS and modify the source to perform logging of when a particular method was called etc.
This will enable you to run the application as is with no modifications.
Morten. -
How to Call one EJB from another
Hi all
I am trying to call one EJB in one system from another EJB residing on diferent system...
Both are Stateless session beans ...
I can't use No-args Intialcontext() as i need to specify the Ip address of other system to be looked up.....
So i am using properties Dorg.omg.CORBA.ORBInitlalHost....
But its not looking up..Its telling not bound...But i called it from standalone client remotely...
Am i wrong..?
I hope I am in right path....
I hope ill get reply as fast as possible...
Gopal VHi ken Thanks for replying....
Ya i packed it as a jar (using Export tool in Eclipse3.2)....
I am using SUN AS 9.....
I packed bean1 and bean2 as two different jars in the same domain...
Here is my code...
Bean1:
@Stateless(mappedName="ejb/Second")
public class SecondIMPL implements SecondRemote {
public FirstRemote obj;
public String connect() {
try{
InitialContext ctx= new InitialContext();
FirstRemote obj =(FirstRemote)ctx.lookup("ejb/First");
System.out.println("Client :"+obj.bMethod());
}catch(Exception e){
e.printStackTrace();
return "Check server Log";
}Bean2 :
@Stateless(mappedName="ejb/First")
public class FirstIMPL implements FirstRemote {
public String bMethod() {
return "From First Bean";
Client:
public static void main(String[] args) {
try{
InitialContext ctx= new InitialContext();
SecondRemote obj =(SecondRemote)ctx.lookup("ejb/Second");
System.out.println("Client :"+obj.connect());
}catch(Exception e){
e.printStackTrace();
Here is my Stack Trace...
[#|2007-05-24T18:35:17.214+0530|WARNING|sun-appserver-pe9.0|javax.enterprise.system.stream.err|_ThreadID=18;_ThreadName=p: thread-pool-1; w: 19;_RequestID=bb4848e7-829a-421d-a560-93659898eb02;|
javax.naming.NamingException: ejb ref resolution error for remote business interfacecom.SecondRemote[Root exception is java.lang.ClassNotFoundException: com.SecondRemote]
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:350)
at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:61)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:314)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.FirstBean.rediff(FirstBean.java:16)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.enterprise.security.application.EJBSecurityManager.runMethod(EJBSecurityManager.java:1050)
at com.sun.enterprise.security.SecurityUtil.invoke(SecurityUtil.java:165)
at com.sun.ejb.containers.BaseContainer.invokeTargetBeanMethod(BaseContainer.java:2766)
at com.sun.ejb.containers.BaseContainer.intercept(BaseContainer.java:3847)
at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:190)
at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:110)
at $Proxy36.rediff(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:121)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:650)
at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:193)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1705)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1565)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:947)
at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:178)
at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:717)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.dispatch(SocketOrChannelConnectionImpl.java:473)
at com.sun.corba.ee.impl.transport.SocketOrChannelConnectionImpl.doWork(SocketOrChannelConnectionImpl.java:1270)
at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:479)
Caused by: java.lang.ClassNotFoundException: com.Second
at com.sun.enterprise.loader.EJBClassLoader.findClassData(EJBClassLoader.java:701)
at com.sun.enterprise.loader.EJBClassLoader.findClass(EJBClassLoader.java:614)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:568)
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:320)
... 31 more
|#]
Maybe you are looking for
-
My iPhone 4S won't play certain sounds
I just got this as a hand me down from my boyfriend because he has the new 5, pretty great condition, played all the sounds, videos, musics, etc with no problems. I was playing a game earlier today with no issues, sound was great, and listened to mus
-
[VIA] KT6 Delta hangs when I install SATA disk
I've had a lot of problems with my PC - maybe related to the mobo, maybe not. I have a KT6 Delta LSR - and was running XP SP2 with a SATA disk on it. Not RAID - just standalone. It ran OK for about 4 months, then it crashed hard. For the last two wee
-
Upgrade Error Failed to upgrade SAP Business One Client
Hi All, I have upgraded one of our customers from SAP 9.0 to 9.1 PL5. Everything upgraded successfully through the wizard. When launching the client, the 32 bit client upgraded with no errors. When attempting to open the 64 bit client I get the erro
-
i cannot figure out how to cut and paste a website address into an e-mail so that it is a 'live' link how do i do this?
-
APP download, then time machine RESTORE, froze; results: Grey Apple screen
I have a macbook 13" albumin unibody-(late 09) configured w/ a 45 nm Penryn 2.26 GHz Intel Core 2 Duo processor250 GB Serial ATA (5400 RPM) hard drive. Yesterday, I decided to finally buy a good external hard drive to backup my macbook. I used time m