Announcement Announcement Module
Collapse
No announcement yet.
MDB needs to use Spring/Hibernate bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MDB needs to use Spring/Hibernate bean

    Hi all,

    I have the following setup:

    +EAR file containing a WAR (Spring MVC, Spring Hibernate) and EJB (regular MDB)
    +Deploying on WAS6.0.2.7 of both work fine independently. However, I have manager/service classes in the WAR file that do database stuff (via Spring/Hibernate) that I'm trying to access via the MDB. I successfully get the manager and dao beans from app context but when I try executing the database update/save, I get the following error:

    Code:
    org.springframework.dao.DataAccessResourceFailureException: Could not register synchronization with JTA TransactionManager; nested exception is java.lang.UnsupportedOperationException: Could not register synchronization with JTA TransactionManager; nested exception is java.lang.UnsupportedOperationException
    .

    I've tried searching these forums and the net in general but have not been able to pinpoint what is going wrong. I tried utilizing the Spring AbstractMessageDriven class but came up with this error:

    Code:
    [1/29/07 10:01:56:681 EST] 00000081 ExceptionUtil E   CNTR0019E: EJB threw an unexpected (non-declared) exception during invocation of method "onMessage". Exception data: com.ibm.ejs.container.CreateFailureException: ; nested exception is: 
    	java.lang.reflect.InvocationTargetException
    	at com.ibm.ejs.container.MessageDrivenBeanO.<init>(MessageDrivenBeanO.java:155)
    	at com.ibm.ejs.container.CMMessageDrivenBeanO.<init>(CMMessageDrivenBeanO.java:70)
    	at com.ibm.ejs.container.CMMessageDrivenBeanOFactory.create(CMMessageDrivenBeanOFactory.java:39)
    	at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:858)
    	at com.ibm.ejs.container.EJSHome.createBeanO(EJSHome.java:961)
    	at com.ibm.ejs.container.activator.UncachedActivationStrategy.atActivate(UncachedActivationStrategy.java:83)
    	at com.ibm.ejs.container.activator.Activator.activateBean(Activator.java:595)
    	at com.ibm.ejs.container.EJSContainer.preInvokeActivate(EJSContainer.java:3365)
    	at com.ibm.ejs.container.EJSContainer.preInvokeMdbActivate(EJSContainer.java:2987)
    	at com.ibm.ejs.container.MessageEndpointHandler.beforeDelivery(MessageEndpointHandler.java:1261)
    	at com.ibm.ejs.container.MessageEndpointHandler.invokeMessageEndpointMethod(MessageEndpointHandler.java:746)
    	at com.ibm.ejs.container.MessageEndpointHandler.invoke(MessageEndpointHandler.java:712)
    	at $Proxy17.beforeDelivery(Unknown Source)
    	at com.ibm.ws.sib.ra.inbound.impl.SibRaTransactionalDispatcher.beforeDelivery(SibRaTransactionalDispatcher.java:296)
    	at com.ibm.ws.sib.ra.inbound.impl.SibRaDispatcher.dispatch(SibRaDispatcher.java(Compiled Code))
    	at com.ibm.ws.sib.ra.inbound.impl.SibRaSingleProcessListener$SibRaWork.run(SibRaSingleProcessListener.java(Compiled Code))
    	at com.ibm.ejs.j2c.work.WorkProxy.run(WorkProxy.java(Compiled Code))
    	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
    Caused by: java.lang.reflect.InvocationTargetException
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
    	at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
    	at com.ibm.ejs.container.MessageDrivenBeanO.<init>(MessageDrivenBeanO.java:149)
    	... 17 more
    Caused by: org.springframework.beans.factory.access.BootstrapException: Define an environment variable [java:comp/env/ejb/BeanFactoryPath] containing the class path locations of XML bean definition files; nested exception is javax.naming.NameNotFoundException: Name comp/env/ejb not found in context "java:".
    	at org.springframework.context.access.ContextJndiBeanFactoryLocator.useBeanFactory(ContextJndiBeanFactoryLocator.java:76)
    	at org.springframework.ejb.support.AbstractEnterpriseBean.loadBeanFactory(AbstractEnterpriseBean.java:117)
    	at org.springframework.ejb.support.AbstractMessageDrivenBean.ejbCreate(AbstractMessageDrivenBean.java:76)
    	at com.wiley.ptmd.reportgenerator.ejb.ReportRequestListener.ejbCreate(ReportRequestListener.java:159)
    	... 23 more
    Caused by: javax.naming.NameNotFoundException: Name comp/env/ejb not found in context "java:".
    	at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1766)
    	at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1082)
    	at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:990)
    	at com.ibm.ws.naming.urlbase.UrlContextImpl.lookup(UrlContextImpl.java:1263)
    	at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:201)
    	at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:142)
    	at javax.naming.InitialContext.lookup(InitialContext.java:361)
    	at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java:124)
    	at org.springframework.jndi.JndiTemplate.execute(JndiTemplate.java:86)
    	at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:122)
    	at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:147)
    	at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:90)
    	at org.springframework.context.access.ContextJndiBeanFactoryLocator.useBeanFactory(ContextJndiBeanFactoryLocator.java:67)
    	... 26 more
    Any help would be greatly appreciated.


    Thanks!!

  • #2
    What does your ejb-jar.xml for the MDB looks like? Did you provide the BeanFactoryPath property there?

    Regards,
    Andreas

    Comment


    • #3
      Hmmmm, did not specify it. How and where in the ejb-jar file do I need to place it? By specifying it in there, which option would I be able to use: AbstractMessageDrivenBean or my original setup of manager/dao access in WAR from MDB?

      Thanks!

      Here is my ejb-jar.xml:

      Code:
      <?xml version="1.0" encoding="UTF-8"?>
      <ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
      	<display-name>ReportRequestListener</display-name>
      	<enterprise-beans>
      		<message-driven id="com.wiley.ptmd.reportgenerator.ejb.ReportRequestListener">
      			<ejb-name>ReportRequestListener</ejb-name>
      			<ejb-class>com.wiley.ptmd.reportgenerator.ejb.ReportRequestListener</ejb-class>
      			<transaction-type>Bean</transaction-type>
      			<message-destination-type>javax.jms.Queue</message-destination-type>
      			<activation-config>
      				<activation-config-property>
      					<activation-config-property-name>destinationType</activation-config-property-name>
      					<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
      				</activation-config-property>
      				<activation-config-property>
      					<activation-config-property-name>acknowledgeMode</activation-config-property-name>
      					<activation-config-property-value>Auto-acknowledge</activation-config-property-value>
      				</activation-config-property>
      				<activation-config-property>
      					<activation-config-property-name>subscriptionDurability</activation-config-property-name>
      					<activation-config-property-value>Durable</activation-config-property-value>
      				</activation-config-property>
      			</activation-config>
      		</message-driven>
      </enterprise-beans>
      	<assembly-descriptor>
      	</assembly-descriptor>
      </ejb-jar>

      Comment


      • #4
        Just add an environment entry like this

        Code:
        <env-entry>
        	<env-entry-name>ejb/BeanFactoryPath</env-entry-name>
        	<env-entry-type>java.lang.String</env-entry-type>
        	<env-entry-value>context.xml</env-entry-value>
        </env-entry>
        It will be evaluated from AbstractMessageDrivenBean.

        Regards,
        Andreas

        Comment


        • #5
          What goes in context.xml? BeanFactory definition?

          Comment


          • #6
            context.xml is the name of your Spring application context file. If you have more than one file, you can specify them all as whitespace-separated list.
            The file(s) will be looked up relative to the classloading root (e.g. the root of the EJB jar).

            Some additional information can be found here.

            Regards,
            Andreas

            Comment

            Working...
            X