Error While Deploying Stateless EJB Using Struts&Weblogic 7.0

Discussions

EJB programming & troubleshooting: Error While Deploying Stateless EJB Using Struts&Weblogic 7.0

  1. I am trying to deploy a stateless session bean and encountered the following error "EJB : SesFacade .Unable to initialize method info for remote or home interface.x: com/xxx/xx/xx/CatForm"

    I have created jar,war and packaged the same into ear file.

    In one of the methods of the bean i am passing CatForm Object,Following is the method.

    public void addCategory(CatForm catForm)
    {
      CatForm tt = (CatForm) catForm;
    }

    If i remove the parameter CatForm for the addCategory then it is gettting deployed. Can any one of you help me to resolve this issue.

    Do i need to set the classpath??

    Note:- The EJB being invoked from Struts Action Class.

    Your help is highly appreicated. Thanks
  2. Hi Suryan

    Can you list your exception so that I can know what issues you are facing ?
    To save some time could you tell why are you creating a new object of CatForm

    Tim
  3. Hi Tim,

    Pls ignore the method that i have specified in the previous post.
    Sorry for the confusion. The method is somewhat like this

    public void addCategory(CatForm catForm)
    {
      String catName = catForm.getName();
      .....................
      ..................................
    }
     
    Where catForm is the Struts ActionForm being passed from the client.

    Following is the exception...

     TargetException:

    Unable to deploy EJB: C:\myhome\max\.\myserver\.wlnotdelete\strutsdemo\MasterEjb
    .jar from MasterEjb.jar:

    EJB : MasterSes .Unable to initialize method info for remote or home interface.
    The error is java.lang.NoClassDefFoundError: com/max/master/form/CatForm

            at java.lang.Class.getMethods0(Native Method)
            at java.lang.Class.getMethods(Class.java:737)
            at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.initializeMethodInfo
    s(ClientDrivenBeanInfoImpl.java:1083)
            at weblogic.ejb20.deployer.ClientDrivenBeanInfoImpl.<init>(ClientDrivenB
    eanInfoImpl.java:218)
            at weblogic.ejb20.deployer.SessionBeanInfoImpl.<init>(SessionBeanInfoImp
    l.java:107)
            at weblogic.ejb20.deployer.BeanInfoImpl.createBeanInfoImpl(BeanInfoImpl.
    java:343)
            at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.initializeBeanInfos(M
    BeanDeploymentInfoImpl.java:438)
            at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.<init>(MBeanDeploymen
    tInfoImpl.java:165)
            at weblogic.ejb20.deployer.EJBDeployer.setupBeanInfo(EJBDeployer.java:96
    4)
            at weblogic.ejb20.deployer.EJBDeployer.prepare(EJBDeployer.java:1273)
            at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:232)
            at weblogic.j2ee.J2EEApplicationContainer.prepareModule(J2EEApplicationC
    ontainer.java:1570)
            at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContain
    er.java:737)
            at weblogic.j2ee.J2EEApplicationContainer.prepare(J2EEApplicationContain
    er.java:555)
            at weblogic.management.deploy.slave.SlaveDeployer.processPrepareTask(Sla
    veDeployer.java:1062)
            at weblogic.management.deploy.slave.SlaveDeployer.prepareUpdate(SlaveDep
    loyer.java:730)
            at weblogic.drs.internal.SlaveCallbackHandler$1.execute(SlaveCallbackHan
    dler.java:24)
            at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
            at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
  4. public void addCategory(CatForm catForm)
    {
      String catName = catForm.getName();
      .....................
      ..................................
    }
      
    See Suryan the problem is I guess you are not able to get the value from "Form". You need to change your code to this

    String catName = ((catForm) form).getName();

    Try this piece of code...if it works then pls let me know and if it doesn`t then still let me know if you are getting the same exception. All the best.

    Tim
  5. Sorry Correction

    //Use this instead of the above code
    String catName = ((CatForm) form).getName();
  6. Tim,

    The problem is not with the method implementation.

    I am not able to deploy the ejb even if i have a method like the following...

    Public void addCategory(CatForm catForm)
    {
      System.out.println("addCategory Invoked");
    }

    Actually CatForm and all the other. Struts related files are packaged in an war file. The Jar and war are packaged into a Ear File.
  7. It definitely sounds like a classpath issue. Consult the documentation for your server for how to put your ActionForm class into your EJB's classpath. In addition, the EJB will also need access to the Struts jar, because it won't be able to initialize the CatForm subclass unless it can locate its ActionForm superclass in the Struts library.

    Finally, as a general practice, you may want to alter the way you are passing data between tiers. By passing the ActionForm down to your EJB layer, you are creating a dependency between your EJBs and the Web layer. Instead, I sugest you use the Data Transfer Object pattern to pass a generic JavaBean up from your EJB layer. You can then pass data between your ActionForm and your JavaBean in the web layer, thereby reducing the coupling between layers in your system.

    Right now you have this dependency:

    Web <--> EJB

    Using a DTO, you have this dependency:

    Web ---> EJB

    This will go a long way to simplifying your classpath issues.
  8. Hi Suryan

    I believe the issue is with Form Bean...Since you are directly passing Form to EJB rather than Action Class...EJB needs to know about Form Bean...U need to provide struts.jar in ur classpath as well as in lib directory (to be on safe side) ...

    My suggestion to u would be use Action Class and the invoke EJB or Send information to bean through it...Not the way you are doing it (with Action Class)...

    Hope this helps

    Tim
  9. Hi Suryan (Without Action Class)

    I believe the issue is with Form Bean...Since you are directly passing Form to EJB rather than Action Class...EJB needs to know about Form Bean...U need to provide struts.jar in ur classpath as well as in lib directory (to be on safe side) ...

    My suggestion to u would be use Action Class and the invoke EJB or Send information to bean through it...Not the way you are doing it ("without" Action Class)...

    Hope this helps

    Tim
  10. Hi,

    Thanks for the postings.
    Yes it was a classpath problem and i got it right now.

    Regards
    Suryan