openejb-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: Custom Resource Factory
Date Tue, 12 Aug 2008 23:43:43 GMT
That definitely should work.  Let me see if I can't reproduce this.

-David

On Aug 12, 2008, at 1:45 PM, lupu.slobodu wrote:

>
> If I declare my session bean in ejb-jar.xml, together with the
> resource-env-ref like this
>
>        <session>
>            <ejb-name>CalculatorImpl</ejb-name>
>            <business-local>sample.CalculatorLocal</business-local>
>            <ejb-class>sample.CalculatorImpl</ejb-class>
>            <transaction-type>Container</transaction-type>
>
> 			<resource-env-ref>
> 				  <description>
> 				    Object factory for MyBean instances.
> 				  </description>
> 				
> 				  <resource-env-ref-name>
> 				     bean/ParamsFactory
> 				  </resource-env-ref-name>
> 				
> 				  <resource-env-ref-type>
> 				    sample.jndi.ResourceBean
> 				  </resource-env-ref-type>
> 			</resource-env-ref>
>        </session>
>
>
> it crashes at deploy time like this:
>
> org.apache.openejb.OpenEJBException: No provider available for  
> resource-ref
> 'null' of type 'sample.jndi.ResourceBean' for 'CalculatorImpl'.
> 	at
> org 
> .apache.openejb.config.AutoConfig.autoCreateResource(AutoConfig.java: 
> 1292)
> 	at  
> org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java: 
> 1285)
> 	at  
> org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java: 
> 1236)
> 	at
> org 
> .apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java: 
> 781)
> 	at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:706)
> 	at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:133)
> 	at
> org.apache.openejb.config.ConfigurationFactory 
> $Chain.deploy(ConfigurationFactory.java:148)
> 	at
> org 
> .apache 
> .openejb 
> .config 
> .ConfigurationFactory.configureApplication(ConfigurationFactory.java: 
> 440)
> 	at
> org 
> .apache 
> .openejb 
> .tomcat.catalina.TomcatWebAppBuilder.start(TomcatWebAppBuilder.java: 
> 233)
> 	at
> org 
> .apache 
> .openejb 
> .tomcat 
> .catalina 
> .GlobalListenerSupport.lifecycleEvent(GlobalListenerSupport.java:58)
> 	at
> org 
> .apache 
> .catalina 
> .util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
> 	at
> org.apache.catalina.core.StandardContext.start(StandardContext.java: 
> 4252)
> 	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java: 
> 1045)
> 	at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
> 	at org.apache.catalina.core.ContainerBase.start(ContainerBase.java: 
> 1045)
> 	at  
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
> 	at  
> org.apache.catalina.core.StandardService.start(StandardService.java: 
> 516)
> 	at  
> org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
> 	at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> 	at java.lang.reflect.Method.invoke(Unknown Source)
> 	at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
> 	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
>
> David Blevins wrote:
>>
>>
>> On Aug 8, 2008, at 11:11 AM, lupu.slobodu wrote:
>>
>>>
>>> Here it is what I've been trying:
>>>
>>> 1)Resource Factory configuration in tomcat context.xml
>>>
>>> <Resource
>>>      name="bean/ParamsFactory"
>>>      auth="Container"
>>>      type="sample.jndi.ResourceBean"
>>>      factory="sample.jndi.GenericObjectFactory"
>>> 		value="ContextResource"
>>>      />
>>>
>>> 2)test web application's  web.xml
>>>
>>> <resource-env-ref>
>>> <description>
>>>   Object factory for ResourceBean instances.
>>> </description>
>>> <resource-env-ref-name>
>>>    bean/ParamsFactory
>>> </resource-env-ref-name>
>>> <resource-env-ref-type>
>>>   sample.jndi.ResourceBean
>>> </resource-env-ref-type>
>>> </resource-env-ref>
>>>
>>>
>>> I can look it up successfully from a servlet like this
>>>
>>> 		Context initCtx = new InitialContext();
>>> 		Context envCtx = (Context) initCtx.lookup("java:comp/env");
>>> 		ResourceBean bean = (ResourceBean) envCtx.lookup("bean/
>>> ParamsFactory");
>>>
>>>
>>> The same look up fails  when performed inside a session bean.
>>>
>>> I tried to integrate the declarations in the openejb web module
>>> web.xml
>>> descriptor also but with no success.
>>
>> If you can look it up from a Servlet, we're not too far! Post the  
>> ejb-
>> jar.xml you using if you can.  You would need an identical resource-
>> env-ref in there for your session bean.
>>
>> -David
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Custom-Resource-Factory-tp18852971p18952298.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>


Mime
View raw message