tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jonathan S. Fisher" <jonat...@springventuregroup.com>
Subject Re: Rar Deployment and tomee.xml configuration
Date Thu, 15 Oct 2015 22:53:06 GMT
boom. Figured it out, it was sort of a bug in the JCA connector. Stopped
the debugger to see what interfaces the connection implents:
allocateConnection.getClass().getInterfaces()
(java.lang.Class<T>[]) [interface org.connectorz.files.Bucket]

But the original code assumes it's getting a FileBucket back:
@Override
public FileBucket getBucket() {
out.println("#FileBucketStore.getConnection " + this.cm + " MCF: " +
this.mcf);
try {
return (FileBucket) cm.allocateConnection(mcf, getConnectionRequestInfo());
} catch (ResourceException ex) {
throw new RuntimeException(ex.getMessage());
}
}


Quick fix:
@Override
public Bucket getBucket() {
out.println("#FileBucketStore.getConnection " + this.cm + " MCF: " +
this.mcf);
try {
return (Bucket) cm.allocateConnection(mcf, getConnectionRequestInfo());
} catch (ResourceException ex) {
throw new RuntimeException(ex.getMessage());
}
}

NOW WE'RE COOKING WITH PEANUT OIL


On Thu, Oct 15, 2015 at 5:44 PM, Jonathan S. Fisher <
jonathan@springventuregroup.com> wrote:

