6 Replies Latest reply on Jun 13, 2006 5:01 AM by dreu zel

    Casting  arguments in an EJB   Urgent !!!

    dreu zel Novice

      How can I cast arguments in a bean ????


      bean.callprocess((Object) xxx)

      where the bean was defined as an object gives an execution failure


      any way to solve the problem ????
      any way to cast from one class to any parent class ????


      15:53:12,578 ERROR [Main] Errname[javax.ejb.EJBException] Where: what What: XmlService.java-():whereSetupSession About: about
      javax.ejb.EJBException: java.lang.IllegalArgumentException: Wrong target. class com.cyclus.bean.DommerBean for public java.lang.String com.cyclus.bean.DommerBean.DomSession(com.cyclus.Dom.DomTransport)
      at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:69)
      at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
      at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:197)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:76)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:78)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:47)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
      at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
      at org.jboss.ejb3.service.ServiceContainer.localInvoke(ServiceContainer.java:199)
      at org.jboss.ejb3.service.ServiceLocalProxy.invoke(ServiceLocalProxy.java:75)

        • 1. Re: Casting  arguments in an EJB   Urgent !!!
          William DeCoste Apprentice

          Can you please post the bean, interface and client classes?

          • 2. Re: Casting  arguments in an EJB   Urgent !!!
            dreu zel Novice

            included the CODE
            but this is NOT ROCKET SCIENCE



            BEAN CASTING ERRORS

            package interf;
            import javax.ejb.Init;
            import javax.ejb.PostActivate;
            //import javax.ejb.PostConstruct;
            //import javax.ejb.PreDestroy;
            import javax.ejb.PrePassivate;
            import javax.ejb.Remove;
            import javax.ejb.SessionContext;
            import org.dom4j.Document;
            import com.cyclus.servlet.*;
            import java.util.*;


            public interface interf
            {
            public abstract String getDescriptor();
            public abstract String getStatus();
            //public String test(String ID,String value);
            //setup destruction consistency
            public void create()throws Exception ;
            public void destroy();
            public void disconnect(String Id);

            public String prcBEAN(String txt);
            public String prcBEAN(Object obj);
            public String prcBEAN_s(Servlet srv);
            }



            package bean;
            import javax.ejb.spi.*;

            //import javax.ejb.* ; //additional options

            import javax.annotation.*; //EJB,EJBs,Resource,Resources
            import javax.annotation.security.PermitAll;
            import javax.annotation.security.RolesAllowed;

            import javax.ejb.Remote;
            import javax.ejb.Local;
            import javax.ejb.Remove;

            import javax.ejb.Stateless;
            import javax.ejb.Stateful;
            import javax.ejb.SessionContext;//get the session context

            //Statefull accross session info
            import javax.ejb.Init; //init
            //import javax.ejb.PostConstruct;// init routine
            //import javax.ejb.PreDestroy;
            import javax.ejb.PrePassivate; //sleep
            import javax.ejb.PostActivate; //Unsleep
            //import javax.ejb.Resource; addition special jar
            import javax.ejb.TimedObject;
            import javax.ejb.Timer;
            import javax.ejb.Timeout;
            import javax.ejb.TimerService;
            //message beans
            import javax.ejb.MessageDriven;
            import javax.ejb.ActivationConfigProperty; //message bean
            //transaction
            import javax.ejb.TransactionAttribute;
            import javax.ejb.TransactionAttributeType;

            import javax.ejb.*;//pck up the rest
            // Jboss additions
            import org.jboss.annotation.ejb.LocalBinding;
            import org.jboss.annotation.ejb.RemoteBinding;
            import org.jboss.annotation.ejb.Service;
            import org.jboss.annotation.ejb.Management; //jmx
            import org.jboss.annotation.ejb.Producer; //message queue

            //import org.jboss.ejb3.remoting.RemoteBinding;
            //import org.jboss.ejb3.remoting.LocalBinding;

            import org.jboss.annotation.security.SecurityDomain;

            //import java.util.*;
            import java.io.Serializable;
            import java.util.HashMap;
            import java.util.Date;

            //import javax.ejb.Inject;
            import javax.jms.*;
            import org.dom4j.Document; //dom4j

            //import com.cyclus.bean.*; //include Cyclus stuff all in the bean
            //import com.cyclus.beanClient.*;
            import com.cyclus.servlet.Servlet;

            import com.cyclus.*;//error
            import com.cyclus.String.*;//error
            import org.dom4j.Document; //dom4j

            import com.cyclus.servlet.*;
            import interf.*;


            the BEAN :::::



            /*
            *
            * @stateless Nothing is remembered in the bean itself
            * @Local ({LocalBeanInterface.class}) <<<< Tag CLASS or individual Method
            * @LocalBinding (jndiBinding="beanName")
            * @Remote ({RemoteBeanInterface.class})
            * @RemoteBinding (jndiBinding="beanName")
            * class bean implements LocalBeanInterface.RemoteBeanInterface
            * @statefull Call the same stud and all bean variables remain
            *
            */
            @Service//("DomCrawl/BeanService")
            // a service request does not execute any initalisation or post actions
            //@Stateful(name="ejb/RequestBean") //global containers/DBXmlEJB //
            //@Stateless(name="ejb302")
            //@SecurityDomain("Cyclus") //Conf used Roles

            @RemoteBinding( jndiBinding="ejb/bean/remote") //global ejb/DBXmlEJB
            @LocalBinding( jndiBinding="ejb/bean/local") //global ejb/DBXmlEJB
            @Remote( interf.class)
            @Local( interf.class)

            public class Bean implements interf
            {
            public String getDescriptor() {return "Bean MINEJB";}
            public String getStatus() {return "Bean MINEJB";}
            public void create()throws Exception {}
            public void destroy() {}
            public void disconnect(String Id) {}






            try {x2=ben.prcBEAN(this);} catch (Throwable e) {System.out.print("\n bean err object");} WORKS
            try {x3=ben.prcBEAN_s(ses);} catch (Throwable e) {System.out.print("\n bean err servlet");} FAILS
            try {x1=ben.prcBEAN("this is some text to return ");} catch (Throwable e) {System.out.print("\n bean text");} WORKS


            depending on what object is passed IT FAILS
            as soon it is a home brewed class i pass EJB do not function any more !!!

            ANY Suggestions

            • 3. Re: Casting  arguments in an EJB   Urgent !!!
              William DeCoste Apprentice

              Looks like you are calling the bean from a Servlet - is Tomcat configured to use the same classloader as the EJB3 deployment? I suspect it is not. So, the passed classes are incompatible since they are not in the same classloader. To enable Tomcat to use the JBoss classloader, set the UseJBossWebLoader attribute to true in Tomcat's jboss-service.xml

              • 4. Re: Casting  arguments in an EJB   Urgent !!!
                dreu zel Novice

                Sorry I was out Yesterday


                THIS LOOKS LIKE A PATH !!!! I'll Try it immedialtly

                • 5. Re: Casting  arguments in an EJB   Urgent !!!
                  dreu zel Novice

                  Does this value has an impact on ECLIPSE JBOSS-Debugging
                  all debugging seems to be mixed up

                  "To enable Tomcat to use the JBoss classloader, set the UseJBossWebLoader attribute to true in Deploy\Tomcat's jboss-service.xml"

                  I'm investigating further

                  • 6. Re: Casting  arguments in an EJB   Urgent !!!
                    dreu zel Novice

                    setting "UseJBossWebLoader" in

                    C:\JBOSS\jboss-4.0.4.GA\server\default\deploy\jbosswebtomcat55.sar\META-INF\jboss-service.xml



                    Using Jboss 4.0.4.GA local interfaces
                    Does definetly Corrupt the presentation of the ECLIPSE Debugger.
                    Even after a complete rebuild locations and traps are placed completly (let's say at random) all references have gone


                    I seem to have an additional problem corrupting the result

                    I verify the bean interface to be correct as I setup a JNDI Connection
                    (on servlet side)

                    JNDI beancalss ->>>> Beaner
                    beaner =Ctx.lookup(beanName)
                    if (beaner instanceof bean)
                    else ----> Beaner not derived from overall Bean Class


                    Appearently the Jboss-tomcat servlet does not recogise
                    beans passed from JNDI ??
                    an other classloader problem ???? works perfectly as
                    UseJBossWebLoader=false

                    still trying to confirm/deney the original

                    Summary
                    UseJBossWebLoader=false
                    ECLIPSE_JBOSS debugging syncronisation OK
                    JNDI --> Classes are recognised

                    UseJBossWebLoader=true
                    ECLIPSE_JBOSS debugging syncronisation FAILS !!!!
                    JNDI --> Classes not recognised any more.
                    as far as can be seen the problem is NOT SOLVED
                    Still class desynchronisation beween Servlet and BEAN !!!!




                    Any other suggestions ?