Can not lookup EJB from another EAR file, the ClassCastException returned

Hi,
     I try to call EJB module in A.ear from Servlet in another EAR file(B.ear) the ClassCastException returned on the context.lookup() code . So when i create a Dynamic Web Project(With the same code as Servlet in B.ear) and pack it in A.ear(The same EAR file with EJB module), it work fine. I have no idea. Could you please suggest me.
The ClassCastException : incompatible with interface ..... return on
HelloManBeanLocalHome home=(HelloManBeanLocalHome) ctx.lookup("localejbs/sap.com/HelloMan_EAR/HelloManBean");
The entire code is below :
          try {               
               InitialContext ctx=new InitialContext();
               HelloManBeanLocalHome home=(HelloManBeanLocalHome) ctx.lookup("localejbs/sap.com/HelloMan_EAR/HelloManBean");
               HelloManBeanLocal remote=home.create();
               lookupText=remote.helloMan("Test");
          } catch (Exception e) {
               // TODO: handle exception
               e.printStackTrace(out);
Many Thanks

Hi Saleem Mohammad.
           Thank a lot for your post. I got this idea from your link. The below code work fine.
          try {               
               InitialContext ctx=new InitialContext();
               Object obj= ctx.lookup("localejbs/sap.com/HelloMan_EAR/HelloManBean");
                ClassLoader homeCl = obj.getClass().getClassLoader();
                Class<?> localHome = homeCl.loadClass(HelloManBeanLocalHome.class.getCanonicalName());
                java.lang.reflect.Method method = localHome.getMethod("create");               
                Object homeObj = (Object)method.invoke(obj);
                ClassLoader localCl=homeObj.getClass().getClassLoader();
                Class<?> local = localCl.loadClass(HelloManBeanLocal.class.getCanonicalName());
                Class  args[] = {String.class};
                java.lang.reflect.Method localMethod=local.getMethod("helloMan",args);               
                Object params[]={"Thongie"};
                Object localObj = (Object)localMethod.invoke(homeObj,params);
                lookupText=(String)localObj;               
          } catch (Exception e) {
               // TODO: handle exception
               e.printStackTrace(out);

Similar Messages

  • My iphone 5 ATT, i can hear the recording, but can not hear anything from neither ear speaker or loud speaker when i call? what is the problem? what can i do, it is out of warranty.

    My iphone 5 ATT, i can hear the recording, but can not hear anything from neither ear speaker or loud speaker when i call? what is the problem? what can i do, it is out of warranty.

    1357b wrote:
    My iphone 5 ATT, i can hear the recording
    What recording?
    but can not hear anything from neither ear speaker or loud speaker when i call?
    You just wrote you could hear the recording...
    You can take it into an Apple store and have it checked out.

  • I can not download pictures from my Iphone5S to the computer ?

    I can not download pictures from my Iphone5S to the computer ?

    Just use Windows Explorer...
    Navigate to the iPhone and copy/move pics from there.

  • 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(Abstr

    ok.. 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

  • Can not migrate EJB from WL 5.1 to WL 6.0

    I have followed the procedures for migrating my ejb's from weblogic 5.1
    to weblogic 6.0. I am receiving an error when I try to deploy an ejb
    (java.lang.NoClassDefFoundError). The class it can not find is
    packagename.ejbnameHome. This class is inside of the jar file containing
    the ejb that I am trying to deploy. Any idea what the problem may be?
    Eddie

    Yes you can, I did it. Just remember, Jdev 3.0 is only for OAS 4081 and Oracle 8.1.5, and Jdev 3.1 is for OAS 4082 and Oracle 8.1.6. Don't mix them, you'll run into problems.

  • Can not copy spaces from some pdf file

    https://sites.google.com/site/sharedacrobat/data/cannot_copy_text.pdf
    I'm trying to copy some text from the above pdf file (with mouse and ctrl-C). But many spaces are missing (e.g., the following text). Is it a problem with acrobat. Or it is a problem with the pdf file. I use pdftotext to conver the pdf file to a text file. The text file looks fine. Therefore, I suspect it is a bug in Acrobat. But I'm not completely. Could you please take a look and let me know what the problem is and how to fix it? Thanks!
    ConnectingmicroRNAgenestothecore
    transcriptional regulatorycircuitryofembryonicstemcells

    It appears that the PDF creation process was deliberately intended to make repurpose of content difficult.
    --| The table description/caption uses "Calibri" font having non-standard lookup tables.
    (for some relevant discussion scroll to UVSAR's post in this thread:
    http://acrobatusers.com/forum/printing-prepress/pdfs-printing-garbage-characters )
    --| The 3.3 font size of the table cells' content.
    --| The small page size associated with dense packing of content.
    Perhaps if you print to an image (from Acrobat) and OCR the resultant PDF you may be able to do something.
    However, the small font size may be problematic.
    Be well...

  • Can not lookup EJB

    11g
    When i run a unit test, and lookup the remote interface. ClassNotFoundException. From JNDI tree, i can find the remote interface. Please find the details trace, thanks for your help.
    at weblogic.ejb.container.internal.RemoteBusinessIntfGenerator.generateRemoteInterface(RemoteBusinessIntfGenerator.java:84)
         at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.readObject(RemoteBusinessIntfProxy.java:211)
         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:597)
         at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
         at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:197)
         at weblogic.rjvm.MsgAbbrevInputStream.readObject(MsgAbbrevInputStream.java:564)
         at weblogic.utils.io.ChunkedObjectInputStream.readObject(ChunkedObjectInputStream.java:193)
         at weblogic.rmi.internal.ObjectIO.readObject(ObjectIO.java:62)
         at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:240)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
         at weblogic.jndi.internal.ServerNamingNode_1031_WLStub.lookup(Unknown Source)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:400)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:388)
         at javax.naming.InitialContext.lookup(InitialContext.java:392)

    Hi Saleem Mohammad.
               Thank a lot for your post. I got this idea from your link. The below code work fine.
              try {               
                   InitialContext ctx=new InitialContext();
                   Object obj= ctx.lookup("localejbs/sap.com/HelloMan_EAR/HelloManBean");
                    ClassLoader homeCl = obj.getClass().getClassLoader();
                    Class<?> localHome = homeCl.loadClass(HelloManBeanLocalHome.class.getCanonicalName());
                    java.lang.reflect.Method method = localHome.getMethod("create");               
                    Object homeObj = (Object)method.invoke(obj);
                    ClassLoader localCl=homeObj.getClass().getClassLoader();
                    Class<?> local = localCl.loadClass(HelloManBeanLocal.class.getCanonicalName());
                    Class  args[] = {String.class};
                    java.lang.reflect.Method localMethod=local.getMethod("helloMan",args);               
                    Object params[]={"Thongie"};
                    Object localObj = (Object)localMethod.invoke(homeObj,params);
                    lookupText=(String)localObj;               
              } catch (Exception e) {
                   // TODO: handle exception
                   e.printStackTrace(out);

  • Can not copy text from a pdf file

    https://sites.google.com/site/sharedacrobat/data/cannot_copy_text.pdf?attredirects=0&d=1
    I can not copy the table caption in the above pdf. If I do so, I will get some gibberish, such as %"/*&+%",-.%&1",/*%9&,*09%&
    I'm wondering what happens to the pdf file. Is there a way to fix it so that I can copy the text?

    asdfabcedasf wrote:
    https://sites.google.com/site/sharedacrobat/data/cannot_copy_text.pdf? attredirects=0&d=1
    I can not copy the table caption in the above pdf. If I do so, I will get some gibberish, such as %"/*&+%",-.%&1",/*%9&,*09%&
    I'm wondering what happens to the pdf file. Is there a way to fix it so that I can copy the text?
    Does anybody know what cause the problem and how to fix it? The current walkaround is to convert the pdf into image, then load the image into acrobat and perform OCR. But this is tedious and some information may be lost. I'm wondering if there is a better solution.

  • Can not send mail from PR Workflow to the approver

    Dear all,
    I have issues about send mail from PR Workflow to the approver.
    Now when user create PR and the corresponding user can receive the workflow items in SBWP.
    But no email from the user to approver.
    If I assign authorization SAP_ALL to the user that create PR. The approver can recieve the workflow item PR in SBWP and email to their mail
    Can you tell me about the authorization that can allow the user to send the workflow item PR in SBWP and email to the approver?
    Now user can send mail to external and internal mail and I also configured the mail server in SCOT and can successfully send a mail to users in SO01 by manually creating a message.
    Now the approver not receive any email but can receive a workflow item in SBWP
    Regards,
    Pannee

    Dear all,
    Thank you for all suppport, Now I can solve issues.
    Regards,
    Pannee

  • Help!! Can not find ejb from servlet!!!

    I have tried several days...here is my code to look up ejb..
    Context context = new InitialContext();
    Object ref = context.lookup("CustomerFacade");
    //Object ref = context.lookup("CustomerFacade");
    facadeHome = (CustomerFacadeHome) PortableRemoteObject.narrow(ref, CustomerFacadeHome.class);
    facade = facadeHome.create();
    do I need a orion-ejb-jar.xml? oc4j will generate it, right?
    Do I need a ejb-ref tag in the web.xml file? I've tried to use JDev to develop an example..the file it generates doesn't have ejb-ref tag at all..however..it works...
    the problem is that I want to port an app from JBoss to OC4J....so I cannot use JDev to develop from scratch...
    Please help me~~~I am stuck for several days...

    Next step it to restore to factory defaults in case there is some corruption which is now in the backup. If that does not work then you may have a hardware problem.

  • I can not start Instalation from my cs6, because the Installationprogramm says, installer couldn´t initialise

    how can i get an Installer to initialise my cs6?

    If you are still receiving this error message when running the proper installation media then please remove all Adobe Creative Software and run the CS Cleaner Tool.  You can find details regarding the CS Cleaner Tool at CS Cleaner Tool for installation problems | CCM, CS6, CS5.5, CS5, CS4, CS3 - http://helpx.adobe.com/creative-suite/kb/cs5-cleaner-tool-installation-problems.html.
    It would be the best way to remove the Adobe Application Manager to allow you to reinstall.
    Regards
    Rajshree

  • Help. Can't paste photos from my photos file

    I can not paste photos from my photos file. If I start a blank file I can paste anything photos want from the web in as many layers as I want. If I try to paste a photo from my own photos file it becomes the back ground by itself. I don't know how to stop this. Using photoshop elements 11. Thanks

    Thanks for trying to help. My photos are stored in my pictures folder in Windows. I don't want the photos as the background sometimes if I what to edit them and over lay parts of them on top of another photo.As it stands now I can only work with one of my photos at a time. If I paste them off the net I can stack them right up.

  • I can not import photos from PC to my Ipad, it says iTunes will no longer sync photos to the iPad

    I can not import photos from my PC to the iPad, it says  iTunes will no longer sync photos to the iPad

    YES Terence!  Thank you. Exporting allowed me to move my photos from iPhoto into the Burn Folder on my desktop.   But that doesn't explain why I'm having to go that route now.   Have I done something (accidentally changed some setting) on my computer that will not allow me to just click and drag anymore?   I really liked the convenience of the click and drag option. 
    I don't have the time tonight to export and burn a lot of CD/DVDs.  I'll try that tomorrow and make sure my photos are moving properly.  I also need to export photos to my external hard drive to make sure that route is working. 
    Wouldn't you know that my Apple Care Plan runs out this Wednesday?!  I need to make sure everything is working properly before that expires. 
    Thank you so much for your help.   I really, really appreciate it.

  • Can not send photo from messages

    Can not send photo from messages

    I am having the same issue. I can email, but not text message a picture. I get "message send failure". I am at home, have my wifi working, have full towers and my MMS is on and so is cellular data. I have the 4s and have had if for less than a week. I have sent pictures before. Also my daughter has my old Iphone 4 and the texts I send to her are going as regular mms texts and not Imessages???

  • I can not transfer date from one hard drive to another, I keep getting an error because I have two of the same file names and one file name is in caps and I cant change the file name

    can not transfer date from one hard drive to another, I keep getting an error because I have two of the same file names and one file name is in caps and I cant change the file name. My original external has an error and needs to be reformatted but I dont want to lose this informations its my entire Itunes library.

    Sounds like the source drive is formatted as case sensitive and the destination drive is not. The preferred format for OS X is case insensitive unless there is a compelling reason to go case sensitive.
    Why can't you change the filename? Is it because the source drive is having problems?  If so is this happening with only one or two or a few files? If so the best thing would be to copy those over individually and then rename them on the destination drive.
    If it is more then you can do manually and you can't change the name on the source you will have to reformat the destination as case sensitive.
    Btw this group is for discussion of the Support Communities itself, you;d do better posting to Lion group. I'll see if a host will move it.

Maybe you are looking for