Jonathan Gallimore created TOMEE-2151:
-----------------------------------------

             Summary: Use correct classloader for creating application 
resources specified in resources.xml
                 Key: TOMEE-2151
                 URL: https://issues.apache.org/jira/browse/TOMEE-2151
             Project: TomEE
          Issue Type: Bug
    Affects Versions: 7.0.4, 1.7.5
            Reporter: Jonathan Gallimore
            Assignee: Jonathan Gallimore


I have been digging into our support for connectors in WARs and EARs, and I 
believe I have uncovered (and hopefully patched) a few issues, relating to EAR 
deployments, and defining containers in an application's resources.xml file. I 
have 2 PRs (which are not ready to be merged yet), and both have a sample with 
a connector in a WAR and a connector in a EAR file.

In essence, the issue that I have run into, is where the resource adapter and 
container are defined in an application's resources.xml, like this:

<resources>
    <Resource id="SampleResourceAdapter" 
class-name="org.superbiz.connector.adapter.SampleResourceAdapter">
    </Resource>

    <Container id="SampleMDBContainer" ctype="MESSAGE">
        ResourceAdapter=SampleResourceAdapter
        ActivationSpecClass=org.superbiz.connector.adapter.SampleActivationSpec
        MessageListenerInterface=org.superbiz.connector.api.InboundListener
    </Container>

    <Resource id="SampleConnectionFactory" 
type="org.superbiz.connector.api.SampleConnectionFactory" 
class-name="org.superbiz.connector.adapter.SampleManagedConnectionFactory">
        ResourceAdapter=SampleResourceAdapter
        TransactionSupport=none
    </Resource>
</resources>

when that application is deployed through webapps, either as an EAR or a WAR, 
it would fail:

at 
org.apache.openejb.assembler.classic.Assembler.replaceResourceAdapterProperty(Assembler.java:2680)
at 
org.apache.openejb.assembler.classic.Assembler.createContainer(Assembler.java:2550)
at 
org.apache.openejb.config.ConfigurationFactory.install(ConfigurationFactory.java:429)
at 
org.apache.openejb.config.AutoConfig.processApplicationContainers(AutoConfig.java:906)
at org.apache.openejb.config.AutoConfig.deploy(AutoConfig.java:191)
at 
org.apache.openejb.config.ConfigurationFactory$Chain.deploy(ConfigurationFactory.java:403)
at 
org.apache.openejb.config.ConfigurationFactory.configureApplication(ConfigurationFactory.java:971)

In essence what was happening was, the resource for SampleResourceAdapter was 
being created as a lazy resource (i.e. initialized on first lookup), and the 
creation of the container (which happened with TCCL being set to the main TomEE 
classloader), triggered that lookup, which failed with a class not found 
exception. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to