Hello, I would like to use TreeCache inside JBossAS and access it from Tomcat running outside JBossAS. - JBoss 4.0.5 GA - Tomcat 5.5.20 - WinXP - j2sdk1.5.0_07
I have a cache-service.xml config in the deploy directory of JBoss, here is the config: | <?xml version="1.0" encoding="UTF-8"?> | | <!-- ===================================================================== --> | <!-- --> | <!-- Sample TreeCache Service Configuration --> | <!-- --> | <!-- ===================================================================== --> | | <server> | | <classpath codebase="./lib" archives="jboss-cache.jar, jgroups.jar"/> | | | <!-- ==================================================================== --> | <!-- Defines TreeCache configuration --> | <!-- ==================================================================== --> | | <mbean code="org.jboss.cache.TreeCache" name="jboss.cache:service=TreeCache"> | <depends>jboss:service=Naming</depends> | <depends>jboss:service=TransactionManager</depends> | | <!-- Configure the TransactionManager --> | <attribute name="TransactionManagerLookupClass">org.jboss.cache.JBossTransactionManagerLookup</attribute> | | <!-- | Node locking level : SERIALIZABLE | REPEATABLE_READ (default) | READ_COMMITTED | READ_UNCOMMITTED | NONE | --> | <attribute name="IsolationLevel">REPEATABLE_READ</attribute> | | <!-- | Valid modes are LOCAL | REPL_ASYNC | REPL_SYNC | INVALIDATION_ASYNC | INVALIDATION_SYNC | --> | <attribute name="CacheMode">LOCAL</attribute> | | <!--<attribute name="UseInterceptorMbeans">true</attribute>--> | | <!-- Name of cluster. Needs to be the same for all clusters, in order | to find each other | --> | <attribute name="ClusterName">TreeCache-Cluster</attribute> | | <!-- JGroups protocol stack properties. Can also be a URL, | e.g. file:/home/bela/default.xml | <attribute name="ClusterProperties"></attribute> | --> | | <attribute name="ClusterConfig"> | <config> | <!-- UDP: if you have a multihomed machine, | set the bind_addr attribute to the appropriate NIC IP address --> | <!-- UDP: On Windows machines, because of the media sense feature | being broken with multicast (even after disabling media sense) | set the loopback attribute to true --> | <UDP mcast_addr="228.1.2.3" mcast_port="48866" | ip_ttl="64" ip_mcast="true" | mcast_send_buf_size="150000" mcast_recv_buf_size="80000" | ucast_send_buf_size="150000" ucast_recv_buf_size="80000" | loopback="false"/> | <PING timeout="2000" num_initial_members="3" | up_thread="false" down_thread="false"/> | <MERGE2 min_interval="10000" max_interval="20000"/> | <FD shun="true" up_thread="true" down_thread="true"/> | <VERIFY_SUSPECT timeout="1500" | up_thread="false" down_thread="false"/> | <pbcast.NAKACK gc_lag="50" retransmit_timeout="600,1200,2400,4800" | max_xmit_size="8192" up_thread="false" down_thread="false"/> | <UNICAST timeout="600,1200,2400" window_size="100" min_threshold="10" | down_thread="false"/> | <pbcast.STABLE desired_avg_gossip="20000" | up_thread="false" down_thread="false"/> | <FRAG frag_size="8192" | down_thread="false" up_thread="false"/> | <pbcast.GMS join_timeout="5000" join_retry_timeout="2000" | shun="true" print_local_addr="true"/> | <pbcast.STATE_TRANSFER up_thread="false" down_thread="false"/> | </config> | </attribute> | | | <!-- | The max amount of time (in milliseconds) we wait until the | initial state (ie. the contents of the cache) are retrieved from | existing members in a clustered environment | --> | <attribute name="InitialStateRetrievalTimeout">20000</attribute> | | <!-- | Number of milliseconds to wait until all responses for a | synchronous call have been received. | --> | <attribute name="SyncReplTimeout">20000</attribute> | | <!-- Max number of milliseconds to wait for a lock acquisition --> | <attribute name="LockAcquisitionTimeout">15000</attribute> | | | <attribute name="EvictionPolicyClass">org.jboss.cache.eviction.LRUPolicy</attribute> | <!-- Specific eviction policy configurations. This is LRU --> | <attribute name="EvictionPolicyConfig"> | <config> | <attribute name="wakeUpIntervalSeconds">300</attribute> | <!-- Cache wide default --> | | <region name="/command_image/"> | <attribute name="maxNodes">100</attribute> | <attribute name="timeToLiveSeconds">8</attribute> | <attribute name="maxAgeSeconds">10</attribute> | </region> | | <region name="/command_photo/"> | <attribute name="maxNodes">100</attribute> | <attribute name="timeToLiveSeconds">8</attribute> | <attribute name="maxAgeSeconds">10</attribute> | </region> | | <region name="/command_mixte/"> | <attribute name="maxNodes">100</attribute> | <attribute name="timeToLiveSeconds">8</attribute> | <attribute name="maxAgeSeconds">10</attribute> | </region> | </config> | </attribute> | | | <!-- | Indicate whether to use region based marshalling or not. Set this to true if you are running under a scoped | class loader, e.g., inside an application server. Default is "false". | --> | <attribute name="UseRegionBasedMarshalling">true</attribute> | <attribute name="CacheLoaderConfiguration"> | <config> | <passivation>true</passivation> | <preload></preload> | <cacheloader> | <class>org.jboss.cache.loader.JDBCExtendedCacheLoader</class> | <!-- same as the old CacheLoaderConfig attribute --> | <properties> | cache.jdbc.table.name=jbosscache | cache.jdbc.table.create=true | cache.jdbc.table.drop=false | 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=VARBINARY(MAX) | cache.jdbc.parent.column=parent | cache.jdbc.driver=net.sourceforge.jtds.jdbc.Driver | cache.jdbc.url=jdbc:jtds:sqlserver://192.168.1.74:1433/MappingCache | cache.jdbc.user | cache.jdbc.password | </properties> | <!-- whether the cache loader writes are asynchronous --> | <async>false</async> | <!-- only one cache loader in the chain may set fetchPersistentState to true. | An exception is thrown if more than one cache loader sets this to true. --> | <fetchPersistentState>true</fetchPersistentState> | <!-- determines whether this cache loader ignores writes - defaults to false. --> | <ignoreModifications>false</ignoreModifications> | <!-- if set to true, purges the contents of this cache loader when the cache starts up. | Defaults to false. --> | <purgeOnStartup>false</purgeOnStartup> | </cacheloader> | </config> | </attribute> | </mbean> | | <mbean code="org.jboss.invocation.jrmp.server.JRMPProxyFactory" | name="mydomain:service=proxyFactory,type=jrmp,target=factory"> | <attribute name="InvokerName">jboss:service=invoker,type=jrmp</attribute> | <attribute name="TargetName">jboss.cache:service=TreeCache</attribute> | <attribute name="JndiName">MyCache</attribute> | <attribute name="InvokeTargetMethod">true</attribute> | <attribute name="ExportedInterface">org.jboss.cache.TreeCacheMBean</attribute> | <attribute name="ClientInterceptors"> | <interceptors> | <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor> | <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor> | <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor> | </interceptors> | </attribute> | <depends>jboss:service=invoker,type=jrmp</depends> | <depends>jboss.cache:service=TreeCache</depends> | </mbean> | </server> | In Tomcat, i can bind to the TreeCache with jndi in my ServletContextListener. But when Tomcat execute this line | treecache.registerClassLoader("/command_image/", Thread.currentThread().getContextClassLoader()); | an exception is thrown: ERROR 2007-04-04 17:49:54,078 com.marketip.cache.util.TreeCacheSingleton - | java.lang.reflect.UndeclaredThrowableException | at $Proxy0.registerClassLoader(Unknown Source) | at com.marketip.cache.util.TreeCacheSingleton.init(TreeCacheSingleton.java:45) | at com.marketip.cache.listener.CacheControlListener.contextInitialized(CacheControlListener.java:39) | at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729) | at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187) | at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759) | at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739) | at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524) | at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:904) | at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:867) | at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474) | at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122) | at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310) | at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119) | at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021) | at org.apache.catalina.core.StandardHost.start(StandardHost.java:718) | at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013) | at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442) | at org.apache.catalina.core.StandardService.start(StandardService.java:450) | at org.apache.catalina.core.StandardServer.start(StandardServer.java:709) | at org.apache.catalina.startup.Catalina.start(Catalina.java:551) | at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) | at java.lang.reflect.Method.invoke(Method.java:585) | at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:294) | at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432) | Caused by: java.rmi.MarshalException: error marshalling arguments; nested exception is: | java.io.NotSerializableException: org.apache.catalina.loader.WebappClassLoader | at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122) | at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source) | at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:133) | at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365) | at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197) | at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70) | at org.jboss.proxy.ClientMethodInterceptor.invoke(ClientMethodInterceptor.java:74) | at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100) | ... 27 more | Caused by: java.io.NotSerializableException: org.apache.catalina.loader.WebappClassLoader | at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081) | at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251) | at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075) | at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302) | at org.jboss.invocation.MarshalledValue.<init>(MarshalledValue.java:70) | at org.jboss.invocation.MarshalledInvocation.createMarshalledValue(MarshalledInvocation.java:632) | at org.jboss.invocation.MarshalledInvocation.writeExternal(MarshalledInvocation.java:570) | at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1307) | at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1288) | at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079) | at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302) | at sun.rmi.server.UnicastRef.marshalValue(UnicastRef.java:258) | at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:117) | ... 34 more | Here is the complete code executed in order to bind to TreeCache: | Properties props = new Properties(); | props.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); | props.setProperty("java.naming.provider.url", "jnp://localhost:1099"); | props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); | InitialContext ctx=new InitialContext(props); | treecache = (TreeCacheMBean)ctx.lookup("MyCache"); | treecache.registerClassLoader("/command_image/", Thread.currentThread().getContextClassLoader()); | isInited = true; | Could someone help me? What is wrong in my config or in my code? Thank you in advance. PHS View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4034662#4034662 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4034662 _______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user