[ 
https://issues.apache.org/jira/browse/OPENEJB-1939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13502814#comment-13502814
 ] 

Borislav Kapukaranov commented on OPENEJB-1939:
-----------------------------------------------

Hi,

I just attached a new version of the app, you can recognize it by the newer 
date. It doesn't need a listener, yet would still fail in the same manner.
IMHO the problem lies with how OpenEjb processes resources when deploying 
modules. I'm not sure there is a problem in TomEE at all.
Here's what I found during debugging:
When AutoConfig.deploy(AppModule appModule) is called it processes the various 
modules. At this point all jndi resources in the app are all merged into one 
collection. 
Processing the WebModule deployment is OK because the resources that Tomcat 
discovered are ignored, so that is fine.
But the trouble comes when processing the EjbModule deployment (the first one 
in the call order). It can't escape the Tomcat resources without your fix and 
tries to find a Service Provider for them which just isn't there, so it fails. 
I think it would have been better if the EjbModule deployment didn't process 
web/servlet resources at all so that there would be no need to ignore them if 
they aren't in the collection in the first place. After all the EjbModule 
deployment won't do anything useful for the servlet resource.

I haven't looked at the TomEE fixes but the one in OpenEjb's AutoConfig class 
looks to be in the right direction - It sounds semantically right that the 
EjbModule should ignore the web(Servlet) resources.

Best Regards
Bobby
                
> OpenEjb processes @Resource wrong
> ---------------------------------
>
>                 Key: OPENEJB-1939
>                 URL: https://issues.apache.org/jira/browse/OPENEJB-1939
>             Project: OpenEJB
>          Issue Type: Bug
>            Reporter: Borislav Kapukaranov
>         Attachments: listener.jar, TestResourceApp.war, TestResourceApp.war
>
>
> Hi,
> I have an application that injects a resource in a servlet and defines a 
> ejb-local-ref in it's web.xml but it isn't used anywhere. 
> A custom object factory is added to the naming resource for my annotated 
> field by a NamingListener. This way upon instantiating the servlet my factory 
> gets called and creates the resource.
> However this doesn't work in Tomee. OpenEjb tries to find a service provider 
> for this resource instead of letting tomcat do its work.
> I tested on tomcat 7.0.32 and tomee 1.5.0
> Attached are jar and app that will help to reproduce it. 
> Source included.
> How to setup:
> 1. Copy listener.jar into tomee/lib
> 2. Copy in tomee/conf/context.xml this: <Listener 
> className="listener.NamingListener" />
> 3. Place the app in webapps and start tomee
> 4. Request on http://localhost:8080/TestResourceApp/TestServlet
> On Tomcat I get a good response and in the server's console I can find 
> system.out of my factory:
> {quote}
> creating resource from factory
> resource ready
> {quote}
> On Tomee deployment fails with:
> Caused by: org.apache.openejb.OpenEJBException: No provider available for 
> resource-ref 'null' of type 'resource.TestResource' for 'TestBean'.
>       at 
> org.apache.openejb.config.AutoConfig.autoCreateResource(AutoConfig.java:1770)
>       at 
> org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1763)
>       at 
> org.apache.openejb.config.AutoConfig.getResourceId(AutoConfig.java:1714)
>       at 
> org.apache.openejb.config.AutoConfig.processResourceRef(AutoConfig.java:1101)
>       at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:832)
>       at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:186)
>       at 
> org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:363)
>       at 
> org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:850)
>       at 
> org.apache.tomee.catalina.TomcatWebAppBuilder.startInternal(TomcatWebAppBuilder.java:791)
> What is strange here is that it seems as if OpenEjb is trying to inject the 
> resource in the defined in the web.xml EJB instead of in the servlet.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to