> Hmm... I made the connection class DissociatableManagedConnection and I'm
> still getting the same problem. Is there a reason the proxy doesn't
> implement the connection interface?
>
> On Thu, Oct 15, 2015 at 5:32 PM, Jonathan S. Fisher <
> jonathan@springventuregroup.com> wrote:
>
>> Actually what you just said got me thinking...
>>
>> I set the dependency to provided scope in Maven, so my code compiles. I
>> added this to tomee.xml:
>> <Resource
>> id="bucketStore"
>> class-name="org.connectorz.files.store.GenericManagedConnectionFactory">
>> rootDirectory=/tmp
>> </Resource>
>>
>> Then removed the deployments line and the apps directory. I then unpacked
>> the rar to /lib. This should force the class to be loaded from the lib
>> directory. The injection now works!!
>>
>> Now I'm getting this error:
>>
>> Oct 15, 2015 5:29:31 PM
>> org.apache.openejb.core.transaction.EjbTransactionUtil handleSystemException
>> SEVERE: EjbTransactionUtil.handleSystemException: com.sun.proxy.$Proxy149
>> cannot be cast to org.connectorz.files.store.FileBucket
>> java.lang.ClassCastException: com.sun.proxy.$Proxy149 cannot be cast to
>> org.connectorz.files.store.FileBucket
>> at
>> org.connectorz.files.store.FileBucketStore.getBucket(FileBucketStore.java:45)
>> at
>> org.connectorz.files.store.FileBucketStore.getBucket(FileBucketStore.java:26)
>> at
>> com.xxx.assettrack.jpa.SupportingDocService.saveDoc(SupportingDocService.java:36)
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>> at java.lang.reflect.Method.invoke(Method.java:497)
>>
>> Is there an interface the connection class needs to implement to avoid
>> being proxied?
>>
>>
>> On Thu, Oct 15, 2015 at 5:15 PM, Jonathan S. Fisher <
>> jonathan@springventuregroup.com> wrote:
>>
>>> The debugger shows the field annotated with @Resource is null.
>>>
>>> Stack: http://pastebin.com/WnXKaUx8
>>> Code: http://pastebin.com/f45n7S4k
>>>
>>>
>>>
>>> On Thu, Oct 15, 2015 at 5:08 PM, Romain Manni-Bucau <
>>> rmannibucau@gmail.com> wrote:
>>>
>>>> Hi Jonathan,
>>>>
>>>> not sure if gmail swallowed it but do you have your NPE stack? or is it
>>>> the
>>>> em? Something to take care with ra is to share the api between your app
>>>> and
>>>> the ra (putting it in the container instead of the rar for instance)
>>>>
>>>>
>>>> Romain Manni-Bucau
>>>> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>>>> <http://rmannibucau.wordpress.com> | Github <
>>>> https://github.com/rmannibucau> |
>>>> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
>>>> <http://www.tomitribe.com>
>>>>
>>>> 2015-10-16 0:06 GMT+02:00 Jonathan S. Fisher <
>>>> jonathan@springventuregroup.com>:
>>>>
>>>> > I got a little bit farther by putting this into system.properties
>>>> (renamed
>>>> > it):
>>>> > openejb.connector.jca-file-store.aliases = bucketStore
>>>> > openejb.connector.jca-file-store.skip-default = true
>>>> > bucketStore.rootDirectory=/tmp
>>>> >
>>>> > But now I'm getting a Null injection! Argh! What the deuce am I doing
>>>> > wrong?
>>>> >
>>>> > Logs show the resource is linked:
>>>> >
>>>> > Oct 15, 2015 5:02:16 PM org.apache.openejb.config.AutoConfig
>>>> > processResourceRef
>>>> > INFO: Auto-linking resource-ref 'java:comp/env/bucketStore' in bean
>>>> > asset-track/asset-track/asset-track.Comp1776931388 to
>>>> > Resource(id=bucketStore)
>>>> > Oct 15, 2015 5:02:16 PM org.apache.openejb.config.AutoConfig
>>>> > processResourceRef
>>>> > INFO: Auto-linking resource-ref 'java:comp/env/bucketStore' in bean
>>>> > asset-track/asset-track/IdentifiableService to
>>>> Resource(id=bucketStore)
>>>> > Oct 15, 2015 5:02:16 PM org.apache.openejb.config.AutoConfig
>>>> > processResourceRef
>>>> > INFO: Auto-linking resource-ref 'java:comp/env/bucketStore' in bean
>>>> > asset-track/asset-track/SupportingDocService to
>>>> Resource(id=bucketStore)
>>>> > Oct 15, 2015 5:02:16 PM org.apache.openejb.config.AutoConfig deploy
>>>> > INFO: Configuring PersistenceUnit(name=asset-track,
>>>> > provider=org.eclipse.persistence.jpa.PersistenceProvider)
>>>> > Oct 15, 2015 5:02:16 PM org.apache.openejb.config.AutoConfig
>>>> > logAutoCreateResource
>>>> > INFO: Auto-creating a Resource with id 'jdbc/asset_trackNonJta' of
>>>> type
>>>> > 'DataSource for 'asset-track'.
>>>> > Oct 15, 2015 5:02:16 PM org.apache.openejb.config.AutoConfig deploy
>>>> > INFO: Configuring Service(id=jdbc/asset_trackNonJta, type=Resource,
>>>> > provider-id=jdbc/asset_track)
>>>> > Oct 15, 2015 5:02:16 PM org.apache.openejb.assembler.classic.Assembler
>>>> > createRecipe
>>>> > INFO: Creating Resource(id=jdbc/asset_trackNonJta)
>>>> >
>>>> > What's weird is in IdentifiableService there is not reference to
>>>> > BucketStore:
>>>> >
>>>> >
>>>> > @Stateless
>>>> > @TransactionAttribute(TransactionAttributeType.REQUIRED)
>>>> > public class IdentifiableService {
>>>> > @PersistenceContext
>>>> > private EntityManager em;
>>>> > ...
>>>> > }
>>>> >
>>>> > HElllpppp!!!
>>>> >
>>>> > On Thu, Oct 15, 2015 at 4:40 PM, Jonathan S. Fisher <
>>>> > jonathan@springventuregroup.com> wrote:
>>>> >
>>>> > > Hey guys,
>>>> > >
>>>> > > I've read through the mailing list posts on this subject and I
>>>> _still_
>>>> > > can't get this to work.
>>>> > >
>>>> > > I'm trying to deploy Adam Bien's transactional file adapter:
>>>> > > https://github.com/AdamBien/connectorz/tree/master/files to the
>>>> server
>>>> > >
>>>> > > Here's the EJB:
>>>> > >
>>>> > > @Stateless
>>>> > > @TransactionAttribute(TransactionAttributeType.REQUIRED)
>>>> > > public class SupportingDocService {
>>>> > > @Inject
>>>> > > private Logger log;
>>>> > > @Resource(name = "ra/files/asset-track")
>>>> > > private BucketStore bucketStore;
>>>> > > ...
>>>> > > }
>>>> > >
>>>> > >
>>>> > > I've added this to tomee.xml:
>>>> > > <Deployments dir="apps" />
>>>> > >
>>>> > > And deployed the jca-file-store.rar to apps/ TomEE unpacks the
rar.
>>>> But
>>>> > > how do you configure it? I need to name the resource
>>>> > "ra/files/asset-track"
>>>> > > and set the rootDirectory property.
>>>> > >
>>>> >
>>>> > --
>>>> > Email Confidentiality Notice: The information contained in this
>>>> > transmission is confidential, proprietary or privileged and may be
>>>> subject
>>>> > to protection under the law, including the Health Insurance
>>>> Portability and
>>>> > Accountability Act (HIPAA). The message is intended for the sole use
>>>> of the
>>>> > individual or entity to whom it is addressed. If you are not the
>>>> intended
>>>> > recipient, you are notified that any use, distribution or copying of
>>>> the
>>>> > message is strictly prohibited and may subject you to criminal or
>>>> civil
>>>> > penalties. If you received this transmission in error, please contact
>>>> the
>>>> > sender immediately by replying to this email and delete the material
>>>> from
>>>> > any computer.
>>>> >
>>>>
>>>
>>>
>>
>

-- 
Email Confidentiality Notice: The information contained in this 
transmission is confidential, proprietary or privileged and may be subject 
to protection under the law, including the Health Insurance Portability and 
Accountability Act (HIPAA). The message is intended for the sole use of the 
individual or entity to whom it is addressed. If you are not the intended 
recipient, you are notified that any use, distribution or copying of the 
message is strictly prohibited and may subject you to criminal or civil 
penalties. If you received this transmission in error, please contact the 
sender immediately by replying to this email and delete the material from 
any computer.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message