[JAVA-1153] GSSAPI auth when running within OSGI causes NoClassDefFoundError (SaslException) Created: 24/Mar/14  Updated: 03/Apr/16  Resolved: 27/Mar/14

Status: Closed
Project: Java Driver
Component/s: Build
Affects Version/s: 2.11.1
Fix Version/s: 2.12.0, 3.0.0

Type: Bug Priority: Major - P3
Reporter: Matt Campbell Assignee: Jeffrey Yemin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

I hit the error below when attempting to use Kerberos authentication with the Java driver running as an OSGI module.

Caused by: java.lang.NoClassDefFoundError: javax/security/sasl/SaslException
	at com.mongodb.DBPort.authenticate(DBPort.java:318)
	at com.mongodb.DBPort.checkAuth(DBPort.java:333)
	at com.mongodb.DBTCPConnector.innerCall(DBTCPConnector.java:243)
	at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:216)
	at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:288)
	at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:273)
	at com.mongodb.DB.getCollectionNames(DB.java:399)
	at org.pentaho.mongo.wrapper.NoAuthMongoClientWrapper.getCollectionsNames(NoAuthMongoClientWrapper.java:196)
	... 118 more
Caused by: java.lang.ClassNotFoundException: javax.security.sasl.SaslException not found by org.mongodb.mongo-java-driver [21]
	at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
	at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
	at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 126 more

-----------------
I later added the following items to the Import-Package in the MANIFEST for mongo-java-driver-2.11.1.jar and was able to connect without issue.

javax.security.sasl,javax.security.auth.login,javax.security.auth,org.ietf.jgss



 Comments   
Comment by Matt Campbell [ 27/Mar/14 ]

Yes, that does look reasonable. Thanks Jeff.

Comment by Githook User [ 26/Mar/14 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1153: Added packages to Import-Package so that GSSAPI will work properly when the driver is running as an OSGI module.
Branch: 3.0.x
https://github.com/mongodb/mongo-java-driver/commit/1559ded8dcda8b3e27332ba9c339520c4b3e9247

Comment by Jeffrey Yemin [ 24/Mar/14 ]

Hi Matt,

Thanks for the report. Running "ant jar" after making the above commit, the MANIFEST.MF now looks like this for 2.12.0-SNAPSHOT:

$ cat META-INF/MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.2
Created-By: 1.7.0_06-ea-b11 (Oracle Corporation)
Bundle-License: http://www.apache.org/licenses/LICENSE-2.0.txt
Bundle-ManifestVersion: 2
Bundle-Name: MongoDB Java Driver
Bundle-SymbolicName: org.mongodb.mongo-java-driver
Bundle-Version: 2.12.0.BUILD-SNAPSHOT
Import-Package: javax.management,javax.net,javax.net.ssl,javax.securit
 y.sasl,javax.security.auth.login,javax.security.auth,org.ietf.jgss
Export-Package: com.mongodb;version="2.12.0.BUILD-SNAPSHOT",com.mongod
 b.io;version="2.12.0.BUILD-SNAPSHOT",com.mongodb.util;version="2.12.0
 .BUILD-SNAPSHOT",com.mongodb.gridfs;version="2.12.0.BUILD-SNAPSHOT",o
 rg.bson;version="2.12.0.BUILD-SNAPSHOT",org.bson.util;version="2.12.0
 .BUILD-SNAPSHOT",org.bson.util.annotations;version="2.12.0.BUILD-SNAP
 SHOT",org.bson.types;version="2.12.0.BUILD-SNAPSHOT",org.bson.io;vers
 ion="2.12.0.BUILD-SNAPSHOT"

Does that look reasonable?

Comment by Githook User [ 24/Mar/14 ]

Author:

{u'username': u'jyemin', u'name': u'Jeff Yemin', u'email': u'jeff.yemin@10gen.com'}

Message: JAVA-1153: Added packages to Import-Package so that GSSAPI will work properly when the driver is running as an OSGI module.
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/a3a90b473b95a5d87e0ce9ce968b9a7f9924a718

Generated at Thu Feb 08 08:53:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.