liu4lin / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

Spymemcached 2.8.0 not compatible with Hibernate-Memcached 1.2.2 #240

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
We are currently running spymemcached 2.7.3 with Hibernate-Memcached 1.2.2. 
When I tried to upgrade our JAR to 2.8.0 I am seeing the following error:

java.lang.NoSuchFieldError: NATIVE_HASH
        at com.googlecode.hibernate.memcached.spymemcached.SpyMemcacheClientFactory.getHashAlgorithm(SpyMemcacheClientFactory.java:125)
        at com.googlecode.hibernate.memcached.spymemcached.SpyMemcacheClientFactory.buildDefaultConnectionFactory(SpyMemcacheClientFactory.java:60)
        at com.googlecode.hibernate.memcached.spymemcached.SpyMemcacheClientFactory.getConnectionFactory(SpyMemcacheClientFactory.java:41)
        at com.googlecode.hibernate.memcached.spymemcached.SpyMemcacheClientFactory.createMemcacheClient(SpyMemcacheClientFactory.java:32)
        at com.googlecode.hibernate.memcached.MemcachedCacheProvider.start(MemcachedCacheProvider.java:153)

Original issue reported on code.google.com by lukelap...@gmail.com on 6 Mar 2012 at 7:24

GoogleCodeExporter commented 8 years ago
This actually looks to have something to do with HashAlgorithm now being an 
interface

Original comment by lukelap...@gmail.com on 6 Mar 2012 at 9:52

GoogleCodeExporter commented 8 years ago
I agree. We changed the hash algorithm code in 2.8. It appears to me though 
that this should be patched in your code as opposed to ours. Either way without 
seeing some of your code I can't tell what the best way to fix this is.

Original comment by mikewie...@gmail.com on 6 Mar 2012 at 10:04

GoogleCodeExporter commented 8 years ago
It is not my code it is the Hibernate Memcached project.  

http://code.google.com/p/hibernate-memcached/

This is also broken in the latest version 1.3

Original comment by lukelap...@gmail.com on 6 Mar 2012 at 10:06

GoogleCodeExporter commented 8 years ago
Thanks, I'll try to contribute a patch to that project to get this fixed.

Original comment by mikewie...@gmail.com on 6 Mar 2012 at 10:12

GoogleCodeExporter commented 8 years ago
That would be great. Thanks!

Original comment by lukelap...@gmail.com on 6 Mar 2012 at 10:23

GoogleCodeExporter commented 8 years ago
I have written a patch in the hibernate memcached client for a temporary fix 
but I think the true solution is to make a patch so 2.8.0 is backward 
compatible hibernate-memcached.  Cheers.

Original comment by lukelap...@gmail.com on 6 Mar 2012 at 10:58

GoogleCodeExporter commented 8 years ago
can you post the solution here?

I am facing the same problem. I am using the latest hibernate-memcached 
(downloaded src and built from the git repo) and spymemcached-2.8.0.jar and I 
see similar errors as mentioned below.

Errors I see

nested exception is org.springframework.beans.factory.BeanCreationException: 
Error creating bean with name 'gpSessionFactory' defined in URL 
[file:/usr/local/fs_env/jboss-4.0.5.GA/server/active/deploy/fimapp.ear/services.
jar/META-INF/spring-datasource-web.xml]: Invocation of init method failed; 
nested exception is java.lang.VerifyError: (class: 
com/googlecode/hibernate/memcached/spymemcached/SpyMemcacheClientFactory, 
method: getHashAlgorithm signature: ()Lnet/spy/memcached/HashAlgorithm;) 
Incompatible argument to function
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:254)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:925)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFa

my spring-datasource bean for 'gpSessionFactory' is

