2012-05-06 15 views
17

मैं यह समझने में सक्षम नहीं हूं कि मुझे यह त्रुटि क्यों मिलती है। मैंने अपमानित और बहुत आगे की लिबियों की सफाई करने की कोशिश की।java.lang.IncompatibleClassChangeError: कक्षा को लागू करना मोंगो

मैं जब मैं करने की कोशिश त्रुटि मिलती है:

mongo = new Mongo(host, port); 

अजीब बात यह है कि मुझे लगता है मैं आईडीई (इंटेलीजे) से किए गए किसी भी इकाई परीक्षण चला सकते हैं है, लेकिन बिलाव मैं के माध्यम से इसे चलाने के लिए जब मैं कोशिश इस मिल:

Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com. 
    sfatandrei.db.MongoManager]: Constructor threw exception; nested exception is java.lang.IncompatibleCla 
    ssChangeError: Implementing class 
     at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162) 
     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInst 
    antiationStrategy.java:110) 
     at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(Constructo 
    rResolver.java:280) 
     ... 82 more 
    Caused by: java.lang.IncompatibleClassChangeError: Implementing class 
     at java.lang.ClassLoader.defineClass1(Native Method) 
     at java.lang.ClassLoader.defineClass(ClassLoader.java:791) 
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 
     at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2889) 
     at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1170) 
     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678) 
     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556) 
     at java.lang.ClassLoader.defineClass1(Native Method) 
     at java.lang.ClassLoader.defineClass(ClassLoader.java:791) 
     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 
     at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2889) 
     at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1170) 
     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678) 
     at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556) 
     at com.mongodb.MongoOptions.reset(MongoOptions.java:47) 
     at com.mongodb.MongoOptions.<init>(MongoOptions.java:29) 
     at com.mongodb.Mongo.<init>(Mongo.java:148) 
     at com.mongodb.Mongo.<init>(Mongo.java:137) 
     at com.sfatandrei.db.MongoManager.<init>(MongoManager.java:28) 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl. 
    java:45) 
     at java.lang.reflect.Constructor.newInstance(Constructor.java:525) 
     at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147) 
     ... 84 more 

mvn dependency:tree -Dverbose

