Open dimaki opened 10 years ago
BTW: The resource adapter configuration section in the standalone.xml of Wildfly is:
<subsystem xmlns="urn:jboss:domain:resource-adapters:2.0">
<resource-adapters>
<resource-adapter id="jca-file-store.rar">
<archive>
jca-file-store.rar
</archive>
<transaction-support>LocalTransaction</transaction-support>
<connection-definitions>
<connection-definition class-name="org.connectorz.files.store.GenericManagedConnectionFactory" jndi-name="java:jboss/eis/Bucket" enabled="true" use-java-context="true" pool-name="Bucket" use-ccm="true">
<config-property name="rootDirectory">
./store/
</config-property>
<pool>
<min-pool-size>0</min-pool-size>
<max-pool-size>10</max-pool-size>
<prefill>false</prefill>
<use-strict-min>false</use-strict-min>
<flush-strategy>FailingConnectionOnly</flush-strategy>
</pool>
<security>
<application/>
</security>
</connection-definition>
</connection-definitions>
</resource-adapter>
</resource-adapters>
</subsystem>
I am struggling with this issue. How did you resolve it?
Hi,
I tried the following:
................org.connectorz.files.store.Client........... package org.connectorz.files;
import java.net.URI; import javax.annotation.Resource; import javax.ejb.Stateless; import javax.ws.rs.*; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.connectorz.files.Bucket; import org.connectorz.files.BucketStore; import org.connectorz.files.FileBucketStore;
/*
// @Resource(name = "jca/files") @Resource(lookup = "java:jboss/eis/Bucket") // BucketStore bucketStore; Object bucketStore;
@GET
@Path("start")
// public String fetch(@PathParam("id") String id) {
public String fetch() {
if(null == bucketStore){
return "bucketStore is NULL";
}else{
BucketStore b = (FileBucketStore)bucketStore;
return "bucketStore is NOT NULL";
}
}
@GET
@Path("ping")
public String pint() {
return "- - - P I N G ! - - - ";
}
...................
I changed the return type from Object to FileBucketStore
.................org.connectorz.files.store.GenericManagedConnectionFactory.............. @Override public FileBucketStore createConnectionFactory(ConnectionManager cxManager) throws ResourceException { out.println("#GenericManagedConnectionFactory.createConnectionFactory,1"); return new FileBucketStore(out,this, cxManager); }
@Override
public FileBucketStore createConnectionFactory() throws ResourceException {
out.println("#GenericManagedConnectionFactory.createManagedFactory,2");
return new FileBucketStore(out,this, null);
}
...................
The client is getting the injection (Yuppiiiii!!!) but still getting an strange error during casting :-(
............Console.......... Caused by: javax.ejb.EJBException: java.lang.ClassCastException: org.connectorz.files.FileBucketStore cannot be cast to org.connectorz.files.FileBucketStore ...................
Some suggestions or solved in the meantime?
Thanks and regards
Frank
Same error here on Payara:
java.lang.IllegalArgumentException: Can not set org.connectorz.files.BucketStore field com.abien.filestore.FilesResource.bucketStore to org.connectorz.files.store.FileBucketStore
this is a clasloading-issue. the .rar-file as well as the client.war contain the api.jar. it should not be part of the client.jar. change the pom.xml of the client.jar to have the api as provided-scope:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.connectorz.files</groupId>
<artifactId>files</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>org.connectorz.files</groupId>
<artifactId>client</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>JCA Test Client</name>
<dependencies>
<dependency>
<groupId>org.connectorz.files</groupId>
<artifactId>api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
How do we solve the problem, if we aren't using maven to do the deployments.
I basically extracted the "Bucket" and "BucketStore" interfaces into a saperate jar . and injected this jar as a dependency in both the rar-file and the Jax-RS-client of this rar. But i still see the first error reported in the issue even on the latest package of build. Note i also over came the issues on needing to apply the equals and hashCode method and removing the @Min(1) annotation.
Questions: 1) Is there a specific way to implement the hashCode and equals method in the FileAdapter? As of now i am just in-turn invoking the super.hashCode() and super.equals() methods respectively in my implementation.
Hi Adam, after hacking around some problems in the code because of missing hashCode() and equals() in FileAdapter class and removing the not supported "@Min(1)" annotation for setRootDirectory() function in GenericManagedConnectionFactory class, I'm stuck.
I can deploy the the file-store and the file client (with changed resource name "java:jboss/eis/Bucket") successfully. But when I try to use a REST resource (getting a connection), I always get the following stack-trace in Wildfly:
Maybe you can have a quick look what's going on here.
cheers, Dino