<bean id="gpSessionFactory" 
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" 
lazy-init="true">
        <property name="dataSource">
            <ref bean="gpDataSource" />
        </property>
        <property name="mappingResources">
            <list>
                <value>hbm-base.xml</value>
             </list>
        </property>
        <property name="entityInterceptor"><ref bean="auditInterceptor"/></property>
        <property name="hibernateProperties">
            <props>
                <!-- use Oracle10gDialect if using newer Hibernate -->
                <prop key="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</prop>               
                <prop key="hibernate.query.substitutions">true 1, false 0</prop>
                <prop key="hibernate.max_fetch_depth">2</prop>
                <prop key="hibernate.connection.pool_size">5</prop>
                <prop key="hibernate.dbcp.initialSize">5</prop>
                <prop key="hibernate.dbcp.maxWait">10000</prop>
                <prop key="hibernate.show_sql">false</prop>
                <prop key="hibernate.jdbc.batch_size">1000</prop>
                <prop key="hibernate.generate_statistics">true</prop>
                <prop key="hibernate.connection.release_mode">auto</prop>

                <!-- Begin Hibernate Global Caching Configuration -->
                <!-- To turn second level caching (i.e. JVM-wide, versus Session-specific), set the following to false. -->
                <!--<prop key="hibernate.cache.use_second_level_cache">false</prop>
                <prop key="hibernate.cache.provider_class">org.hibernate.cache.NoCacheProvider</prop>-->
                <prop key="hibernate.cache.use_second_level_cache">true</prop>
                <!-- prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop-->
                <prop key="hibernate.cache.use_query_cache">false</prop>
                <prop key="hibernate.cache.use_structured_entries">true</prop>
                <prop key="net.sf.ehcache.configurationResourceName">/ehcache-entity.xml</prop>

                <!-- memcache -->
                    <prop key="hibernate.cache.provider_class">com.googlecode.hibernate.memcached.MemcachedCacheProvider</prop>
                    <!-- explicitly use the SpyMemcache client implementation -->
                    <prop key="hibernate.memcached.memcacheClientFactory">com.googlecode.hibernate.memcached.spymemcached.SpyMemcacheClientFactory</prop>
                    <prop key="hibernate.memcached.connectionFactory">BinaryConnectionFactory</prop>

                    <prop key="hibernate.memcached.servers">localhost:11211</prop>
                    <!-- max allowable cache time in memcache is 30 days.  This is as close as we can get to no expiration -->
                    <prop key="hibernate.memcached.cacheTimeSeconds">2592000</prop>
                    <prop key="hibernate.memcached.keyStrategy">com.googlecode.hibernate.memcached.Sha1KeyStrategy</prop>
                    <!-- now set up the regions -->

                <!-- End Hibernate Global Caching Configuration -->
            </props>
        </property>
    </bean>

Original comment by ashayman...@gmail.com on 13 Mar 2012 at 11:17

GoogleCodeExporter commented 8 years ago
You would need to replace this file in your hibernate memcached jar and 
rebuild.  Let me know how it goes.

Original comment by lukelap...@gmail.com on 15 Mar 2012 at 5:48

Attachments:

GoogleCodeExporter commented 8 years ago
thanks .. will check it soon

Original comment by ashayman...@gmail.com on 16 Mar 2012 at 1:27

GoogleCodeExporter commented 8 years ago
With the new code in there is an issue. The latest hibernate-memcached 
(1.4.0-SNAPSHOT) depends on spymemcached 2.7.1 and compiles fine but a as soon 
as we replace the SpymemcacheClientLibrary with the one attached above and 
replace the dependency in pom.xml to spymemcached 2.8.0, I see the following 
errors

/Users/amanjure/Downloads/raykrueger-hibernate-memcached-ce50ca3: mvn install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building hibernate-memcached 1.4-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.danga:java_memcached:jar:2.0.1 is missing, no 
dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.241s
[INFO] Finished at: Thu Mar 15 18:42:14 PDT 2012
[INFO] Final Memory: 5M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project hibernate-memcached: Could not 
resolve dependencies for project 
com.googlecode:hibernate-memcached:jar:1.4-SNAPSHOT: The following artifacts 
could not be resolved: javax.jms:jms:jar:1.1, com.sun.jdmk:jmxtools:jar:1.2.1, 
com.sun.jmx:jmxri:jar:1.2.1: Could not transfer artifact javax.jms:jms:jar:1.1 
from/to java.net (https://maven-repository.dev.java.net/nonav/repository): No 
connector available to access repository java.net 
(https://maven-repository.dev.java.net/nonav/repository) of type legacy using 
the available factories WagonRepositoryConnectorFactory -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e 
switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please 
read the following articles:
[ERROR] [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[amanjure@FNG112137.local]/Users/amanjure/Downloads/raykrueger-hibernate-memcach
ed-ce50ca3: mvn install

its kinda weird on why it would give errors for javax.jms related stuff. If 
anyone knows this. This would be helpful. I am going to post a question on 
hibernate-memcached project too. 

Thanks for the help!!

Original comment by ashayman...@gmail.com on 16 Mar 2012 at 1:43

GoogleCodeExporter commented 8 years ago
The dependency problem is due to how log4j describes dependencies.  You can 
specifically exclude the javax.jms and other transitive dependencies from log4j 
you're not actually using and then it'll be fine.

Original comment by ingen...@gmail.com on 16 Mar 2012 at 5:04

GoogleCodeExporter commented 8 years ago
Note, the transitive dependency fix is in 2.8.1

Original comment by ingen...@gmail.com on 22 Mar 2012 at 4:38