[JBossCache] - PojoCache Map collection adds key to Map object when removin
by tfila
Hello,
It appears that in JBossCache-1.4.1.SP3 (and earlier versions) that doing a Map.remove() on a Map object in the PojoCache for a key that does not exist will result in the key being created in the Map without an associated value. After the remove() doing a containsKey() for that key will return 'true'. From that point on the only way to remove the key from the Map is to first assign it a value and then doing another remove.
For example:
The cache with an empty Map added:
/myProperties
_lock_: LOCK
__jboss:internal:class__: class java.util.HashMap
AOPInstance: org.jboss.cache.aop.AOPInstance@1ce3fc5
The cache after doing a remove on the key 'MY_KEY'
/myProperties
_lock_: LOCK
__jboss:internal:class__: class java.util.HashMap
AOPInstance: org.jboss.cache.aop.AOPInstance@1ce3fc5
/MY_KEY
_lock_: LOCK
The following unit test demonstrates this problem. In this test a HashMap is added to the cache and a key/value pair is added. A remove is performed on the key and then verified that the key no longer exists in the Map. A second removal on the same key is then done with the same verification which fails.
package org.jboss.cache.aop.collection;
|
| import java.util.HashMap;
| import java.util.Map;
|
| import junit.framework.Test;
| import junit.framework.TestCase;
| import junit.framework.TestSuite;
|
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
| import org.jboss.cache.PropertyConfigurator;
| import org.jboss.cache.aop.PojoCache;
|
|
| public class MultiRemovalCacheMapAopTest extends TestCase
| {
| Log log=LogFactory.getLog(MultiRemovalCacheMapAopTest.class);
| PojoCache cache_;
| Map hobbies;
|
| public MultiRemovalCacheMapAopTest(String name)
| {
| super(name);
| }
|
| protected void setUp() throws Exception
| {
| super.setUp();
| log.info("setUp() ....");
| String configFile = "META-INF/local-service.xml";
| cache_ = new PojoCache();
| PropertyConfigurator config = new PropertyConfigurator();
| config.configure(cache_, configFile);
| cache_.start();
| }
|
| protected void tearDown() throws Exception
| {
| super.tearDown();
| cache_.stop();
| }
|
| public void testMultipleRemoves() throws Exception
| {
| final String key = "MY_KEY";
|
| HashMap properties = new HashMap();
| cache_.putObject( "/myProperties", properties );
|
| properties = (HashMap)cache_.getObject( "/myProperties" );
|
| properties.put( key, "value1");
| log.info( cache_.printDetails() );
|
| assertTrue( properties.containsKey( key ) );
| assertNotNull( properties.get(key));
|
| log.info( "removing Map key [" + key + "]" );
| properties.remove( key );
| log.info( cache_.printDetails() );
|
| assertTrue( !properties.containsKey( key ) );
|
| log.info( "Second removal of Map key [" + key + "]" );
| properties.remove( key );
| log.info( cache_.printDetails() );
| assertTrue( !properties.containsKey( key ) );
| }
|
| public static Test suite() throws Exception
| {
| return new TestSuite(MultiRemovalCacheMapAopTest.class);
| }
|
| public static void main(String[] args) throws Exception
| {
| junit.textui.TestRunner.run(suite());
| }
| }
|
Any work-arounds other than checking first if the key exists prior to the remove would be appreciated.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047974#4047974
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047974
18 years, 11 months
[JBoss Seam] - lookup of remote EntityQuery (from seam-gen) for Eclipse RCP
by cupdike
I'm trying to remote access an EntityQuery subclass that I've converted to a SFSB. It was generated by seam-gen as a non-EJB subclass. I'm trying to use the EJB in a remote client app (Eclipse RCP). Currently, the lookup works but the bean won't cast properly due to some kind of serialVersionUID problem. I've tried many different workarounds related to assigning the serialVersionUID of the bean to either values in the error message, but it still fails (class snippets and stack trace given below). I'm wondering if this has something to do with Seam creating proxies for the bean.
And am I taking the wrong approach here? Is there an easier way to do this? I hear rumors that RCP integration is in the plan, but I can't wait for that to happen (although it would be awesome to be able to reference Seam components in RCP instead of doing remote EJB lookup). Perhaps with some guidance, I could write some Seam code that surface the remote components in RCP (but I don't know where to start--any pointers welcome).
TIA, Clark
| @Name("demoStatesList")
| @Stateful
| public class DemoStatesList extends EntityQuery implements DemoStatesListIntface, Serializable {
|
|
| private static final long serialVersionUID = -2164496320326661428L;
| ...
| <snip>
| --------------------------
| @Remote
| public interface DemoStatesListIntface {
|
| public abstract DemoStates getDemoStates();
|
| }
| --------------------------
| ######## doing lookup of: SeamGenTest2/DemoStatesList/remote
| 20:33:31,564 ERROR [SocketClientInvoker] Got marshalling exception, exiting
| java.io.InvalidClassException: org.jboss.ejb3.stateful.StatefulRemoteProxy; local class incompatible: stream classdesc serialVersionUID = -2164496320326661428, local class serialVersionUID = -8874087830926007682
| at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:519)
| at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
| at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
| at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
| at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
| at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
| at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
| at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
| at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:107)
| at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
| at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
| at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
| at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
| at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
| at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
| at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
| at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
| at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:279)
| at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
| at org.jboss.remoting.Client.invoke(Client.java:525)
| at org.jboss.remoting.Client.invoke(Client.java:488)
| at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:61)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:48)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:61)
| at $Proxy0.createProxy(Unknown Source)
| at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
| at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
| at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1131)
| at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1148)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:706)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at edu.jhuapl.ermp.ServiceFactory.buildALocalFacade(ServiceFactory.java:129)
| at edu.jhuapl.ermp.ServiceFactory.getDemoStatesList(ServiceFactory.java:115)
| at edu.jhuapl.ermp.ServiceFactory.main(ServiceFactory.java:153)
| javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
| at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1156)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:706)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at edu.jhuapl.ermp.ServiceFactory.buildALocalFacade(ServiceFactory.java:129)
| at edu.jhuapl.ermp.ServiceFactory.getDemoStatesList(ServiceFactory.java:115)
| at edu.jhuapl.ermp.ServiceFactory.main(ServiceFactory.java:153)DemoStatesList not found
|
| Caused by: java.lang.reflect.UndeclaredThrowableException
| at $Proxy0.createProxy(Unknown Source)
| at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
| at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
| at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1131)
| at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1148)
| ... 6 more
| Caused by: java.rmi.MarshalException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
| java.io.InvalidClassException: org.jboss.ejb3.stateful.StatefulRemoteProxy; local class incompatible: stream classdesc serialVersionUID = -2164496320326661428, local class serialVersionUID = -8874087830926007682
| at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:306)
| at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
| at org.jboss.remoting.Client.invoke(Client.java:525)
| at org.jboss.remoting.Client.invoke(Client.java:488)
| at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:61)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:48)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:61)
| ... 11 more
| Caused by: java.io.InvalidClassException: org.jboss.ejb3.stateful.StatefulRemoteProxy; local class incompatible: stream classdesc serialVersionUID = -2164496320326661428, local class serialVersionUID = -8874087830926007682
| at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:519)
| at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1546)
| at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1460)
| at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1693)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
| at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
| at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
| at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
| at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
| at org.jboss.aop.joinpoint.InvocationResponse.readExternal(InvocationResponse.java:107)
| at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1753)
| at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1711)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
| at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1912)
| at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
| at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
| at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
| at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
| at org.jboss.remoting.serialization.impl.java.JavaSerializationManager.receiveObject(JavaSerializationManager.java:128)
| at org.jboss.remoting.marshal.serializable.SerializableUnMarshaller.read(SerializableUnMarshaller.java:66)
| at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:279)
| at org.jboss.remoting.RemoteClientInvoker.invoke(RemoteClientInvoker.java:143)
| at org.jboss.remoting.Client.invoke(Client.java:525)
| at org.jboss.remoting.Client.invoke(Client.java:488)
| at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:61)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at org.jboss.aspects.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:48)
| at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:98)
| at org.jboss.aspects.remoting.PojiProxy.invoke(PojiProxy.java:61)
| at $Proxy0.createProxy(Unknown Source)
| at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
| at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
| at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1131)
| at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1148)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:706)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:588)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at edu.jhuapl.ermp.ServiceFactory.buildALocalFacade(ServiceFactory.java:129)
| at edu.jhuapl.ermp.ServiceFactory.getDemoStatesList(ServiceFactory.java:115)
| at edu.jhuapl.ermp.ServiceFactory.main(ServiceFactory.java:153)
| at org.jboss.aspects.remoting.InvokeRemoteInterceptor.invoke(InvokeRemoteInterceptor.java:73)
| ... 15 more
| Exception in thread "main" java.lang.NullPointerException
| at edu.jhuapl.ermp.ServiceFactory.main(ServiceFactory.java:154)
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047971#4047971
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047971
18 years, 11 months
[JBoss Messaging] - Re: automatically truncate message table on server startup
by paul_da_programmer
So would non-persistent messages still preserve the transactional integrity of the JMS transaction?
onMsg(...) {
| //performSomeDBOperation( ) // or any XA transactional operation
| ...biz throws an uncaught exception which is propagated to the JMS container
| }
|
Can I assume the DB updates would be automatically rolled back - regardless of whether the message was persisted is a XA resource like a DB? So is JMS itself is an XA transactional resource irrespective of how persistence is handled? If so, that's something I guess I've missed all of these years using JMS.
I assumed that JMS being a 'potential' XA resource was only because of it's persistence implementation - I assumed if no persistence is used (or a non-transactional persistence impl like a filesystem) then consistent JMS<->DB transactions couldn't be guaranteed.
For so value added here's a good description:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JMS6.html#wp81843
...from Sun's tutorial...
anonymous wrote : # You can use the setDeliveryMode method of the MessageProducer interface to set the delivery mode for all messages sent by that producer. For example, the following call sets the delivery mode to NON_PERSISTENT for a producer:
|
| producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
|
| # You can use the long form of the send or the publish method to set the delivery mode for a specific message. The second argument sets the delivery mode. For example, the following send call sets the delivery mode for message to NON_PERSISTENT:
|
| producer.send(message, DeliveryMode.NON_PERSISTENT, 3, 10000);
|
| The third and fourth arguments set the priority level and expiration time, which are described in the next two subsections.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4047968#4047968
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4047968
18 years, 11 months