10:08:53,096 INFO [ServerInfo] Java version: 1.5.0_10,Sun Microsystems Inc.
10:08:53,096 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM
1.5.0_10-b03,Sun Microsystems Inc.
10:08:53,096 INFO [ServerInfo] OS-System: Linux 2.6.18-3-k7,i386
10:08:53,100 DEBUG [ServerInfo] java.home:
/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre
10:08:53,100 DEBUG [ServerInfo] java.specification.vendor: Sun
Microsystems Inc.
10:08:53,100 DEBUG [ServerInfo] user.language: en
10:08:53,100 DEBUG [ServerInfo] java.vm.info: mixed mode
10:08:53,100 DEBUG [ServerInfo] java.version: 1.5.0_10
10:08:53,100 DEBUG [ServerInfo] java.ext.dirs:
/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/ext
10:08:53,100 DEBUG [ServerInfo] sun.boot.class.path:
/usr/local/jboss/lib/endorsed/serializer.jar:/usr/local/jboss/lib/endorsed/x
alan.jar:/usr/local/jboss/lib/endorsed/xercesImpl.jar:/usr/lib/jvm/java-1.5.
0-sun-1.5.0.10/jre/lib/rt.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/i
18n.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/sunrsasign.jar:/usr/lib
/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/jsse.jar:/usr/lib/jvm/java-1.5.0-sun-1.
5.0.10/jre/lib/jce.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/charsets
.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/classes
# ls /usr/share/java/jboss-4.2.2.GA/server/default/lib
activation.jar hibernate-entitymanager.jar
jboss-monitoring.jar jbossws-spi.jar
antlr.jar hibernate3.jar
jboss-remoting-int.jar jmx-adaptor-plugin.jar
autonumber-plugin.jar hsqldb-plugin.jar jboss-remoting.jar
jnpserver.jar
bcel.jar hsqldb.jar jboss-saaj.jar
joesnmp.jar
bindingservice-plugin.jar javassist.jar
jboss-serialization.jar jpl-pattern.jar
bsf.jar jaxen.jar jboss-srp.jar
jpl-util.jar
bsh-deployer.jar jboss-cache-jdk50.jar
jboss-transaction.jar jsp-api.jar
bsh.jar jboss-common-jdbc-wrapper.jar jboss-vfs.jar
log4j-snmp-appender.jar
cglib.jar jboss-ejb3x.jar jboss.jar
log4j.jar
commons-codec.jar jboss-hibernate.jar
jbossjta-integration.jar mail-plugin.jar
commons-collections.jar jboss-j2ee.jar jbossjta.jar
mail.jar
commons-httpclient.jar jboss-jaxrpc.jar jbossmq.jar
properties-plugin.jar
commons-logging.jar jboss-jaxws.jar jbosssx.jar
quartz.jar
dom4j.jar jboss-jca.jar jbossts-common.jar
scheduler-plugin-example.jar
ejb3-persistence.jar jboss-jsr77.jar jbossws-common.jar
scheduler-plugin.jar
el-api.jar jboss-jsr88.jar
jbossws-framework.jar servlet-api.jar
hibernate-annotations.jar jboss-management.jar
jbossws-jboss42.jar xmlentitymgr.jar
Could you try running a small test JetS3t program, or the Synchronize
application, from outside JBoss? If this test works, we can be sure
it's something to do with the app server rather than the JVM or system.
I'm not sure what would cause a conflict on JBoss, but we should be
able to work through it and figure it out.
James
On 14/08/2008, at 8:15 AM, "Rob Staveley \(Tom\)"
--------8<--------
#!/usr/bin/java bsh.Interpreter
/*
These are the .jars in the WEB-INF/lib directory:
bcprov-jdk15-136.jar commons-logging-1.1.1.jar junit-3.8.1.jar
lucene-lucli-2.3.1.jar tar-2.5.jar
commons-codec-1.3.jar jets3t-0.6.1.jar log4j-1.2.14.jar
spring-2.0.5.jar typica-1.3.jar
commons-httpclient-3.1.jar jline-0.9.91.jar lucene-core-2.3.1.jar
tagsoup-1.1.3.jar
*/
// Add .jars from the current working directory (from the deployed .war
String webLib =
"/usr/share/java/jboss-4.2.2.GA/server/default/tmp/deploy/tmp20676xxxxxxx-ex
p.war/WEB-INF/lib/";
// Test for jets3t
addClassPath(webLib+"jets3t-0.6.1.jar");
addClassPath(webLib+"commons-logging-1.1.1.jar");
addClassPath(webLib+"commons-httpclient-3.1.jar");
addClassPath(webLib+"commons-codec-1.3.jar");
System.out.println("BeanShell test");
import org.jets3t.service.security.AWSCredentials;
import org.jets3t.service.S3Service;
import org.jets3t.service.impl.rest.httpclient.RestS3Service;
import org.jets3t.service.model.S3Bucket;
import org.jets3t.service.model.S3Object;
import org.jets3t.service.S3ServiceException;
/*
reference to S3 service
*/
S3Service getS3Service() throws S3ServiceException {
String awsAccessKey = "xxxxxxxxxxxx";
String awsSecretKey = "xxxxxxxxxxxx";
AWSCredentials awsCredentials = new AWSCredentials(awsAccessKey,
awsSecretKey);
return new RestS3Service(awsCredentials);
}
// Amazon S3 service
S3Service s3Service = getS3Service();
String bucketName = "lucy-services";
boolean gotBucket = false;
S3Bucket[] buckets = s3Service.listAllBuckets();
print("Found "+buckets.length+" buckets in S3");
S3Bucket lucyBucket = null;
for (S3Bucket bucket : buckets) {
print("S3 bucket: "+bucket.getName());
if (bucket.getName().equals(bucketName)) {
gotBucket = true;
lucyBucket = bucket;
}
}
print(gotBucket?"Bucket located OK":"Bucket not found :-(");
--------8<--------
root@seseiaa4:/usr/share/java/jboss-4.2.2.GA/server/default/lib# echo `ls`
activation.jar antlr.jar autonumber-plugin.jar bcel.jar
bindingservice-plugin.jar bsf.jar bsh-deployer.jar bsh.jar cglib.jar
commons-codec.jar commons-collections.jar commons-httpclient.jar
commons-logging.jar dom4j.jar ejb3-persistence.jar el-api.jar
hibernate-annotations.jar hibernate-entitymanager.jar hibernate3.jar
hsqldb-plugin.jar hsqldb.jar javassist.jar jaxen.jar jboss-cache-jdk50.jar
jboss-common-jdbc-wrapper.jar jboss-ejb3x.jar jboss-hibernate.jar
jboss-j2ee.jar jboss-jaxrpc.jar jboss-jaxws.jar jboss-jca.jar
jboss-jsr77.jar jboss-jsr88.jar jboss-management.jar jboss-monitoring.jar
jboss-remoting-int.jar jboss-remoting.jar jboss-saaj.jar
jboss-serialization.jar jboss-srp.jar jboss-transaction.jar jboss-vfs.jar
jboss.jar jbossjta-integration.jar jbossjta.jar jbossmq.jar jbosssx.jar
jbossts-common.jar jbossws-common.jar jbossws-framework.jar
jbossws-jboss42.jar jbossws-spi.jar jmx-adaptor-plugin.jar jnpserver.jar
joesnmp.jar jpl-pattern.jar jpl-util.jar jsp-api.jar log4j-snmp-appender.jar
log4j.jar mail-plugin.jar mail.jar properties-plugin.jar quartz.jar
scheduler-plugin-example.jar scheduler-plugin.jar servlet-api.jar
security.provider.1=sun.security.provider.Sun
policy.url.1=file:${java.home}/lib/security/java.policy
If the security settings aren't quite right, the server may be unable
to load some crypto libraries even when the right jar files are
present.
However, it looks to me that the class that can't be loaded in JBoss is
javax.crypto.Mac itself.
Here's what I've found...
If I manually get an instance of a Mac for "HmaxSHA1", with the following
BeanShell script....
--------8<--------
#!/usr/lib/jvm/java-1.5.0-sun/jre/bin/java bsh.Interpreter
import javax.crypto.Mac;
import java.security.Provider;
try {
Mac mac = Mac.getInstance("HmacSHA1");
if (mac == null) {
print("No Mac found");
exit();
}
Provider provider = mac.getProvider();
print("Mac: "+mac.getClass().getName());
print("Provider: "+provider.getClass().getName()+" -
"+provider.getInfo());
print("Algorithm: "+mac.getAlgorithm());
exit();
}
catch (Exception e) {
e.printStackTrace();
}
--------8<--------
...I see:
Mac: javax.crypto.Mac
Provider: com.sun.crypto.provider.SunJCE - SunJCE Provider (implements RSA,
DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, Diffie-Hellman, HMAC)
Algorithm: HmacSHA1
If I run the equivalent in my web application, I see the same in Jetty,
which has been behaving nicely throughout.
In JBoss, however, I see...
008-08-15 07:10:24,475 ERROR [STDERR] Exception in thread "Timer-13"
2008-08-15 07:10:24,475 ERROR [STDERR] java.lang.NoClassDefFoundError
2008-08-15 07:10:24,476 ERROR [STDERR] at
javax.crypto.Mac.getInstance(DashoA12275)
This suggests that javax.crypto.Mac itself is not on the classpath.
Looking at http://javacio.us/subscribers/classes/javax.crypto.Mac tells me
that I should expect to load javax.crypto.Mac from J2SE JRE's jce.jar, which
I can confirm is there on the server in the right J2SE JRE lib directory. In
the JBoss boot.log, I see it on the sun.boot.class.path:
10:08:53,100 DEBUG [ServerInfo] sun.boot.class.path:
/usr/local/jboss/lib/endorsed/serializer.jar:/usr/local/jboss/lib/endorsed/x
alan.jar:/usr/local/jboss/lib/endorsed/xercesImpl.jar:/usr/lib/jvm/java-1.5.
0-sun-1.5.0.10/jre/lib/rt.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/i
18n.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/sunrsasign.jar:/usr/lib
/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/jsse.jar:/usr/lib/jvm/java-1.5.0-sun-1.
5.0.10/jre/lib/jce.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/lib/charsets
.jar:/usr/lib/jvm/java-1.5.0-sun-1.5.0.10/jre/classes
You can apparently also get it from BouncyCastle.
If I add the BounceCastle .jar from
http://repo1.maven.org/maven2/bouncycastle/bouncycastle-jce-jdk13/112/ to my
project, the code fails in Jetty as follows:
java.lang.ClassCastException: com.sun.crypto.provider.HmacSHA1 cannot be
cast to javax.crypto.MacSpi
at javax.crypto.Mac.getInstance(Mac.java:95)
at
com.xerox.amazonws.common.AWSConnection.encode(AWSConnection.java:145)
at
com.xerox.amazonws.common.AWSQueryConnection.makeRequest(AWSQueryConnection.
java:301)
at
com.xerox.amazonws.sqs2.QueueService.getOrCreateMessageQueue(QueueService.ja
va:122)
JBoss gets no further than the familiar NoClassDefFoundError link error, so
no change there. It still appears to be unable to load javax.crypto.Mac,
assuming that's what it means.
I followed the instructions at http://jaitechwriteups.blogspot.com/ and set
up a jboss-web.xml which gets JBoss to load classes in isolation in
deployment. I found that somehow or other this seems to get the JBoss
classloader to load javax.crypto.Mac. My uneducated guess is that JBoss's
super-efficient class-loading got its knickers in a twist and things are
simplified, when the application is not made to share classes. Or something
like that!
It would be good to know for real, because JBoss is important in my world.
Thanks for bearing with me, James; and thanks very much for the great
software!!
I'm glad you found a fix, and thanks for sharing it here on the forum
-- it's sure to affect someone else sooner or later.
App servers often need to do odd things with class paths, especially
for libraries that are required by the server itself. I'm only
guessing, but this issue may be caused by the fact that JBoss uses the
Java security libraries itself while hiding them from deployed
applications, in the expectation that these apps will hook into JBoss'
resources rather than talking to the "outside world" directly. I've
had my share of problems with XML libraries in this kind of
situation...
I hope things will run more smoothly for you from now on.
Cheers,
James
On Sat, Aug 16, 2008 at 12:30 AM, Rob Staveley (Tom)