openejb-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "lupu.slobodu" <lupu.slob...@gmail.com>
Subject Re: Custom Resource Factory
Date Tue, 19 Aug 2008 21:56:13 GMT

I am not sure about this, but it looks like the container is checking for a
service provider definition  in service-jar.xml compatible with my type(that
would be "sample.jndi.ResourceBean") 
Is there a chance that I could add such a definition?


David Blevins wrote:
> 
> 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.
>>
>>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Custom-Resource-Factory-tp18852971p19059489.html
Sent from the OpenEJB User mailing list archive at Nabble.com.


Mime
View raw message