Moving to Pojo 3 from pojo 2 and attach fails
adrigan Dec 23, 2008 3:49 PMHi,
I am preparing my existing application that uses multiple pojo caches to be able to be accessed from the latest JBoss App Server 5. In doing this, I realized I had to "upgrade" to the latest release of Pojo cache. In other words, I did not want to mix versions of the pojo cache but instead use the same version as JBoss App server 5.
For step 1, I simply want to get the old application running with Naga.
I change my command files to point to the places within the JBoss App Server (same libraries) as follows:
set JBOSS_POJO=%BUILD_AREA%\lib\jboss\jboss-5.0.0.GA\server\AMOD\lib set JBOSS_POJO_JARS=%JBOSS_POJO%\jbosscache-pojo.jar; set JBOSS_POJO_JARS=%JBOSS_POJO_JARS%;%JBOSS_POJO%\jbosscache-core.jar; set JBOSS_POJO_JARS=%JBOSS_POJO_JARS%;%JBOSS_POJO%\jgroups.jar; set JBOSS_POJO_JARS=%JBOSS_POJO_JARS%;%JBOSS_JARS%; set JBOSS_CACHE_PARAMS=-javaagent:%JBOSS_CLIENT%\jboss-aop-client.jar -Djboss.aop.path=%JBOSS_POJO%\META-INF\pojocache-aop.xml
As you can imagine, these variables are placed on the classpath and command line of my bat file. I extracted the pojocache-aop.xml from the jar file in my server called AMOD. It did not match the one in the documentation - but it worked (while the one in the 3.0 documentation did not.) Here it is:
<?xml version="1.0" encoding="UTF-8"?> <!-- This is a variant of jboss-aop.xml. --> <aop> <!-- If a POJO has a Replicable annotation, it will be asepectized. --> <!-- Supports inheritance and polymorphism. It can either be a concrete class or an interface. All sub-classes or interface implementors will be instrumeneted. --> <prepare expr="field(* $instanceof{@org.jboss.cache.pojo.annotation.Replicable}->*)" /> <!-- Work around that ensures annotated classes which do not access fields are instrumented --> <introduction expr="class($instanceof{@org.jboss.cache.pojo.annotation.Replicable})"/> <!-- Array support --> <!-- Comment entire section to disable --> <arrayreplacement expr="class($instanceof{@org.jboss.cache.pojo.annotation.Replicable})"/> <interceptor name="pojocache-array" class="org.jboss.cache.pojo.interceptors.dynamic.ArrayInterceptor"/> <introduction expr="class($instanceof{@org.jboss.cache.pojo.annotation.Replicable})"> <interfaces>org.jboss.cache.pojo.impl.ArrayInterceptable</interfaces> </introduction> <arraybind name="pojocache-array" type="READ_WRITE"> <interceptor-ref name="pojocache-array"/> </arraybind> </aop>
My code from the application that worked on version 2 of pojo has not changed. The classes are annotated as follows.
@org.jboss.cache.pojo.annotation.Replicable public class EquipmentItemNode extends ANode
I use the following configuration file to create the cache. I pulled it from the "all.xml" from the jbosscache-core.jar (3.0) version.
<?xml version="1.0" encoding="UTF-8"?> <jbosscache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:jboss:jbosscache-core:config:3.0"> <!-- isolation levels supported: READ_COMMITTED and REPEATABLE_READ nodeLockingSchemes: mvcc, pessimistic (deprecated), optimistic (deprecated) --> <locking isolationLevel="REPEATABLE_READ" lockParentForChildInsertRemove="false" lockAcquisitionTimeout="20000" nodeLockingScheme="mvcc" writeSkewCheck="false" concurrencyLevel="500"/> <!-- Used to register a transaction manager and participate in ongoing transactions. --> <transaction transactionManagerLookupClass="org.jboss.cache.transaction.GenericTransactionManagerLookup" syncRollbackPhase="false" syncCommitPhase="false"/> <!-- Used to register JMX statistics in any available MBean server --> <jmxStatistics enabled="false"/> <!-- If region based marshalling is used, defines whether new regions are inactive on startup. --> <startup regionsInactiveOnStartup="true"/> <!-- Used to register JVM shutdown hooks. hookBehavior: DEFAULT, REGISTER, DONT_REGISTER --> <shutdown hookBehavior="DEFAULT"/> <!-- Used to define async listener notification thread pool size --> <listeners asyncPoolSize="1" asyncQueueSize="1000000"/> <!-- Used to enable invocation batching and allow the use of Cache.startBatch()/endBatch() methods. --> <invocationBatching enabled="false"/> <!-- serialization related configuration, used for replication and cache loading --> <serialization objectInputStreamPoolSize="12" objectOutputStreamPoolSize="14" version="3.0.0" marshallerClass="org.jboss.cache.marshall.VersionAwareMarshaller" useLazyDeserialization="false" useRegionBasedMarshalling="false"/> <!-- This element specifies that the cache is clustered. modes supported: replication (r) or invalidation (i). --> <clustering mode="replication" clusterName="JBossCache-cluster"> <!-- Defines whether to retrieve state on startup --> <stateRetrieval timeout="20000" fetchInMemoryState="false"/> <!-- Network calls are synchronous. --> <sync replTimeout="20000"/> <!-- Uncomment this for async replication. --> <!--<async useReplQueue="true" replQueueInterval="10000" replQueueMaxElements="500" serializationExecutorPoolSize="20" serializationExecutorQueueSize="5000000"/>--> <!-- Uncomment to use Buddy Replication --> <!-- <buddy enabled="true" poolName="myBuddyPoolReplicationGroup" communicationTimeout="2000"> <dataGravitation auto="true" removeOnFind="true" searchBackupTrees="true"/> <locator class="org.jboss.cache.buddyreplication.NextMemberBuddyLocator"> <properties> numBuddies = 1 ignoreColocatedBuddies = true </properties> </locator> </buddy> --> <!-- Configures the JGroups channel. Looks up a JGroups config file on the classpath or filesystem. udp.xml ships with jgroups.jar and will be picked up by the class loader. --> <jgroupsConfig> <UDP discard_incompatible_packets="true" enable_bundling="false" enable_diagnostics="false" ip_ttl="2" loopback="false" max_bundle_size="64000" max_bundle_timeout="30" mcast_addr="228.10.10.10" mcast_port="45588" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000" oob_thread_pool.enabled="true" oob_thread_pool.keep_alive_time="10000" oob_thread_pool.max_threads="4" oob_thread_pool.min_threads="1" oob_thread_pool.queue_enabled="true" oob_thread_pool.queue_max_size="10" oob_thread_pool.rejection_policy="Run" thread_naming_pattern="pl" thread_pool.enabled="true" thread_pool.keep_alive_time="30000" thread_pool.max_threads="25" thread_pool.min_threads="1" thread_pool.queue_enabled="true" thread_pool.queue_max_size="10" thread_pool.rejection_policy="Run" tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" use_concurrent_stack="true" use_incoming_packet_handler="true"/> <PING num_initial_members="3" timeout="2000"/> <MERGE2 max_interval="30000" min_interval="10000"/> <FD_SOCK/> <FD max_tries="5" shun="true" timeout="10000"/> <VERIFY_SUSPECT timeout="1500"/> <pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800" use_mcast_xmit="false"/> <UNICAST timeout="300,600,1200,2400,3600"/> <pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/> <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false" view_ack_collection_timeout="5000" view_bundling="true"/> <FRAG2 frag_size="60000"/> <pbcast.STREAMING_STATE_TRANSFER/> <pbcast.FLUSH timeout="0"/> </jgroupsConfig> </clustering> <!-- Eviction configuration. WakeupInterval defines how often the eviction thread runs, in milliseconds. 0 means the eviction thread will never run. --> <eviction wakeUpInterval="0"> <!-- was 500 --> <default algorithmClass="org.jboss.cache.eviction.LRUAlgorithm" eventQueueSize="200000"> <property name="maxNodes" value="5000"/> <property name="timeToLive" value="1000"/> </default> <region name="/org/jboss/data1"> <property name="timeToLive" value="2000"/> </region> <region name="/org/jboss/data2" algorithmClass="org.jboss.cache.eviction.FIFOAlgorithm" eventQueueSize="100000"> <property name="maxNodes" value="3000"/> <property name="minTimeToLive" value="4000"/> </region> </eviction> <!-- Cache loaders. If passivation is enabled, state is offloaded to the cache loaders ONLY when evicted. Similarly, when the state is accessed again, it is removed from the cache loader and loaded into memory. Otherwise, state is always maintained in the cache loader as well as in memory. Set 'shared' to true if all instances in the cluster use the same cache loader instance, e.g., are talking to the same database. LKA - comment out until we get our database set up - Derby comes with JBoss 5 - may use it <loaders passivation="false" shared="false"> <preload> <node fqn="/org/jboss"/> <node fqn="/org/tempdata"/> </preload> --> <!-- we can have multiple cache loaders, which get chained <loader class="org.jboss.cache.loader.JDBCCacheLoader" async="true" fetchPersistentState="true" ignoreModifications="true" purgeOnStartup="true"> <properties> cache.jdbc.table.name=jbosscache cache.jdbc.table.create=true cache.jdbc.table.drop=true cache.jdbc.table.primarykey=jbosscache_pk cache.jdbc.fqn.column=fqn cache.jdbc.fqn.type=varchar(255) cache.jdbc.node.column=node cache.jdbc.node.type=blob cache.jdbc.parent.column=parent cache.jdbc.sql-concat=1 || 2 cache.jdbc.driver = org.apache.derby.jdbc.EmbeddedDriver cache.jdbc.url=jdbc:derby:jbossdb;create=true cache.jdbc.user=user1 cache.jdbc.password=user1 </properties> --> <!-- alternatively use a connection from a datasorce, as per the code sample below--> <!--<properties>--> <!--cache.jdbc.datasource=AllSampleDS--> <!--cache.jdbc.table.name=jbosscache--> <!--cache.jdbc.table.create=true--> <!--cache.jdbc.table.drop=true--> <!--</properties> <singletonStore enabled="true" class="org.jboss.cache.loader.SingletonStoreCacheLoader"> <properties> pushStateWhenCoordinator=true pushStateWhenCoordinatorTimeout=20000 </properties> </singletonStore> </loader> </loaders> --> <!-- Define custom interceptors. All custom interceptors need to extend org.jboss.cache.interceptors.base.CommandInterceptor --> <!-- <customInterceptors> <interceptor position="first" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"> <property name="attrOne" value="value1" /> <property name="attrTwo" value="value2" /> </interceptor> <interceptor position="last" class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor index="3" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> <interceptor before="org.jboss.cache.interceptors.CallInterceptor" class="org.jboss.cache.config.parsing.custominterceptors.BbbCustomInterceptor"/> <interceptor after="org.jboss.cache.interceptors.CallInterceptor" class="org.jboss.cache.config.parsing.custominterceptors.AaaCustomInterceptor"/> </customInterceptors> --> </jbosscache>
When I attach an object to the cache, I do not receive an exception at all. But - it is not attached as a subsequent find does not retrieve it. I put the following debug line around the attach to see if a fqn id is assigned to the object.
Ojbect pojo = myCache.attach(name, object); trace.log(Level.INFO, "did attach object " + object.getClass().toString() + " " + object.toString() + " to name " + name + " in cache name " + this.nameOfCache + " with fqn of " + this.myCache.getInternalFqn(object)); Dec 23, 2008 3:39:06 PM com.lm.cache.CacheManager attachObjectToCache INFO: did attach object class com.lm.dataModel.EquipmentItemNode / to name / in cache name EquipmentCache with fqn of null
The result I get back confuses the day lights out of me. No exception is thrown - the object is annotated and instrumented, but it is not actually attached. This did work on the prior version.
I figure I must have the configuration messed up. I would appreciate any and all help. Thank you.