[INFO] 
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ mongodb-performance-test --- 
[INFO] com.sfatandrei:mongodb-performance-test:war:1.0 
[INFO] +- junit:junit:jar:4.8.2:test 
[INFO] +- org.springframework:spring-core:jar:3.1.1.RELEASE:compile 
[INFO] | +- org.springframework:spring-asm:jar:3.1.1.RELEASE:compile 
[INFO] | \- (commons-logging:commons-logging:jar:1.1.1:compile - omitted for duplicate) 
[INFO] +- org.springframework:spring-beans:jar:3.1.1.RELEASE:compile 
[INFO] | \- (org.springframework:spring-core:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] +- org.springframework:spring-context:jar:3.1.1.RELEASE:compile 
[INFO] | +- org.springframework:spring-aop:jar:3.1.1.RELEASE:compile 
[INFO] | | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate) 
[INFO] | | +- (org.springframework:spring-asm:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | | +- (org.springframework:spring-beans:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | | \- (org.springframework:spring-core:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- (org.springframework:spring-beans:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- (org.springframework:spring-core:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- org.springframework:spring-expression:jar:3.1.1.RELEASE:compile 
[INFO] | | \- (org.springframework:spring-core:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | \- (org.springframework:spring-asm:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] +- org.springframework:spring-jdbc:jar:3.1.1.RELEASE:compile 
[INFO] | +- (org.springframework:spring-beans:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- (org.springframework:spring-core:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | \- org.springframework:spring-tx:jar:3.1.1.RELEASE:compile 
[INFO] |  +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate) 
[INFO] |  +- (org.springframework:spring-aop:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] |  +- (org.springframework:spring-beans:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] |  +- (org.springframework:spring-context:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] |  \- (org.springframework:spring-core:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] +- org.springframework:spring-web:jar:3.1.1.RELEASE:compile 
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile 
[INFO] | +- (org.springframework:spring-beans:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- (org.springframework:spring-context:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | \- (org.springframework:spring-core:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] +- org.springframework:spring-webmvc:jar:3.1.1.RELEASE:compile 
[INFO] | +- (org.springframework:spring-asm:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- (org.springframework:spring-beans:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- (org.springframework:spring-context:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- org.springframework:spring-context-support:jar:3.1.1.RELEASE:compile 
[INFO] | | +- (org.springframework:spring-beans:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | | +- (org.springframework:spring-context:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | | \- (org.springframework:spring-core:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- (org.springframework:spring-core:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- (org.springframework:spring-expression:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | \- (org.springframework:spring-web:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] +- org.springframework.data:spring-data-mongodb:jar:1.0.0.RELEASE:compile 
[INFO] | +- (org.springframework:spring-beans:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- (org.springframework:spring-expression:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | +- org.springframework.data:spring-data-commons-core:jar:1.2.0.RELEASE:compile 
[INFO] | | +- (org.springframework:spring-beans:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | | \- (org.springframework:spring-tx:jar:3.1.1.RELEASE:compile - omitted for duplicate) 
[INFO] | \- org.mongodb:mongo-java-driver:jar:2.7.1:compile 
[INFO] +- log4j:log4j:jar:1.2.16:compile 
[INFO] +- org.springframework:spring-test:jar:3.1.1.RELEASE:compile 
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile 
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided 
[INFO] +- org.mongodb:bson:jar:2.3:compile 
[INFO] \- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.6:compile 
[INFO] \- org.codehaus.jackson:jackson-core-asl:jar:1.9.6:compile 

मैं JDK 7 उपयोग कर रहा हूँ, बिल्ला 7.0। 27, मेवेन 3.0.3।

+1

आम तौर पर यह त्रुटि JAR फ़ाइलों के एक सेट के साथ संकलित करने और एक अलग सेट के विरुद्ध चलने के कारण होती है। यह आपके द्वारा उपयोग किए जाने वाले जारों में से एक में कक्षा या कक्षाओं में से एक हो सकता है। दुर्भाग्यवश, ऐसा नहीं लगता है कि किस वर्ग ने त्रुटि ली है। –

+0

@ होट्लिक्स, वास्तव में, यह कहता है कि किस वर्ग ने त्रुटि ली: 'com.mongodb.MongoOptions.reset (MongoOptions.java:47) ' – sfat

+1

नहीं, वहीं त्रुटि हुई। लेकिन वर्ग को लोड होने पर त्रुटि हुई, जो कुछ भी था। यदि आप उस बिंदु पर कोड की जांच कर सकते हैं तो आप समझ सकते हैं कि कौन सी कक्षा लोड की जा रही थी। –

उत्तर

19

यह बाइट कोड स्तर की एक त्रुटि की तरह दिखता है। हो सकता है कि आपके टॉमकैट सर्वर में एक ही लाइब्रेरी के दो संस्करण हों।

देखें: What causes java.lang.IncompatibleClassChangeError?

+2

ऐसा लगता है कि 'मोंगो-जावा-ड्राइवर' एक कक्षा के अंदर है जो org.bson का उपयोग करता है और मैंने खुद को 'बीएसओ' निर्भरता जोड़ा और जो हस्तक्षेप कर रहा था – sfat

1

आप JBoss के तहत इस समस्या को मिलता है, यह सच है कि JBoss बंडल डिफ़ॉल्ट के रूप में RESTeasy बाकी कार्यान्वयन के कारण हुई है। यदि आप अपनी खुद की आरईएसटी लाइब्रेरी को ईएआर/डब्ल्यूएआर फ़ाइल में पैकेज करते हैं, तो आपको काम करने के लिए अपनी तैनात लाइब्रेरी के लिए डिफ़ॉल्ट रीस्टसी को अक्षम करने की आवश्यकता है।

संबंधित मुद्दे