Using Spring beans from EJB MDB

I have a situation where I need to use spring beans from an EJB 3.0 MDB. The project does not have any webapps or anything,
it will be only a MessageBean facade that needs to call spring beans. It is meant to be a service, that can be called by usign a single EJB message.
The problem is I cannot get the spring context to load properly, since the MDBean it self is initialized(constructor called) only when it receives the first message from the broker, thus It's "too late" to initialize the spring context. What I want to do is load the spring context when the EJB is deployed in the Java EE container. So, is there a way I can call a some method, class, anything when the EJB is deployed in the container. Can I do something with a deployment descriptor?
I am using glassfish V2 UR1, EJB 3.0, Spring 2.0.7 The project is deployed as a jar.

Miku wrote:
I have a situation where I need to use spring beans from an EJB 3.0 MDB. The project does not have any webapps or anything,
it will be only a MessageBean facade that needs to call spring beans. It is meant to be a service, that can be called by usign a single EJB message. Why not make it a real service? Spring's contract first web services are a very nice way to go. It hides the fact that you're using a message-driven component for processing, too.
%

Similar Messages

  • Looking up of a stateless session bean from an MDB

    Hi,
    I have been trying to invoke a method on a stateless session bean from an MDB on receipt of a message from a queue. The bean receives the message. Then it gets the initial context, but after this the following message appears:
    javax.naming.NamingException: Error instantation environment context for Message DrivenBean MyMDB: No location specified and no suitable instance of the type 'MySessionRemote' found for the ejb-ref <mySessionBean> at com.evermind.server.ejb.MessageDrivenHome.getEnvironmentContext(MessageDrivenHome.java:559)
    The session bean is in a seperate ear file. These are the deployment descriptors of the MDB:
    ejb-jar:
    <ejb-jar>
         <description>A Message-Driven Beans</description>
         <enterprise-beans>
         <message-driven>
              <description></description>
              <ejb-name>MyMDB</ejb-name>
              <ejbclass>MyMDB</ejb-class>
              <message-driven-destination>
              <jms-destination-type>javax.jms.Queue</jms-destination-type>
              </message-driven-destination>
              <ejb-ref>
              <ejb-ref-name>MySessionEJB</ejb-ref-name>
              <ejb-ref-type>Session</ejb-ref-type>
              <home>MySessionEJBHome</home>
              <remote>MySessionRemote</remote>
              </ejb-ref>
         </message-driven>
         </enterprise-beans>
         <assembly-descriptor>
         </assembly-descriptor>
    </ejb-jar>
    orion-ejb-jar
    <orion-ejb-jar>
    <enterprise-beans>
              <message-driven-deployment name="QueueProcessor" destination-location="jms/theQueue" connection-factory-location="jms/theQueueConnectionFactory">
              </message-driven-deployment>
         </enterprise-beans>
         <assembly-descriptor>
         </assembly-descriptor>
    </orion-ejb-jar>
    The lookup name which I give in MDB is:
    java:comp/env/MySessionEJB

    Hi,
        Thanks for your replies.I did as you had suggested.I added ejb-local-ref to the ejb-jar.xml and i provided ejb-ref as MyBean.
    My lookup code uses the string
    ctxt.lookup("localejbs\MyBean");
    But still i get Naming Exception.
    I tried something different yesterday.
    I changed the code to use
    InitialContext ctxt = new InitialContext();
    ctxt.lookup("localejbs/"+ pathfromJNDIRegistry);
    and this time i did not get Naming exception but i got RemoteException saying there was error loading the class.
    Is there something i need to add somewhere for the classloader to be able to find and load this class in the second scenario.
    Please suggest me which method to go for amongst the two and what is the missing information i need to add.
    Thanks
    Priya

  • Using T3 Services from EJB's

    I want to use weblogic's T3Services from within stateless session beans. But when I try to do this I get the following error
    java.rmi.RemoteException: java.lang.NoClassDefFoundError: weblogic/common/T3ServicesDef
    and when I try to put \weblogic\classes in JAVA_CLASSPATH while starting weblogic the server does not start.
    Is their a way of using these services from within EJB's
    I am using weblogic 5.1.0 service pack 6 under WINNT environment with SP5
    Thanks
    Sohit

    You have classpath problems. Please post the classpath and the weblogic
    classpath that you are using to start the server. In particular, make
    sure that your ejb-jar is not found in either of these.
    -- Rob
    Sohit wadhwa wrote:
    >
    I want to use weblogic's T3Services from within stateless session beans. But when I try to do this I get the following error
    java.rmi.RemoteException: java.lang.NoClassDefFoundError: weblogic/common/T3ServicesDef
    and when I try to put \weblogic\classes in JAVA_CLASSPATH while starting weblogic the server does not start.
    Is their a way of using these services from within EJB's
    I am using weblogic 5.1.0 service pack 6 under WINNT environment with SP5
    Thanks
    Sohit

  • OAS and using JDBC-drivers from EJB

    Hi.
    I have a problem with accessing the database from EJB-components
    deployed to OAS 4.0.8. The database is 8.1.5-version. I'm trying
    to use a connection exactly like it is documented in OAS-EJB-
    documents, the connection string looks like this:
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:jts8:@ora8i");
    And this is the error that above sentence it generates:
    "Sub Protocol must be specified in connection URL".
    The DAD(ora8i) is created in OAS.
    Now, I don't even know if this uses JDBC/OCI or thin since the
    documented connection-string doesn't contain that information. I
    quess it must use OCI-drivers, at least I should use them and
    they should be installed with OAS.
    So:
    * I should use only jts-enabled JDBC-drivers when developing EJB-
    components, is this right?
    * How can I connect to the database (from OAS 4.0.8 to Oracle
    8i), the string please?
    Thanks,
    [email protected]
    null

    Hi Suresh,
    There is lot of Documentation available on this, check these links
    http://help.sap.com/saphelp_nwce10/helpdata/en/45/07d2eeea3e0485e10000000a155369/frameset.htm
    http://help.sap.com/saphelp_nwce10/helpdata/en/45/08546ff5200486e10000000a155369/frameset.htm
    Venkat.

  • Using COM component from EJB

    Hi,
    I'd like to use a third party COM component from. I know JIntegra and such tools but I'd like to use a non-commercial software as I need it for my diploma thesis.
    Did anyone ever manage to call an ActiveX/COM component from an EJB. I mean a third party component, not a self developed one.
    Could I use M$ specific classes in my EJB or do they rule out each other?
    Any working example?
    TIA
    Frank

    Did you really manage to use third party DLLs with EZJCOM?
    Would be great if you could clarify this to me:
    If I would use M$ specific classes to have a Java / COM - communication then I would
    have to use M$ JVM, right?
    But if I use that VM, I can not use my classes within the J2EE / EJB environment as this
    requires Sun's JVM, right?
    So, if I use EZJCOM for that than I do not have to use any M$ specific stuff, right?
    Unfortunately, I did not get any further yet. The product I'd like to use is Lindo.
    I have the DLL, but trying to use it with EZJCOM it says: No COM interface definition.
    No tlb is given either. There's a JAR package with classes that seem to use JNI to call
    DLL functions, so maybe it does not provide a COM interface.
    But that means I would have to build my own (maybe VB) ActiveX DLL that calls all the funtions
    in the Lindo DLL. But that would keep me busy for weeks I guess :-(
    As I need it for my diploma thesis, I can not spend a lot of time building ActiveX components.
    Frank

  • DelegatingVariableResolver not resolving Spring beans

    I'm developing an application using ADF UI + Spring using Jdveloper11g and deploying it to Weblogic 10.3. I'm creating beans in Spring and injecting them into ADF as managed beans(via faces-config.xml). My faces-config.xml looks like:
    -------------snip-----------------------
    <?xml version="1.0" encoding="windows-1252"?>
    <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee">
    <application>
    <default-render-kit-id>oracle.adf.rich</default-render-kit-id>
    <variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver>
    </application>
    <managed-bean>
    <managed-bean-name>engineAspect</managed-bean-name>
    <managed-bean-class>com.x.EngineAspect</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    <managed-property>
    <property-name>engineAspect</property-name>
    <value>#{engineAspect}</value>
    </managed-property>
    </managed-bean>
    </faces-config>
    -------------snip-----------------------
    I'm using a backing bean to call a method on the engineAspect bean when some action happens in the UI. But, the line System.out.println(engineAspect); in the backing bean always prints a null. The backing bean has getter and setter for this field. Yet, the bean is not resolved from Spring. Any ideas what may be missing from the configuration?

    Miku wrote:
    I have a situation where I need to use spring beans from an EJB 3.0 MDB. The project does not have any webapps or anything,
    it will be only a MessageBean facade that needs to call spring beans. It is meant to be a service, that can be called by usign a single EJB message. Why not make it a real service? Spring's contract first web services are a very nice way to go. It hides the fact that you're using a message-driven component for processing, too.
    %

  • When to use Custom Adapter, Event Beans and Spring beans

    Hi,
    I have basic question on when or on what basis/scenario the Custom Adapter, Event Beans or Spring beans should be used.
    All three has same implementation methods.
    Please help me in understanding when to use Custom Adapters, Event Beans or Spring beans.
    Thanks,
    Sri
    Edited by: 897694 on Mar 7, 2012 8:12 AM

    custom adapters:
    you have to use a custom adapter when you don't find any adapter in ocep which will serve your purpose.
    Most of the times you use an adapter to connect the application with external things like http server, etc It can be both to listen the events or to send the events outside.
    Event Beans:
    This type of beans does most of the work that an adapter code does but in convention beans are not used to connect the application with external stuff
    You can use Beans as event sink etc In this case using an using an adapter is not suggestable.
    If you implement Interfaces like Initializing Bean for an adapter code it won't work properly, you have to use an event Bean in that case.
    Spring beans:
    Spring beans are used when the bean code doesn't implement EventSink or EventSender.
    These beans are used to enable something (eg: make ${wlevs_dev_home}/abc/a/b.java this path is not understandable by java code unless you override the path using a spring bean)
    Most of the things which doesn't need a connection between components in the application (eg cache loader: you can do this using spring beans and event beans both but spring beans doesn't need a connection with cache)
    Hope this small writeup helps you :)
    Edited by: Patha on Mar 8, 2012 9:10 AM

  • Injecting session bean from different EAR

    Dear all,
    I am using ejb3. i have ejb.ear and web.ear. both deploy in same weblogic server.
    i want to inject session bean from ejb.ear inside web.ear.
    With Regards,
    WP

    hi,
    Currently, we want to separate it. Because may be we will deploy in different server in the future.
    So far, i can inject it using remote interface.
    How about local interface? is it possible to use local interface? because so far both deploy on same server.
    As far as i know, glassfish can't. isn't it?
    it is j2ee standard or server specific?
    With Regards,
    WP

  • Using Spring JMS DefaultMessageListenerContainer within Oracle CEP

    Hi everyone,
    I need to use a DefaultMessageListenerContainer Spring bean (from spring-jms.jar), have the wlevs bean factory to assemble it (it depends from a POJO) and set it as a property of an Adapter bean.
    How do I do it?
    I tried to put the spring-jms.jar into the xbootclasspath but it depends from spring-core.jar. If i put spring-core.jar into the xbootclasspath, the server dies screaming.
    Documentation says i can use legacy Spring beans within an OCEP application, well how do i do it? Can anyone tell me the right steps to do?

    Thanks for the answer :), i just had to import the appropriate packages into the MANIFEST.MF, put all the classes referring to spring-jms into the bundle and away i went.
    The application starts, listens to the JMS destination (an Oracle AQ queue) and dequeues messages correctly.
    I still have a problem when i try to suspend/uninstall the application from the OCEP visualizer.
    The JMS listener is encapsulated into an OCEP ResumableBean/SuspendableBean. It gets created and started (with a call to DefaultMessageListenerContainer.start()) within the beforeResume() method. I hoped that putting a call to DefaultMessageListenerContainer.shutdown() within the suspend() method would do the trick but... the undeployment hangs for a while, then the following is printed on stdout:
    ####<13-gen-2011 17.09.15 CET> <Error> <org.springframework.osgi.extender.internal.util.concurrent.RunnableTimedExecution> <> <myServer> <[ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <> <1294934955875> <BEA-000000> <Closing runnable for context OsgiBundleXmlApplicationContext(bundle=cepcc-adapter-test-aq, config=osgibundle:/META-INF/spring/*.xml) did not finish in 10000ms; consider taking a snapshot and then shutdown the VM in case the thread still hangs>
    ####<13-gen-2011 17.09.15 CET> <Notice> <Deployment> <> <myServer> <[ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'> <> <> <> <1294934955895> <BEA-2045001> <The application bundle "cepcc-adapter-test-aq" was undeployed successfully>
    ####<13-gen-2011 17.09.29 CET> <Warning> <Spring> <> <myServer> <Timer-5> <> <> <> <1294934969426> <BEA-2047008> <Exception encountered while stopping application "cepcc-adapter-test-aq": java.lang.IllegalStateException: BundleContext is no longer valid
    java.lang.IllegalStateException: BundleContext is no longer valid
         at org.eclipse.osgi.framework.internal.core.BundleContextImpl.checkValid(BundleContextImpl.java:1047)
         at org.eclipse.osgi.framework.internal.core.BundleContextImpl.getService(BundleContextImpl.java:694)
         at org.springframework.osgi.service.importer.support.internal.support.ServiceWrapper.getService(ServiceWrapper.java:99)
         at org.springframework.osgi.service.importer.support.internal.aop.ServiceDynamicInterceptor$ServiceLookUpCallback.doWithRetry(ServiceDynamicInterceptor.java:107)
         at org.springframework.osgi.service.importer.support.internal.support.RetryTemplate.execute(RetryTemplate.java:83)
         at org.springframework.osgi.service.importer.support.internal.aop.ServiceDynamicInterceptor.lookupService(ServiceDynamicInterceptor.java:430)
         at org.springframework.osgi.service.importer.support.internal.aop.ServiceDynamicInterceptor.getTarget(ServiceDynamicInterceptor.java:415)
         at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
         at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:131)
         at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:119)
         at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
         at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
         at $Proxy371.unregisterMBean(Unknown Source)
         at com.bea.wlevs.spring.MBeanRegistrationBeanPostProcessor.destroy(MBeanRegistrationBeanPostProcessor.java:145)
         at com.bea.wlevs.spring.ApplicationContextLifecycle.onContextClosedEvent(ApplicationContextLifecycle.java:261)
         at com.bea.wlevs.spring.ApplicationContextLifecycle.onApplicationEvent(ApplicationContextLifecycle.java:149)
         at org.springframework.context.event.SimpleApplicationEventMulticaster$1.run(SimpleApplicationEventMulticaster.java:78)
         at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
         at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:76)
         at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:274)
         at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:819)
         at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.doClose(AbstractOsgiBundleApplicationContext.java:197)
         at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:69)
         at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:214)
         at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
         at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:210)
         at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextExecutor.java:379)
         at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:236)
         at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:794)
         at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$3.run(ContextLoaderListener.java:807)
         at org.springframework.osgi.extender.internal.util.concurrent.RunnableTimedExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60)
         at org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:66)
         at java.util.TimerThread.mainLoop(Timer.java:512)
         at java.util.TimerThread.run(Timer.java:462)
    >
    I also tried a call to DefaultMessageListenerContainer.setTaskExecutor passing it an anonymous class like this:
    container.setTaskExecutor(new TaskExecutor() {
    @Override
    public void execute(Runnable task) {
    logger.debug("Submitting runnable task");
    executorPool.submit(task);
    where executorPool is an instance field of the OCEP bean initialized like this: executorPool = Executors.newFixedThreadPool(8);
    Anyway the result is the same, when i perform the uninstall from the OCEP visualizer the application is undeployed, but with the same painful message.
    Any hint on what i'm doing wrong?
    Thanks in advance!
    Edited by: javawarrior2003 on 13-gen-2011 17.29

  • Stepping into Java Beans from JSP

    I am trying to figure out how to step into the Java Source code for my beans that are used in my JSP pages. I need to be able to debug them by stepping into them, using break points, etc.
    I have Nitro installed and a sample JSP page with the import to my test Java Bean class. What I did was create two projects in my work space. One as a Web project application and one as a Java project. I referenced and opened both projects. Everything compiles fine and the syntax is correct.
    The problem is I can not make the link for importing the class.
    I get this error: Class com.BrianTest.MyBean not found in import com.BrianTest.MyBean
    Anyone got a clue or a good example? I did try and add the class path and I tried to put it in a Jar file and attach the source to the Jar, but same problem.
    Thanks :?

    Stepping into jsp:useBean is not possible, but you can step-into jsp getter & setter tag.
    Since you are using java bean from a dependent project you need to configure your server with DevLoader.
    And currently only Tomcat server can be configured with Sysdeo Devloader to handle this situation
    Download Sysdeo DevLoader for Tomcat from http://www.sysdeo.com/eclipse/tomcatPlugin.html
    NOTE: If the project is self sufficient and not dependent on other projects/locations for classess/libraries then NitroX picks up all the libraries & classes present within default WEB-INF/lib & WEB-INF/classes respectively. And in this case you need not modify server configuration.
    Sysdeo DevLoader is to allow your web project to use libraries/classes from dependent projects. All you need to do is extract DevLoader.zip present within tomcatPluginV3.zip inside your Tomcat/server/classes folder.
    For more information about DevLoader please refer to http://www.sysdeo.com/eclipse/readmeDevLoader.html
    This will solve your problem and you should be able to run/debug your application. And most important make sure you have the correct NitroX build that supports Sysdeo DevLoader, refer http://www.m7.com/whatsnew.htm document against your build id (Help > About NitroX > NitroX Icon)

  • Insert data into table from JSP page using Entity Beans(EJB 3.0)

    I want to insert data into a database table from JSP page using Entity Beans(EJB 3.0).
    1. I have a table 'FRIENDS', (in Oracle 10g database).
    2. It has two columns, 'NAME' and 'CITY'. Both have datatype strings(varchar2).
    3. Now from a JSP page, having two textfields, 'NAME' and 'CITY', I want to insert data into table 'FRIENDS'.
    4. In between JSP and database is a Entity Bean(EJB 3.0) and a stateless session bean.
    5. I am using JDev as editor.
    Please provide me code ASAP or link with similar example.
    Thank you.
    Anurag

    Hi,
    I am also trying that scenario. So u can
    Post the jsp form data to a Servlet which will act as a Controller.
    In the servlet invoke the business method.
    Similar kind of app is in www.roseindia.net
    Hope this would help u.
    Meanwhile if u get any optimal solution, pls post it.
    Thanks,
    Happy Java Coding.

  • Calling Local Stateless session bean from Spring in weblogic 10.3

    We are in the process of upgrading to Weblogic 10.3 from OC4J (OAS). We are using Spring and Stateless Session EJB 3 Local beans (Don't ask me why, it is decided before I came to the project).
    Previously (OC4J):
    -> There is no ejb-jar.xml. EJBs are configured with annotation @Stateless. No "name" or "mappedName" are defined.
    Spring POJOs access EJBs by using "EJBMODULENAME_<<EJBBeanClass>>Local" as JNDI Name. I think this strange JNDI name is what OC4J assigns when there is no explicit JNDI name defined.
    Sample Spring Bean configuration -
    <bean name="securityEJB" class="org.springframework.ejb.access.LocalStatelessSessionProxyFactoryBean" lazy-init="true">
              <property name="jndiName">
                   <value>myapp-ejb_SecurityEJBImplLocal</value>
              </property>
              <property name="resourceRef">
                   <value>false</value>
              </property>
              <property name="businessInterface">
                   <value>my.package.SecurityEJB</value>
              </property>
         </bean>
    I understand that weblogic 10.x doesn't give any global JNDI name (JNDI tree is empty) and also looked at the blog, Link: [http://m-button.blogspot.com/2008/07/reminder-on-how-to-use-ejb3-with.html]
    So far I have tried,
    1. @EJB annotation works but, I don't want to add @EJB annotations in the entire application. Since we are using Spring and EJB3, I am trying to avoid mixing them -
    2. java:comp/env is supposed to work (since it is a local session bean), but it doesn't for me.
    I haven't added weblogic-ejb-jar.xml as I don't think it is going to help, as there is no global JNDI name defined. Am I missing some thing?
    Thx

    Hi,
    if you don't want to use @EJB to inject the EJB, then you'll need declare the EJB reference in deployment descriptor.
    Here is an example copied from EJB3 spec:
    <ejb-local-ref>
    <description>
    This is a reference to the local business interface
    of an EJB 3.0 session bean that provides a payroll
    service.
    </description>
    <ejb-ref-name>ejb/Payroll</ejb-ref-name>
    <local>com.aardvark.payroll.Payroll</local>
    </ejb-local-ref>
    then you can lookup the local ejb from "java:comp/env/ejb/Payroll".

  • Trying to call stateless session bean from MDB

    Folks,
    Am working on RAD and WAS 8.
    I have an MDB. And a stateless session bean (AOBean under EJB project).
    While the listener listens to the messages from queue, it also tries to persist to db. I want to achieve this via a method of AOBean (through instantiating session bean or by injection).
    I have been sucessful by invoking a method from AOBean class -  that method just returns a string (without any objects being passed)
    Problem:
    I am getting IllegalStateException when I try to invoke a method of AOBean class, that has an object as a parameter
    For eg:
    MDB
    @EJB(name="ejb/TransactionMgrAOBean", mappedName="ejb/TransactionMgrAOBean")
    ITransactionMgrAO tranAO;
        public void onMessage(Message message) {
         TextMessage textMessage = (TextMessage) message;
         boolean status = false;
      try {
       TransactionVO tranVO =  getTransactionVO();//Here building the object to be passed to session bean
       String status1  = tranAO.getVersion(tranVO);
      }catch(Exception e){
    AOBean
    @Stateless
    @Remote({ ITransactionMgrAO.class })
    @WebService
    public class TransactionMgrAOBean {
    public String getVersion(TransactionVO tranVO) throws Exception{
      try{
    //business logic 
      } catch(Exception e){
      throw e;
      return true;
    TransactionVO implements Serializable has also inner static classes that are not Serializable.
    EXCEPTION: At runtime we are getting exception saying that the inner classes are not serialized.
    REASON why we are invoking session bean from MDB? We found that if we invoke any service from AOBean the transaction management was successful. We are using sessionContext.setRollBackonly when an exception occurs. Tranasactions are not rolled back when any db exception occurs if we invoke business logic methods from Model layer of another NON-EJB package.
    Hope I have provided enough information!

    My concret problem is that I want to call an ejb session contained in an ejb project from a session bean in a different web project. When I include the code in my web session bean I get the error adjunted:
    - Code:
    @EJB
    private UserRemote userSessionBean;
    - Error:
    Exception Details: javax.naming.NameNotFoundException
    pac.UserRemote#pac.UserRemote not found
    Possible Source of Error:
    Class Name: com.sun.enterprise.naming.TransientContext
    File Name: TransientContext.java
    Method Name: doLookup
    Line Number: 216
    Any suggestion?

  • How can i design a EJB application using session Beans?

    Hello,
    I am designing a Find application using EJB. Here a user is prompted a search page, where he can enter the search criteria's. Then on click of submit, the query is formed at the server side depending on what criteria's were selected. Then a jdbc query is performed and the results are returned back to the user. Here no session is maintained for the users. Can anyone suggest me how to design this application using EJB. Should i use entity beans for this or session beans will suffice? Should the jdbc query be performed in the bean itself or should it be outside in a helper class? Please kindlu suggest me the design for this application...
    Regards,
    Subbu

    Hi,
    First of all, I'm unable to figure out why you need to use EJB for this scenario. You can write a helper class to frame and execute the query.
    If you really want to use EJB, then I suggest you use a stateless Session Bean with transaction attribute as TX_NOT_SUPPORTED. From the session bean, you can call the helper class. But, by avoiding the session bean, you can eliminate remote calls, thus improving your performance. Also, check if the database & the db driver you are using supports sql caching.
    Regards,
    Raj.

  • Help needed in EJB - to call AS from EJB a Session Bean

    Hi All ,
    I have been strictly told not to use Web Services as all the applications are on the same server
    actually I have to make an EJB invocation to an Application Service from the CAF layer from a Session Bean of another EJB Project(Not a CAF Service).
    the CAF layer has 5 parts metadata , permissions , dictionary , ear and ejbmodule.
    I added the ejbModule to the Build Path of the calling EJB Session Bean. And so I was able to access the operations of the Application Service which in turn accesses a BAPI(The Appl Service operation returns a String).
    But while executing I got the exception java.lang.RuntimeException: java.lang.NoClassDefFoundError
    My method :
    Normally from a Dynamic Web Project acting as a client to an EJB Session bean, I was able to get access to EJB Local Interface by using
      private ConverterLocal converterBean = null;
      public void jspInit() {
        try {
         InitialContext ic = new InitialContext();
         converterBean = (ConverterLocal)
         ic.lookup("java:comp/env/Converter");
        } catch (Exception ex) {
             System.out.println("Couldn't create converter bean."+
           ex.getMessage());
    BigDecimal dollarAmount =  converterBean.euroToDollar(value);
    So I created a JNDI field in ejb-j2ee-engine.xml
    enterprise-beans>
            <enterprise-bean>
         <ejb-name>com.sap*******.bapi_company_getlist.BAPI_COMPANY_GETLIST</ejb-name>
                   <jndi-name>COMPANY</jndi-name>
                </enterprise-bean>
    </enterprise-beans>
    And from my Session Bean , I tried to access it using the code in already existing Bean which was working fine
    BAPI_COMPANY_GETLISTBeanImpl bean = new BAPI_COMPANY_GETLISTBeanImpl();
              try {
                   InitialContext ctx = new InitialContext();
                   bean = (BAPI_COMPANY_GETLISTBeanImpl)ctx.lookup("COMPANY");
              } catch (NamingException e) {
                   System.out.println("Converter Bean can't be created");
                   String send = bean.returnDetails();
    And I tried to print the String , but I got the above error
    I have a doubt :
    1) How do I specify the JNDI name ie in the ejb-j2ee-engine.xml file , what should I add as the name of the ejb
    is this sufficient , or are there more steps ??

    Hi Ekaterina,
    I have the document to access my Bean from another Bean.
    I could access my Bean from a standalone Java class with this code
    Properties props = new Properties();
              props.put(Context.INITIAL_CONTEXT_FACTORY,"com.sap.engine.services.jndi.InitialContextFactoryImpl");
              props.put(Context.PROVIDER_URL,"hostname:port");
              try{
                   Context ctx = new InitialContext(props);
                   Object o = ctx.lookup("sap.com/TestEAR/REMOTE/TestBean/com.@#$.TestRemote");
                   TestRemote testRem = (TestRemote)javax.rmi.PortableRemoteObject.narrow(o, TestRemote.class);
                   String msg = testRem.getMessage();
                   System.out.println(msg);
    And in this document there is a way shown to access a bean from another Bean.
       http://help.sap.com/saphelp_nw04/helpdata/en/13/c8633e0084e946e10000000a114084/frameset.htm
    If your client is another enterprise bean, declare the EJB reference in the ejb-jar.xml.
    -For more information, see Declaring EJB References.
    But the problem is that in EJB 3.0 ,  I can't see the ejb-jar.xml file .
    So how should I have a Bean as a client to another Bean, I am not that familiar with Annotations.

Maybe you are looking for

  • S_ALR_87012357 / S_ALR_87012356-Wrong reporting of tax amounts on the tax reports.

    Hi, S_ALR_87012357 / S_ALR_87012356 Tax amount for tax codes V9, VP and VT are calculated and displayed correctly in FI reporting but they are reported at a higher amount in the tax reports run by transactions S_ALR_87012357 / S_ALR_87012356. Since i

  • Mac mini and os x mountain lion help

    hi i want to buy mac mini 2011 with lion server this week so when os x mountain lion is relesed will i be able to upgrade my os x lion to os x mountain lion if yes does it costs money if costs how much it costs

  • Recovery lost  undo tablespace and Redo log

    Recovery undo tablespace [email protected]> shutdown Database closed. Database dismounted. ORACLE instance shut down.e [email protected]> exit Disconnected from Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production With the Partiti

  • InDesign CS5 crashes on startup - Mac OSX Lion

    Hi Everyone, I've reinstalled InDesign, Photoshop and Illustrator CS5 after upgrading to Mac OSX Lion, Photoshop and Illustrator work fine but InDesign crashes on startup. I've followed a few threads on here, one suggested creating a new adimistrator

  • Macromedia Studio 8

    Hello, I bought Macromedia Studio 8 a few years back and have been very satisfied. I recently updated the OS on my Mac and now I am unable to install Studio 8 to my machine. What can I do? Thank you for the help, -Steffen