Hmmm, reducing the chain to GAE -> Ispan + HS, mocking the previous test,
it now runs fine even after few repeats.
Looks like JPA -> JPO -> GAE part is broken ...
-Ales
----
public void putStoresEntity() throws Exception {
DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
Entity client = new Entity("Client");
client.setProperty("username", "alesj");
client.setProperty("password", "password");
final Key key = ds.put(client);
try {
Query query = new Query("Client");
query.addFilter("username", Query.FilterOperator.EQUAL,
"alesj");
PreparedQuery pq = ds.prepare(query);
Entity result = pq.asSingleEntity();
Assert.assertNotNull(result);
Assert.assertEquals(key, result.getKey());
Assert.assertEquals("alesj",
result.getProperty("username"));
Assert.assertEquals("password",
result.getProperty("password"));
} finally {
ds.delete(key);
}
}
On May 11, 2012, at 11:09 AM, Ales Justin wrote:
Changing the topic as I have more info, and found that the problem is
elsewhere.
First -- ClassResolver used does use SML, not not plain ML.
Stack trace was somehow misleading.
So, we're fine there, no false config used.
But, this is what I could find now.
This is my test (see below) - JPA over JDO over DataNucleus over GAE over CapeDwarf (long
chain I know :-))
As you can see, I do cleanup afterwards, but ...
I run the same test twice, via ARQ, where I leave the name generation to ARQ:
10:49:08,684 INFO [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015876:
Starting deployment of "e9b7626a-361c-417d-80d5-b9e46af09f48.war"
10:49:10,466 INFO [org.jboss.as.capedwarf.deployment.CapedwarfInitializationProcessor]
(MSC service thread 1-4) Found GAE / CapeDwarf deployment: deployment
"e9b7626a-361c-417d-80d5-b9e46af09f48.war"
2nd run:
10:51:20,686 INFO [org.jboss.as.server] (management-handler-thread - 5) JBAS018559:
Deployed "6de03e61-ceb9-49d7-ad48-0f9edcc150ce.war"
Caused by: org.jboss.modules.ModuleNotFoundException:
deployment.e9b7626a-361c-417d-80d5-b9e46af09f48.war:main
at org.jboss.modules.ModuleLoader.loadModule(ModuleLoader.java:206)
[jboss-modules.jar:1.1.2.GA]
at
org.jboss.marshalling.ModularClassResolver.resolveClass(ModularClassResolver.java:106)
As you can see, it tries to load some data from 1st deployment / test.
But since that's already undeployed, it's not found.
Shouldn't that JPA delete in finally block clean all stale data?
Trying to reproduce this now with smaller dep chain. :-)
---
public void testSaveAndQuery() throws Throwable {
final Client client = new Client();
EMAction<Long> ema1 = new EMAction<Long>() {
public Long go(EntityManager em) throws Throwable {
client.setUsername("alesj");
client.setPassword("password");
client.setEmail("aj(a)jboss.com");
em.persist(client);
return client.getId();
}
};
run(ema1);
try {
final Long id = client.getId();
Assert.assertNotNull("Null client id", id);
EMAction<Client> ema2 = new EMAction<Client>() {
public Client go(EntityManager em) throws Throwable {
Query q = em.createQuery("select from Client c where c.username =
:username");
q.setParameter("username", "alesj");
@SuppressWarnings("unchecked")
List<Client> clients = q.getResultList();
return (clients.isEmpty()) ? null : clients.get(0);
}
};
Client c = run(ema2, false);
Assert.assertNotNull(c);
Assert.assertEquals(id, c.getId());
Assert.assertEquals("alesj", c.getUsername());
Assert.assertEquals("password", c.getPassword());
EMAction<Client> ema3 = new EMAction<Client>() {
public Client go(EntityManager em) throws Throwable {
return em.find(Client.class, id);
}
};
c = run(ema3, false);
Assert.assertNotNull(c);
Assert.assertEquals(id, c.getId());
Assert.assertEquals("alesj", c.getUsername());
Assert.assertEquals("password", c.getPassword());
} finally {
EMAction<Integer> delete = new EMAction<Integer>() {
public Integer go(EntityManager em) throws Throwable {
Query query = em.createQuery("delete from Client c where c.id =
:id");
query.setParameter("id", client.getId());
return query.executeUpdate();
}
};
Assert.assertTrue(1 == run(delete));
}
}
>> The details of the query module are a little out of my realm of
>> experience. I'm CC'ing infinispan-dev, to open up the larger discussion
>> to classloading and compatibility with modular environments.
>>
>> Off the top of my head, it seems like you need a custom
>> KeyTransformationHandler that can resolve classes using a ModuleLoader
>> (i.e. module ID + class name). Thoughts?
>
> That's one way of solving it.
>
> But AdvancedCache::with(CL) already solves this problem - that's why I used it (I
remembered later :-)).
>
> Where I think the two: AC::with(CL) and ServiceModuleLoader impl of ClassResolver,
should no be connected.
> Since they solve diff problems, imo.
>
> Anyway, I'm now gonna try and hunt down where plain ML impl of CR somes in ...
>
> -Ales
>
>> On Thu, 2012-05-10 at 23:10 +0200, Ales Justin wrote:
>>> If I do <subject> I get this CNFE, see below.
>>>
>>> Looks like I still need a combination of Cache::with(CL) -- so this code sees
Key class,
>>> and at the same time I don't want Infinispan to depend on GAE API.
>>> Where I also need to have SML as ClassResolver.
>>>
>>> Are you sure setting CL on Cache breaks ClassResolver?
>>>
>>> -Ales
>>>
>>> ---
>>>
>>> 23:00:50,321 ERROR [org.infinispan.query.backend.KeyTransformationHandler]
(http-/192.168.1.101:8080-2) ISPN014001: Could not locate key class
com.google.appengine.api.datastore.Key: java.lang.ClassNotFoundException:
com.google.appengine.api.datastore.Key
>>> at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
[classes.jar:1.6.0_31]
>>> at java.security.AccessController.doPrivileged(Native Method)
[classes.jar:1.6.0_31]
>>> at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
[classes.jar:1.6.0_31]
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
[classes.jar:1.6.0_31]
>>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
[classes.jar:1.6.0_31]
>>> at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[classes.jar:1.6.0_31]
>>> at java.lang.Class.forName0(Native Method) [classes.jar:1.6.0_31]
>>> at java.lang.Class.forName(Class.java:247) [classes.jar:1.6.0_31]
>>> at org.infinispan.util.Util.loadClassStrict(Util.java:127)
[infinispan-core-5.2.0-SNAPSHOT.jar:5.2.0-SNAPSHOT]
>>> at
org.infinispan.query.backend.KeyTransformationHandler.getCustomTransformer(KeyTransformationHandler.java:108)
>>> at
org.infinispan.query.backend.KeyTransformationHandler.stringToKey(KeyTransformationHandler.java:96)
>>> at
org.infinispan.query.impl.CacheQueryImpl.fromEntityInfosToKeys(CacheQueryImpl.java:174)
>>> at
org.infinispan.query.impl.CacheQueryImpl.iterator(CacheQueryImpl.java:144)
>>> at
org.infinispan.query.impl.CacheQueryImpl.iterator(CacheQueryImpl.java:137)
>>> at
org.jboss.capedwarf.datastore.query.PreparedQueryImpl.createQueryIterator(PreparedQueryImpl.java:108)
[capedwarf-datastore-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
>>> at
org.jboss.capedwarf.datastore.query.PreparedQueryImpl.asQueryResultIterator(PreparedQueryImpl.java:73)
[capedwarf-datastore-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
>>> at
org.jboss.capedwarf.datastore.query.PreparedQueryImpl.asIterator(PreparedQueryImpl.java:64)
[capedwarf-datastore-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
>>> at
org.jboss.capedwarf.datastore.query.PreparedQueryImpl.asIterator(PreparedQueryImpl.java:60)
[capedwarf-datastore-1.0.0-SNAPSHOT.jar:1.0.0-SNAPSHOT]
>>> at
org.jboss.test.capedwarf.datastore.test.PreparedQueryTestCase.testAsIteratorWithOptionstestCountEntities(PreparedQueryTestCase.java:77)
[classes:]
>>>
>>
>>
>