avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank Herrmann <herrmann.fr...@gmx.de>
Subject Avalon+James+JCE (long!)
Date Tue, 03 Sep 2002 07:45:32 GMT
Hi!

yesterday I asked the following question on the James developer list and 
somebody recommended asking directly on the Avalon list.
So here is the problem:

--------------------------------------------------------------------------------

Hello!

I'd like to use JCE (Java Cryptography Extension) inside a mailet. When I try 
to start James (run.sh) it throws the following exception: 

java.lang.NoClassDefFoundError: com/sun/crypto/provider/SunJCE

AFAIK this only happens if the provider class is not in the classpath.
(for me it is /usr/lib/java/jre/lib/ext/sunjce_provider.jar)

When I compile (and run) the code snippet in a separate ("normal") java file 
it works like a charm. 

So the question is: How can I tell James where to find the sunjce_provider.jar 
file ? 

What I already tried: added classpath in /dist/bin/run.sh - no difference.

$JAVA_HOME/bin/java -classpath /usr/lib/java/jre/lib/ext/sunjce_provider.jar 
$JVM_OPTS -jar $PHOENIX_HOME/bin/phoenix-loader.jar $*

Greetings,
Frank

-------------------------------little code sample---------------------
           try {

            if (_DEBUG_CRYPTO) {
                // display providers we have available:
                secProviders = Security.getProviders();
                System.out.println(secProviders.length);
                for (int i = 0; i < secProviders.length; i++)
                    {
                        System.out.println(secProviders[i].getInfo());
                    }
            }

             /* select provider SunJCE */
            secProvider = new com.sun.crypto.provider.SunJCE();
            Security.addProvider(secProvider);

       }
        catch (Exception e) {}
--------------------------------------------------------------------

------------------------the full exception output--------------------

James 2.0a3
There was an uncaught exception:
---------------------------------------------------------
--- Message ---
Failed to initialize application james.
--- Stack Trace ---
org.apache.avalon.phoenix.interfaces.DeploymentException: Failed to initialize 
application james.
        at 
org.apache.avalon.phoenix.components.deployer.DefaultDeployer.deploy(DefaultDeployer.java:183)
        at 
org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployFile(DefaultEmbeddor.java:467)
        at 
org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployFile(DefaultEmbeddor.java:461)
        at 
org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployFiles(DefaultEmbeddor.java:449)
        at 
org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.deployDefaultApplications(DefaultEmbeddor.java:439)
        at 
org.apache.avalon.phoenix.components.embeddor.DefaultEmbeddor.execute(DefaultEmbeddor.java:182)
        at org.apache.avalon.phoenix.frontends.CLIMain.run(CLIMain.java:115)
        at 
org.apache.avalon.phoenix.frontends.CLIMain.execute(CLIMain.java:101)
        at org.apache.avalon.phoenix.frontends.CLIMain.main(CLIMain.java:67)
        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:324)
        at org.apache.avalon.phoenix.launcher.Main.startup(Main.java:88)
        at org.apache.avalon.phoenix.launcher.Main.main(Main.java:51)
Caused by: org.apache.avalon.framework.CascadingException: Failed to 
initialize application james.
        at 
org.apache.avalon.phoenix.components.kernel.DefaultKernel.startup(DefaultKernel.java:134)
        at 
org.apache.avalon.phoenix.components.kernel.DefaultKernel.addApplication(DefaultKernel.java:169)
        at 
org.apache.avalon.phoenix.components.deployer.DefaultDeployer.deploy(DefaultDeployer.java:166)
        ... 14 more
Caused by: org.apache.avalon.framework.CascadingException: Block named 
"spoolmanager" failed to pass through the Initialization stage. (Reason: 
java.lang.NoClassDefFoundError: com/sun/crypto/provider/SunJCE).
        at 
org.apache.avalon.phoenix.components.application.LifecycleHelper.fail(LifecycleHelper.java:417)
        at 
org.apache.avalon.phoenix.components.application.LifecycleHelper.startup(LifecycleHelper.java:220)
        at 
org.apache.avalon.phoenix.components.application.DefaultApplication.runPhase(DefaultApplication.java:176)
        at 
org.apache.avalon.phoenix.components.application.DefaultApplication.start(DefaultApplication.java:88)
        at 
org.apache.avalon.phoenix.components.kernel.DefaultKernel.startup(DefaultKernel.java:122)
        ... 16 more
Caused by: java.lang.NoClassDefFoundError: com/sun/crypto/provider/SunJCE
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:130)
        at 
org.apache.james.transport.MailetLoader.getMailet(MailetLoader.java:57)
        at 
org.apache.james.transport.JamesSpoolManager.initialize(JamesSpoolManager.java:151)
        at 
org.apache.avalon.phoenix.components.application.LifecycleHelper.startup(LifecycleHelper.java:199)
        ... 19 more
---------------------------------------------------------------------------------------------------------

For your convenience I append the answers I got on James developer list here:

Danny Angus wrote:
-----------------------------------------------------------------------------------------------------------
Frank,
the mailet classpath is controlled by Avalon Phoenix
http://jakarta.apache/org/avalon
If you're not familiar with avalon it provides james (I expect the Avaloon
guys will "correct" me robustly when i get this wrong!) with a runtime
platform "Phoenix", several services, and a lifecycle framework.

Phoenix ensures classpath separation amongst apps its hosting, which is
fine, but also (probably for good reasons) omits
jre/lib/ext from the classpath it provides its "blocks" with. if you're
using james 1.2a1-xx you could try putting the crypto provider in phoenix
own common lib dirs, which I think would be either james/lib or james/ext

I know one of these (can't remember which offhand) works for JDBC drivers,
check my JDBC related comments in the config file to find out what I used to
know ;-).

As far as telling Phoenix to include jre/lib/ext in the classpath it
provides, I'm not sure what to do, (if you are a *nix user I'd try linking
Phoenix /ext/ to jre/lib/ext, but thats not a portable answer).

You may get further by asking this same question on the avalon lists.
If you get a better answer anywhere let us know.
---------------------------------------------------------------------------------------------

Noel J.Bergman wrote:
-----------------------------------------------------------------------------------------------
Removing jre/lib/ext from the classpath seems like an error.  That is
explicitly where shared libraries are supposed to go.  Separation of
classpath's shouldn't apply.

It would only make sense if the goal was to make SAR files self-contained,
except for Phoenix.

        --- Noel
------------------------------------------------------------------------------------------------

Thank you for reading!

Frank




--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message