ClassNotFoundException: JaccProvider$Factory

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

ClassNotFoundException: JaccProvider$Factory

Martin Vysny-2
Hi guys,
  can you please help me with this one? Rarely, the OpenEJB startup
fails with the exception ClassNotFoundException: JaccProvider$Factory
(full stacktrace is below). The interesting point is, that you can just
rerun the OpenEJB and the server would start normally. We are using
OpenEJB 3.0-beta-1, and I could swear that the
org.apache.openejb.core.security.JaccProvider$Factory is on the
classpath. We are using java6 x86 on linux:
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
We are not using any special classloader hierarchy (well, not before
OpenEJB is fully started). Perhaps a java bug?
Thanks!
Martin


PolicyConfigurationFactory class not found: JACC:Error
PolicyConfigurationFactory : cannot find class :
org.apache.openejb.core.security.JaccProvider$Factory
        at
org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:558)
        at
org.apache.openejb.assembler.classic.Assembler.buildContainerSystem(Assembler.java:299)
        at
org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:207)
        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:149)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:293)
        at org.apache.openejb.OpenEJB.init(OpenEJB.java:272)
        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:597)
        at
org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:36)
        at
org.apache.openejb.client.LocalInitialContextFactory.init(LocalInitialContextFactory.java:59)
        at
org.apache.openejb.client.LocalInitialContextFactory.getInitialContext(LocalInitialContextFactory.java:45)
        at
javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
        at
javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.<init>(InitialContext.java:197)
        at
com.whitestein.fe.embedded.launcher.OpenEjbAndJettyLauncher.initOpenEJB(OpenEjbAndJettyLauncher.java:223)
        at
com.whitestein.fe.embedded.launcher.OpenEjbAndJettyLauncher.launch(OpenEjbAndJettyLauncher.java:146)
        at
com.whitestein.fe.embedded.launcher.Launcher.launch(Launcher.java:107)
        at com.whitestein.fe.it.cal.CalUtils.newComm(CalUtils.java:45)
        at
com.whitestein.fe.it.cal.AbstractCalTest.setUp(AbstractCalTest.java:35)
        at junit.framework.TestCase.runBare(TestCase.java:125)
        at junit.framework.TestResult$1.protect(TestResult.java:106)
        at junit.framework.TestResult.runProtected(TestResult.java:124)
        at junit.framework.TestResult.run(TestResult.java:109)
        at junit.framework.TestCase.run(TestCase.java:118)
        at junit.framework.TestSuite.runTest(TestSuite.java:208)
        at junit.framework.TestSuite.run(TestSuite.java:203)
        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:597)
        at
org.apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:213)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:138)
        at
org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:125)
        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
        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:597)
        at
org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
        at
org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
Caused by: org.apache.openejb.OpenEJBException:
PolicyConfigurationFactory class not found: JACC:Error
PolicyConfigurationFactory : cannot find class :
org.apache.openejb.core.security.JaccProvider$Factory
        at
org.apache.openejb.assembler.classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:62)
        at
org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:436)
        ... 42 more
Caused by: java.lang.ClassNotFoundException: JACC:Error
PolicyConfigurationFactory : cannot find class :
org.apache.openejb.core.security.JaccProvider$Factory
        at
javax.security.jacc.PolicyConfigurationFactory.getPolicyConfigurationFactory(PolicyConfigurationFactory.java:143)
        at
org.apache.openejb.assembler.classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:48)
        ... 43 more
Caused by: java.lang.ClassNotFoundException:
org.apache.openejb.core.security.JaccProvider$Factory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at
javax.security.jacc.PolicyConfigurationFactory.getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
        ... 44 more


signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ClassNotFoundException: JaccProvider$Factory

Dain Sundstrom
There is something strange going on here.  The innermost stack trace is:

Caused by:  
java
.lang
.ClassNotFoundException:org.apache.openejb.core.security.JaccProvider
$Factory
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:247)
        at  
javax
.security
.jacc
.PolicyConfigurationFactory
.getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
        ... 44 more

But, if you look at our spec code for  
javax.security.jacc.PolicyConfigurationFactory, there is no code on  
line 131, and after browsing the full history of that file, there has  
never been a call to Class.forName on line 247.  Do you have a second  
(possibly one from Sun), implementation of the JACC spec in your lib  
directory or one of your applications?

-dain


On Jan 16, 2008, at 1:34 AM, Martin Vysny wrote:

> Hi guys,
>  can you please help me with this one? Rarely, the OpenEJB startup
> fails with the exception ClassNotFoundException: JaccProvider$Factory
> (full stacktrace is below). The interesting point is, that you can  
> just
> rerun the OpenEJB and the server would start normally. We are using
> OpenEJB 3.0-beta-1, and I could swear that the
> org.apache.openejb.core.security.JaccProvider$Factory is on the
> classpath. We are using java6 x86 on linux:
> java version "1.6.0_03"
> Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
> Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
> We are not using any special classloader hierarchy (well, not before
> OpenEJB is fully started). Perhaps a java bug?
> Thanks!
> Martin
>
>
> PolicyConfigurationFactory class not found: JACC:Error
> PolicyConfigurationFactory : cannot find class :
> org.apache.openejb.core.security.JaccProvider$Factory
>        at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.createApplication(Assembler.java:558)
>        at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.buildContainerSystem(Assembler.java:299)
>        at
> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:
> 207)
>        at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:149)
>        at org.apache.openejb.OpenEJB.init(OpenEJB.java:293)
>        at org.apache.openejb.OpenEJB.init(OpenEJB.java:272)
>        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:597)
>        at
> org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:
> 36)
>        at
> org
> .apache
> .openejb
> .client
> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:59)
>        at
> org
> .apache
> .openejb
> .client
> .LocalInitialContextFactory
> .getInitialContext(LocalInitialContextFactory.java:45)
>        at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
> 667)
>        at
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>        at javax.naming.InitialContext.init(InitialContext.java:223)
>        at javax.naming.InitialContext.<init>(InitialContext.java:197)
>        at
> com
> .whitestein
> .fe
> .embedded
> .launcher
> .OpenEjbAndJettyLauncher.initOpenEJB(OpenEjbAndJettyLauncher.java:223)
>        at
> com
> .whitestein
> .fe
> .embedded
> .launcher
> .OpenEjbAndJettyLauncher.launch(OpenEjbAndJettyLauncher.java:146)
>        at
> com.whitestein.fe.embedded.launcher.Launcher.launch(Launcher.java:107)
>        at com.whitestein.fe.it.cal.CalUtils.newComm(CalUtils.java:45)
>        at
> com.whitestein.fe.it.cal.AbstractCalTest.setUp(AbstractCalTest.java:
> 35)
>        at junit.framework.TestCase.runBare(TestCase.java:125)
>        at junit.framework.TestResult$1.protect(TestResult.java:106)
>        at junit.framework.TestResult.runProtected(TestResult.java:124)
>        at junit.framework.TestResult.run(TestResult.java:109)
>        at junit.framework.TestCase.run(TestCase.java:118)
>        at junit.framework.TestSuite.runTest(TestSuite.java:208)
>        at junit.framework.TestSuite.run(TestSuite.java:203)
>        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:597)
>        at
> org
> .apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:
> 213)
>        at
> org
> .apache
> .maven
> .surefire
> .suite
> .AbstractDirectoryTestSuite
> .executeTestSet(AbstractDirectoryTestSuite.java:138)
>        at
> org
> .apache
> .maven
> .surefire
> .suite
> .AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
> 125)
>        at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>        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:597)
>        at
> org
> .apache
> .maven
> .surefire
> .booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
>        at
> org
> .apache
> .maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
> Caused by: org.apache.openejb.OpenEJBException:
> PolicyConfigurationFactory class not found: JACC:Error
> PolicyConfigurationFactory : cannot find class :
> org.apache.openejb.core.security.JaccProvider$Factory
>        at
> org
> .apache
> .openejb
> .assembler
> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
> 62)
>        at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.createApplication(Assembler.java:436)
>        ... 42 more
> Caused by: java.lang.ClassNotFoundException: JACC:Error
> PolicyConfigurationFactory : cannot find class :
> org.apache.openejb.core.security.JaccProvider$Factory
>        at
> javax
> .security
> .jacc
> .PolicyConfigurationFactory
> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:143)
>        at
> org
> .apache
> .openejb
> .assembler
> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
> 48)
>        ... 43 more
> Caused by: java.lang.ClassNotFoundException:
> org.apache.openejb.core.security.JaccProvider$Factory
>        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
> 276)
>        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
> 319)
>        at java.lang.Class.forName0(Native Method)
>        at java.lang.Class.forName(Class.java:247)
>        at
> javax
> .security
> .jacc
> .PolicyConfigurationFactory
> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
>        ... 44 more
>

Reply | Threaded
Open this post in threaded view
|

Re: ClassNotFoundException: JaccProvider$Factory

dblevins
Administrator
In reply to this post by Martin Vysny-2

On Jan 16, 2008, at 1:34 AM, Martin Vysny wrote:

> Hi guys,
> can you please help me with this one? Rarely, the OpenEJB startup
> fails with the exception ClassNotFoundException: JaccProvider$Factory
> (full stacktrace is below). The interesting point is, that you can  
> just
> rerun the OpenEJB and the server would start normally. We are using
> OpenEJB 3.0-beta-1, and I could swear that the
> org.apache.openejb.core.security.JaccProvider$Factory is on the
> classpath. We are using java6 x86 on linux:
> java version "1.6.0_03"
> Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
> Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
> We are not using any special classloader hierarchy (well, not before
> OpenEJB is fully started). Perhaps a java bug?


That's pretty strange.  My only guess is that the Thread context  
classloader is getting changed to something else (seemingly randomly)  
and the factory class becomes no longer visible.  I've implemented  
this particular fix forces it to load earlier and forces a specific  
classloader when using our default factory:
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java?r1=612547&r2=612546&pathrev=612547

We could test this theory out on the code you have now if you catch  
the exception you posted below and in the catch clause do something  
like this:

        ClassLoader classLoader =  
Thread.currentThread().getContextClassLoader();
        System.out.println("classLoader" + classLoader);
        System.out.println("classLoader.class" +  
classLoader.getClass().getName());
        if (classLoader instanceof URLClassLoader) {
            URLClassLoader urlClassLoader = (URLClassLoader)  
classLoader;
            URL[] urls = urlClassLoader.getURLs();
            for (URL url : urls) {
                System.out.println("url = " + url.toExternalForm());
            }
        }

-David


> PolicyConfigurationFactory class not found: JACC:Error
> PolicyConfigurationFactory : cannot find class :
> org.apache.openejb.core.security.JaccProvider$Factory
>       at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.createApplication(Assembler.java:558)
>       at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.buildContainerSystem(Assembler.java:299)
>       at
> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:
> 207)
>       at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:149)
>       at org.apache.openejb.OpenEJB.init(OpenEJB.java:293)
>       at org.apache.openejb.OpenEJB.init(OpenEJB.java:272)
>       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:597)
>       at
> org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:
> 36)
>       at
> org
> .apache
> .openejb
> .client
> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:59)
>       at
> org
> .apache
> .openejb
> .client
> .LocalInitialContextFactory
> .getInitialContext(LocalInitialContextFactory.java:45)
>       at
> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
> 667)
>       at
> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
>       at javax.naming.InitialContext.init(InitialContext.java:223)
>       at javax.naming.InitialContext.<init>(InitialContext.java:197)
>       at
> com
> .whitestein
> .fe
> .embedded
> .launcher
> .OpenEjbAndJettyLauncher.initOpenEJB(OpenEjbAndJettyLauncher.java:223)
>       at
> com
> .whitestein
> .fe
> .embedded
> .launcher
> .OpenEjbAndJettyLauncher.launch(OpenEjbAndJettyLauncher.java:146)
>       at
> com.whitestein.fe.embedded.launcher.Launcher.launch(Launcher.java:107)
>       at com.whitestein.fe.it.cal.CalUtils.newComm(CalUtils.java:45)
>       at
> com.whitestein.fe.it.cal.AbstractCalTest.setUp(AbstractCalTest.java:
> 35)
>       at junit.framework.TestCase.runBare(TestCase.java:125)
>       at junit.framework.TestResult$1.protect(TestResult.java:106)
>       at junit.framework.TestResult.runProtected(TestResult.java:124)
>       at junit.framework.TestResult.run(TestResult.java:109)
>       at junit.framework.TestCase.run(TestCase.java:118)
>       at junit.framework.TestSuite.runTest(TestSuite.java:208)
>       at junit.framework.TestSuite.run(TestSuite.java:203)
>       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:597)
>       at
> org
> .apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:
> 213)
>       at
> org
> .apache
> .maven
> .surefire
> .suite
> .AbstractDirectoryTestSuite
> .executeTestSet(AbstractDirectoryTestSuite.java:138)
>       at
> org
> .apache
> .maven
> .surefire
> .suite
> .AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
> 125)
>       at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>       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:597)
>       at
> org
> .apache
> .maven
> .surefire
> .booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
>       at
> org
> .apache
> .maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
> Caused by: org.apache.openejb.OpenEJBException:
> PolicyConfigurationFactory class not found: JACC:Error
> PolicyConfigurationFactory : cannot find class :
> org.apache.openejb.core.security.JaccProvider$Factory
>       at
> org
> .apache
> .openejb
> .assembler
> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
> 62)
>       at
> org
> .apache
> .openejb
> .assembler.classic.Assembler.createApplication(Assembler.java:436)
>       ... 42 more
> Caused by: java.lang.ClassNotFoundException: JACC:Error
> PolicyConfigurationFactory : cannot find class :
> org.apache.openejb.core.security.JaccProvider$Factory
>       at
> javax
> .security
> .jacc
> .PolicyConfigurationFactory
> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:143)
>       at
> org
> .apache
> .openejb
> .assembler
> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
> 48)
>       ... 43 more
> Caused by: java.lang.ClassNotFoundException:
> org.apache.openejb.core.security.JaccProvider$Factory
>       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>       at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
>       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>       at java.lang.Class.forName0(Native Method)
>       at java.lang.Class.forName(Class.java:247)
>       at
> javax
> .security
> .jacc
> .PolicyConfigurationFactory
> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
>       ... 44 more
>

Reply | Threaded
Open this post in threaded view
|

Re: ClassNotFoundException: JaccProvider$Factory

dblevins
Administrator
In reply to this post by Dain Sundstrom

On Jan 16, 2008, at 12:15 PM, Dain Sundstrom wrote:

> Caused by:  
> java
> .lang
> .ClassNotFoundException:org.apache.openejb.core.security.JaccProvider
> $Factory
>       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>       at java.security.AccessController.doPrivileged(Native Method)
>       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
[...]

>       at java.lang.Class.forName(Class.java:247)
>       at  
> javax
> .security
> .jacc
> .PolicyConfigurationFactory
> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
>       ... 44 more
>
> But, if you look at our spec code for  
> javax.security.jacc.PolicyConfigurationFactory, there is no code on  
> line 131, and after browsing the full history of that file, there  
> has never been a call to Class.forName on line 247.  Do you have a  
> second (possibly one from Sun), implementation of the JACC spec in  
> your lib directory or one of your applications?

That's an interesting possibility.  Could be there is another jar in  
your classpath providing the jacc api and it randomly ends up before  
ours (and presumably it's blowing up in it's static initializer).

Looks like you're in maven2/surefire when this happens.  It should be  
possible to get a list of the jars in your classpath via the code I  
posted earlier (surefire's classloader is a subclass of  
URLClassLoader).  Then you should be able to look in them and see how  
many copies copy of javax/security/jacc/
PolicyConfigurationFactory.class you have.

I've got a script for grepping through jars that might be handy:
   http://docs.codehaus.org/display/ninja/grepjar

-David

> On Jan 16, 2008, at 1:34 AM, Martin Vysny wrote:
>
>> Hi guys,
>> can you please help me with this one? Rarely, the OpenEJB startup
>> fails with the exception ClassNotFoundException: JaccProvider$Factory
>> (full stacktrace is below). The interesting point is, that you can  
>> just
>> rerun the OpenEJB and the server would start normally. We are using
>> OpenEJB 3.0-beta-1, and I could swear that the
>> org.apache.openejb.core.security.JaccProvider$Factory is on the
>> classpath. We are using java6 x86 on linux:
>> java version "1.6.0_03"
>> Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
>> Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
>> We are not using any special classloader hierarchy (well, not before
>> OpenEJB is fully started). Perhaps a java bug?
>> Thanks!
>> Martin
>>
>>
>> PolicyConfigurationFactory class not found: JACC:Error
>> PolicyConfigurationFactory : cannot find class :
>> org.apache.openejb.core.security.JaccProvider$Factory
>>       at
>> org
>> .apache
>> .openejb
>> .assembler.classic.Assembler.createApplication(Assembler.java:558)
>>       at
>> org
>> .apache
>> .openejb
>> .assembler.classic.Assembler.buildContainerSystem(Assembler.java:299)
>>       at
>> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:
>> 207)
>>       at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:149)
>>       at org.apache.openejb.OpenEJB.init(OpenEJB.java:293)
>>       at org.apache.openejb.OpenEJB.init(OpenEJB.java:272)
>>       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:597)
>>       at
>> org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:
>> 36)
>>       at
>> org
>> .apache
>> .openejb
>> .client
>> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:59)
>>       at
>> org
>> .apache
>> .openejb
>> .client
>> .LocalInitialContextFactory
>> .getInitialContext(LocalInitialContextFactory.java:45)
>>       at
>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
>> 667)
>>       at
>> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:
>> 288)
>>       at javax.naming.InitialContext.init(InitialContext.java:223)
>>       at javax.naming.InitialContext.<init>(InitialContext.java:197)
>>       at
>> com
>> .whitestein
>> .fe
>> .embedded
>> .launcher
>> .OpenEjbAndJettyLauncher.initOpenEJB(OpenEjbAndJettyLauncher.java:
>> 223)
>>       at
>> com
>> .whitestein
>> .fe
>> .embedded
>> .launcher
>> .OpenEjbAndJettyLauncher.launch(OpenEjbAndJettyLauncher.java:146)
>>       at
>> com.whitestein.fe.embedded.launcher.Launcher.launch(Launcher.java:
>> 107)
>>       at com.whitestein.fe.it.cal.CalUtils.newComm(CalUtils.java:45)
>>       at
>> com.whitestein.fe.it.cal.AbstractCalTest.setUp(AbstractCalTest.java:
>> 35)
>>       at junit.framework.TestCase.runBare(TestCase.java:125)
>>       at junit.framework.TestResult$1.protect(TestResult.java:106)
>>       at junit.framework.TestResult.runProtected(TestResult.java:124)
>>       at junit.framework.TestResult.run(TestResult.java:109)
>>       at junit.framework.TestCase.run(TestCase.java:118)
>>       at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>       at junit.framework.TestSuite.run(TestSuite.java:203)
>>       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:597)
>>       at
>> org
>> .apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:
>> 213)
>>       at
>> org
>> .apache
>> .maven
>> .surefire
>> .suite
>> .AbstractDirectoryTestSuite
>> .executeTestSet(AbstractDirectoryTestSuite.java:138)
>>       at
>> org
>> .apache
>> .maven
>> .surefire
>> .suite
>> .AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
>> 125)
>>       at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>>       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:597)
>>       at
>> org
>> .apache
>> .maven
>> .surefire
>> .booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
>>       at
>> org
>> .apache
>> .maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
>> Caused by: org.apache.openejb.OpenEJBException:
>> PolicyConfigurationFactory class not found: JACC:Error
>> PolicyConfigurationFactory : cannot find class :
>> org.apache.openejb.core.security.JaccProvider$Factory
>>       at
>> org
>> .apache
>> .openejb
>> .assembler
>> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
>> 62)
>>       at
>> org
>> .apache
>> .openejb
>> .assembler.classic.Assembler.createApplication(Assembler.java:436)
>>       ... 42 more
>> Caused by: java.lang.ClassNotFoundException: JACC:Error
>> PolicyConfigurationFactory : cannot find class :
>> org.apache.openejb.core.security.JaccProvider$Factory
>>       at
>> javax
>> .security
>> .jacc
>> .PolicyConfigurationFactory
>> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:143)
>>       at
>> org
>> .apache
>> .openejb
>> .assembler
>> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
>> 48)
>>       ... 43 more
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.openejb.core.security.JaccProvider$Factory
>>       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>       at java.security.AccessController.doPrivileged(Native Method)
>>       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>       at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
>> 276)
>>       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
>> 319)
>>       at java.lang.Class.forName0(Native Method)
>>       at java.lang.Class.forName(Class.java:247)
>>       at
>> javax
>> .security
>> .jacc
>> .PolicyConfigurationFactory
>> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
>>       ... 44 more
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: ClassNotFoundException: JaccProvider$Factory

dblevins
Administrator
In reply to this post by dblevins

On Jan 16, 2008, at 12:30 PM, David Blevins wrote:

>
> On Jan 16, 2008, at 1:34 AM, Martin Vysny wrote:
>
>> Hi guys,
>> can you please help me with this one? Rarely, the OpenEJB startup
>> fails with the exception ClassNotFoundException: JaccProvider$Factory
>> (full stacktrace is below). The interesting point is, that you can  
>> just
>> rerun the OpenEJB and the server would start normally. We are using
>> OpenEJB 3.0-beta-1, and I could swear that the
>> org.apache.openejb.core.security.JaccProvider$Factory is on the
>> classpath. We are using java6 x86 on linux:
>> java version "1.6.0_03"
>> Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
>> Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
>> We are not using any special classloader hierarchy (well, not before
>> OpenEJB is fully started). Perhaps a java bug?
>
>
> That's pretty strange.  My only guess is that the Thread context  
> classloader is getting changed to something else (seemingly  
> randomly) and the factory class becomes no longer visible.  I've  
> implemented this particular fix forces it to load earlier and forces  
> a specific classloader when using our default factory:
> http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java?r1=612547&r2=612546&pathrev=612547
>
> We could test this theory out on the code you have now if you catch  
> the exception you posted below and in the catch clause do something  
> like this:
>
>       ClassLoader classLoader =  
> Thread.currentThread().getContextClassLoader();
>       System.out.println("classLoader" + classLoader);
>       System.out.println("classLoader.class" +  
> classLoader.getClass().getName());
>       if (classLoader instanceof URLClassLoader) {
>           URLClassLoader urlClassLoader = (URLClassLoader)  
> classLoader;
>           URL[] urls = urlClassLoader.getURLs();
>           for (URL url : urls) {
>               System.out.println("url = " + url.toExternalForm());
>           }
>       }

Dain points out to me that the above code doesn't search the parent,  
so here is some better code.  Add this to the top of the TestCase:

     static {
         ClassLoader classLoader =  
Thread.currentThread().getContextClassLoader();
         try {
             Enumeration<URL> resources =  
classLoader.getResources("javax/security/jacc/
PolicyConfigurationFactory.class");
             while (resources != null && resources.hasMoreElements()) {
                 URL factoryClassUrl = resources.nextElement();
                 System.out.println("factoryClassUrl = " +  
factoryClassUrl.toExternalForm());
             }
         } catch (IOException e) {}

         while (classLoader != null){
             System.out.println("classLoader" + classLoader);
             System.out.println("classLoader.class" +  
classLoader.getClass().getName());
             if (classLoader instanceof URLClassLoader) {
                 URLClassLoader urlClassLoader = (URLClassLoader)  
classLoader;
                 URL[] urls = urlClassLoader.getURLs();
                 for (URL url : urls) {
                     System.out.println("url = " +  
url.toExternalForm());
                 }
             }
             classLoader = classLoader.getParent();
         }
     }

That should give us some good info on what might be going on.

-David



> -David
>
>
>> PolicyConfigurationFactory class not found: JACC:Error
>> PolicyConfigurationFactory : cannot find class :
>> org.apache.openejb.core.security.JaccProvider$Factory
>>      at
>> org
>> .apache
>> .openejb
>> .assembler.classic.Assembler.createApplication(Assembler.java:558)
>>      at
>> org
>> .apache
>> .openejb
>> .assembler.classic.Assembler.buildContainerSystem(Assembler.java:299)
>>      at
>> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:
>> 207)
>>      at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:149)
>>      at org.apache.openejb.OpenEJB.init(OpenEJB.java:293)
>>      at org.apache.openejb.OpenEJB.init(OpenEJB.java:272)
>>      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:597)
>>      at
>> org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:
>> 36)
>>      at
>> org
>> .apache
>> .openejb
>> .client
>> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:59)
>>      at
>> org
>> .apache
>> .openejb
>> .client
>> .LocalInitialContextFactory
>> .getInitialContext(LocalInitialContextFactory.java:45)
>>      at
>> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
>> 667)
>>      at
>> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:
>> 288)
>>      at javax.naming.InitialContext.init(InitialContext.java:223)
>>      at javax.naming.InitialContext.<init>(InitialContext.java:197)
>>      at
>> com
>> .whitestein
>> .fe
>> .embedded
>> .launcher
>> .OpenEjbAndJettyLauncher.initOpenEJB(OpenEjbAndJettyLauncher.java:
>> 223)
>>      at
>> com
>> .whitestein
>> .fe
>> .embedded
>> .launcher
>> .OpenEjbAndJettyLauncher.launch(OpenEjbAndJettyLauncher.java:146)
>>      at
>> com.whitestein.fe.embedded.launcher.Launcher.launch(Launcher.java:
>> 107)
>>      at com.whitestein.fe.it.cal.CalUtils.newComm(CalUtils.java:45)
>>      at
>> com.whitestein.fe.it.cal.AbstractCalTest.setUp(AbstractCalTest.java:
>> 35)
>>      at junit.framework.TestCase.runBare(TestCase.java:125)
>>      at junit.framework.TestResult$1.protect(TestResult.java:106)
>>      at junit.framework.TestResult.runProtected(TestResult.java:124)
>>      at junit.framework.TestResult.run(TestResult.java:109)
>>      at junit.framework.TestCase.run(TestCase.java:118)
>>      at junit.framework.TestSuite.runTest(TestSuite.java:208)
>>      at junit.framework.TestSuite.run(TestSuite.java:203)
>>      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:597)
>>      at
>> org
>> .apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:
>> 213)
>>      at
>> org
>> .apache
>> .maven
>> .surefire
>> .suite
>> .AbstractDirectoryTestSuite
>> .executeTestSet(AbstractDirectoryTestSuite.java:138)
>>      at
>> org
>> .apache
>> .maven
>> .surefire
>> .suite
>> .AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
>> 125)
>>      at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
>>      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:597)
>>      at
>> org
>> .apache
>> .maven
>> .surefire
>> .booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
>>      at
>> org
>> .apache
>> .maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
>> Caused by: org.apache.openejb.OpenEJBException:
>> PolicyConfigurationFactory class not found: JACC:Error
>> PolicyConfigurationFactory : cannot find class :
>> org.apache.openejb.core.security.JaccProvider$Factory
>>      at
>> org
>> .apache
>> .openejb
>> .assembler
>> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
>> 62)
>>      at
>> org
>> .apache
>> .openejb
>> .assembler.classic.Assembler.createApplication(Assembler.java:436)
>>      ... 42 more
>> Caused by: java.lang.ClassNotFoundException: JACC:Error
>> PolicyConfigurationFactory : cannot find class :
>> org.apache.openejb.core.security.JaccProvider$Factory
>>      at
>> javax
>> .security
>> .jacc
>> .PolicyConfigurationFactory
>> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:143)
>>      at
>> org
>> .apache
>> .openejb
>> .assembler
>> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
>> 48)
>>      ... 43 more
>> Caused by: java.lang.ClassNotFoundException:
>> org.apache.openejb.core.security.JaccProvider$Factory
>>      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>      at java.security.AccessController.doPrivileged(Native Method)
>>      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>>      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
>>      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
>>      at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>>      at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
>>      at java.lang.Class.forName0(Native Method)
>>      at java.lang.Class.forName(Class.java:247)
>>      at
>> javax
>> .security
>> .jacc
>> .PolicyConfigurationFactory
>> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
>>      ... 44 more
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: ClassNotFoundException: JaccProvider$Factory

Martin Vysny-2
In reply to this post by dblevins

On Wed, 2008-01-16 at 14:16 -0800, David Blevins wrote:

> On Jan 16, 2008, at 12:15 PM, Dain Sundstrom wrote:
>
> > Caused by:  
> > java
> > .lang
> > .ClassNotFoundException:org.apache.openejb.core.security.JaccProvider
> > $Factory
> >       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> >       at java.security.AccessController.doPrivileged(Native Method)
> >       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> [...]
> >       at java.lang.Class.forName(Class.java:247)
> >       at  
> > javax
> > .security
> > .jacc
> > .PolicyConfigurationFactory
> > .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
> >       ... 44 more
> >
> > But, if you look at our spec code for  
> > javax.security.jacc.PolicyConfigurationFactory, there is no code on  
> > line 131, and after browsing the full history of that file, there  
> > has never been a call to Class.forName on line 247.  Do you have a  
> > second (possibly one from Sun), implementation of the JACC spec in  
> > your lib directory or one of your applications?
>
> That's an interesting possibility.  Could be there is another jar in  
> your classpath providing the jacc api and it randomly ends up before  
> ours (and presumably it's blowing up in it's static initializer).
>
> Looks like you're in maven2/surefire when this happens.  It should be  
> possible to get a list of the jars in your classpath via the code I  
> posted earlier (surefire's classloader is a subclass of  
> URLClassLoader).  Then you should be able to look in them and see how  
> many copies copy of javax/security/jacc/
> PolicyConfigurationFactory.class you have.
>
> I've got a script for grepping through jars that might be handy:
>    http://docs.codehaus.org/display/ninja/grepjar
>
> -David
>
Hi all,
  thanks again, you were right! There was javaee-1.4.jar in the
classpath along with geronimo-jacc implementation. When we removed
javaee-1.4.jar from classpath, OpenEJB started succesfully.
  It was quite an interesting bug though, because on computer A it
worked even with javaee-1.4 on classpath (regardless of whether javaee
was first or last on the classpath), on computer B it failed. Perhaps
some classloader caused it - I don't know for sure. However, to fix this
issue just remove javaee (or other non-OpenEJB/Geronimo JACC
implementation) from classpath.

> > On Jan 16, 2008, at 1:34 AM, Martin Vysny wrote:
> >
> >> Hi guys,
> >> can you please help me with this one? Rarely, the OpenEJB startup
> >> fails with the exception ClassNotFoundException: JaccProvider$Factory
> >> (full stacktrace is below). The interesting point is, that you can  
> >> just
> >> rerun the OpenEJB and the server would start normally. We are using
> >> OpenEJB 3.0-beta-1, and I could swear that the
> >> org.apache.openejb.core.security.JaccProvider$Factory is on the
> >> classpath. We are using java6 x86 on linux:
> >> java version "1.6.0_03"
> >> Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
> >> Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
> >> We are not using any special classloader hierarchy (well, not before
> >> OpenEJB is fully started). Perhaps a java bug?
> >> Thanks!
> >> Martin
> >>
> >>
> >> PolicyConfigurationFactory class not found: JACC:Error
> >> PolicyConfigurationFactory : cannot find class :
> >> org.apache.openejb.core.security.JaccProvider$Factory
> >>       at
> >> org
> >> .apache
> >> .openejb
> >> .assembler.classic.Assembler.createApplication(Assembler.java:558)
> >>       at
> >> org
> >> .apache
> >> .openejb
> >> .assembler.classic.Assembler.buildContainerSystem(Assembler.java:299)
> >>       at
> >> org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:
> >> 207)
> >>       at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:149)
> >>       at org.apache.openejb.OpenEJB.init(OpenEJB.java:293)
> >>       at org.apache.openejb.OpenEJB.init(OpenEJB.java:272)
> >>       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:597)
> >>       at
> >> org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:
> >> 36)
> >>       at
> >> org
> >> .apache
> >> .openejb
> >> .client
> >> .LocalInitialContextFactory.init(LocalInitialContextFactory.java:59)
> >>       at
> >> org
> >> .apache
> >> .openejb
> >> .client
> >> .LocalInitialContextFactory
> >> .getInitialContext(LocalInitialContextFactory.java:45)
> >>       at
> >> javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
> >> 667)
> >>       at
> >> javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:
> >> 288)
> >>       at javax.naming.InitialContext.init(InitialContext.java:223)
> >>       at javax.naming.InitialContext.<init>(InitialContext.java:197)
> >>       at
> >> com
> >> .whitestein
> >> .fe
> >> .embedded
> >> .launcher
> >> .OpenEjbAndJettyLauncher.initOpenEJB(OpenEjbAndJettyLauncher.java:
> >> 223)
> >>       at
> >> com
> >> .whitestein
> >> .fe
> >> .embedded
> >> .launcher
> >> .OpenEjbAndJettyLauncher.launch(OpenEjbAndJettyLauncher.java:146)
> >>       at
> >> com.whitestein.fe.embedded.launcher.Launcher.launch(Launcher.java:
> >> 107)
> >>       at com.whitestein.fe.it.cal.CalUtils.newComm(CalUtils.java:45)
> >>       at
> >> com.whitestein.fe.it.cal.AbstractCalTest.setUp(AbstractCalTest.java:
> >> 35)
> >>       at junit.framework.TestCase.runBare(TestCase.java:125)
> >>       at junit.framework.TestResult$1.protect(TestResult.java:106)
> >>       at junit.framework.TestResult.runProtected(TestResult.java:124)
> >>       at junit.framework.TestResult.run(TestResult.java:109)
> >>       at junit.framework.TestCase.run(TestCase.java:118)
> >>       at junit.framework.TestSuite.runTest(TestSuite.java:208)
> >>       at junit.framework.TestSuite.run(TestSuite.java:203)
> >>       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:597)
> >>       at
> >> org
> >> .apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:
> >> 213)
> >>       at
> >> org
> >> .apache
> >> .maven
> >> .surefire
> >> .suite
> >> .AbstractDirectoryTestSuite
> >> .executeTestSet(AbstractDirectoryTestSuite.java:138)
> >>       at
> >> org
> >> .apache
> >> .maven
> >> .surefire
> >> .suite
> >> .AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
> >> 125)
> >>       at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
> >>       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:597)
> >>       at
> >> org
> >> .apache
> >> .maven
> >> .surefire
> >> .booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
> >>       at
> >> org
> >> .apache
> >> .maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
> >> Caused by: org.apache.openejb.OpenEJBException:
> >> PolicyConfigurationFactory class not found: JACC:Error
> >> PolicyConfigurationFactory : cannot find class :
> >> org.apache.openejb.core.security.JaccProvider$Factory
> >>       at
> >> org
> >> .apache
> >> .openejb
> >> .assembler
> >> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
> >> 62)
> >>       at
> >> org
> >> .apache
> >> .openejb
> >> .assembler.classic.Assembler.createApplication(Assembler.java:436)
> >>       ... 42 more
> >> Caused by: java.lang.ClassNotFoundException: JACC:Error
> >> PolicyConfigurationFactory : cannot find class :
> >> org.apache.openejb.core.security.JaccProvider$Factory
> >>       at
> >> javax
> >> .security
> >> .jacc
> >> .PolicyConfigurationFactory
> >> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:143)
> >>       at
> >> org
> >> .apache
> >> .openejb
> >> .assembler
> >> .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
> >> 48)
> >>       ... 43 more
> >> Caused by: java.lang.ClassNotFoundException:
> >> org.apache.openejb.core.security.JaccProvider$Factory
> >>       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> >>       at java.security.AccessController.doPrivileged(Native Method)
> >>       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> >>       at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> >>       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:
> >> 276)
> >>       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> >>       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:
> >> 319)
> >>       at java.lang.Class.forName0(Native Method)
> >>       at java.lang.Class.forName(Class.java:247)
> >>       at
> >> javax
> >> .security
> >> .jacc
> >> .PolicyConfigurationFactory
> >> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
> >>       ... 44 more
> >>
> >
> >
>
>
--
Mgr. Martin Vysny | [hidden email]
Software Engineer
Whitestein Technologies s.r.o | www.whitestein.com
Panenska 28 | 811 03 Bratislava | Slovak Republic
Main +421 2 5443-5502 | Direct +421 2 5930-0717


signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ClassNotFoundException: JaccProvider$Factory

Martin Vysny-2
In reply to this post by dblevins

On Wed, 2008-01-16 at 12:30 -0800, David Blevins wrote:

> On Jan 16, 2008, at 1:34 AM, Martin Vysny wrote:
>
> > Hi guys,
> > can you please help me with this one? Rarely, the OpenEJB startup
> > fails with the exception ClassNotFoundException: JaccProvider$Factory
> > (full stacktrace is below). The interesting point is, that you can  
> > just
> > rerun the OpenEJB and the server would start normally. We are using
> > OpenEJB 3.0-beta-1, and I could swear that the
> > org.apache.openejb.core.security.JaccProvider$Factory is on the
> > classpath. We are using java6 x86 on linux:
> > java version "1.6.0_03"
> > Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
> > Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
> > We are not using any special classloader hierarchy (well, not before
> > OpenEJB is fully started). Perhaps a java bug?
>
>
> That's pretty strange.  My only guess is that the Thread context  
> classloader is getting changed to something else (seemingly randomly)  
> and the factory class becomes no longer visible.  I've implemented  
> this particular fix forces it to load earlier and forces a specific  
> classloader when using our default factory:
> http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java?r1=612547&r2=612546&pathrev=612547
>
> We could test this theory out on the code you have now if you catch  
> the exception you posted below and in the catch clause do something  
> like this:
>
>         ClassLoader classLoader =  
> Thread.currentThread().getContextClassLoader();
>         System.out.println("classLoader" + classLoader);
>         System.out.println("classLoader.class" +  
> classLoader.getClass().getName());
>         if (classLoader instanceof URLClassLoader) {
>             URLClassLoader urlClassLoader = (URLClassLoader)  
> classLoader;
>             URL[] urls = urlClassLoader.getURLs();
>             for (URL url : urls) {
>                 System.out.println("url = " + url.toExternalForm());
>             }
>         }
>
> -David
>
Hi David,
  thanks for your interest. The bug is fixed so this is probably no
longer relevant. Just out of curiosity I put this code into
catch(Exception) clausule where OpenEJB was initialized, and I got
"classLoader.classorg.apache.maven.surefire.booter.IsolatedClassLoader"
classloader, followed by a bunch of "url = ...". When I tried to put it
into the static {} block the same classloader was reported. This is what
I expected - if you do some classloader magic while loading JACC, you
probably restore old classloader in the finally{} statement. Anyway,
thanks for your help guys!
Martin

>
> > PolicyConfigurationFactory class not found: JACC:Error
> > PolicyConfigurationFactory : cannot find class :
> > org.apache.openejb.core.security.JaccProvider$Factory
> >       at
> > org
> > .apache
> > .openejb
> > .assembler.classic.Assembler.createApplication(Assembler.java:558)
> >       at
> > org
> > .apache
> > .openejb
> > .assembler.classic.Assembler.buildContainerSystem(Assembler.java:299)
> >       at
> > org.apache.openejb.assembler.classic.Assembler.build(Assembler.java:
> > 207)
> >       at org.apache.openejb.OpenEJB$Instance.<init>(OpenEJB.java:149)
> >       at org.apache.openejb.OpenEJB.init(OpenEJB.java:293)
> >       at org.apache.openejb.OpenEJB.init(OpenEJB.java:272)
> >       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:597)
> >       at
> > org.apache.openejb.loader.OpenEJBInstance.init(OpenEJBInstance.java:
> > 36)
> >       at
> > org
> > .apache
> > .openejb
> > .client
> > .LocalInitialContextFactory.init(LocalInitialContextFactory.java:59)
> >       at
> > org
> > .apache
> > .openejb
> > .client
> > .LocalInitialContextFactory
> > .getInitialContext(LocalInitialContextFactory.java:45)
> >       at
> > javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:
> > 667)
> >       at
> > javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
> >       at javax.naming.InitialContext.init(InitialContext.java:223)
> >       at javax.naming.InitialContext.<init>(InitialContext.java:197)
> >       at
> > com
> > .whitestein
> > .fe
> > .embedded
> > .launcher
> > .OpenEjbAndJettyLauncher.initOpenEJB(OpenEjbAndJettyLauncher.java:223)
> >       at
> > com
> > .whitestein
> > .fe
> > .embedded
> > .launcher
> > .OpenEjbAndJettyLauncher.launch(OpenEjbAndJettyLauncher.java:146)
> >       at
> > com.whitestein.fe.embedded.launcher.Launcher.launch(Launcher.java:107)
> >       at com.whitestein.fe.it.cal.CalUtils.newComm(CalUtils.java:45)
> >       at
> > com.whitestein.fe.it.cal.AbstractCalTest.setUp(AbstractCalTest.java:
> > 35)
> >       at junit.framework.TestCase.runBare(TestCase.java:125)
> >       at junit.framework.TestResult$1.protect(TestResult.java:106)
> >       at junit.framework.TestResult.runProtected(TestResult.java:124)
> >       at junit.framework.TestResult.run(TestResult.java:109)
> >       at junit.framework.TestCase.run(TestCase.java:118)
> >       at junit.framework.TestSuite.runTest(TestSuite.java:208)
> >       at junit.framework.TestSuite.run(TestSuite.java:203)
> >       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:597)
> >       at
> > org
> > .apache.maven.surefire.junit.JUnitTestSet.execute(JUnitTestSet.java:
> > 213)
> >       at
> > org
> > .apache
> > .maven
> > .surefire
> > .suite
> > .AbstractDirectoryTestSuite
> > .executeTestSet(AbstractDirectoryTestSuite.java:138)
> >       at
> > org
> > .apache
> > .maven
> > .surefire
> > .suite
> > .AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:
> > 125)
> >       at org.apache.maven.surefire.Surefire.run(Surefire.java:132)
> >       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:597)
> >       at
> > org
> > .apache
> > .maven
> > .surefire
> > .booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:290)
> >       at
> > org
> > .apache
> > .maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:818)
> > Caused by: org.apache.openejb.OpenEJBException:
> > PolicyConfigurationFactory class not found: JACC:Error
> > PolicyConfigurationFactory : cannot find class :
> > org.apache.openejb.core.security.JaccProvider$Factory
> >       at
> > org
> > .apache
> > .openejb
> > .assembler
> > .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
> > 62)
> >       at
> > org
> > .apache
> > .openejb
> > .assembler.classic.Assembler.createApplication(Assembler.java:436)
> >       ... 42 more
> > Caused by: java.lang.ClassNotFoundException: JACC:Error
> > PolicyConfigurationFactory : cannot find class :
> > org.apache.openejb.core.security.JaccProvider$Factory
> >       at
> > javax
> > .security
> > .jacc
> > .PolicyConfigurationFactory
> > .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:143)
> >       at
> > org
> > .apache
> > .openejb
> > .assembler
> > .classic.JaccPermissionsBuilder.install(JaccPermissionsBuilder.java:
> > 48)
> >       ... 43 more
> > Caused by: java.lang.ClassNotFoundException:
> > org.apache.openejb.core.security.JaccProvider$Factory
> >       at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> >       at java.security.AccessController.doPrivileged(Native Method)
> >       at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> >       at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
> >       at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
> >       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
> >       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
> >       at java.lang.Class.forName0(Native Method)
> >       at java.lang.Class.forName(Class.java:247)
> >       at
> > javax
> > .security
> > .jacc
> > .PolicyConfigurationFactory
> > .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
> >       ... 44 more
> >
>
>
--
Mgr. Martin Vysny | [hidden email]
Software Engineer
Whitestein Technologies s.r.o | www.whitestein.com
Panenska 28 | 811 03 Bratislava | Slovak Republic
Main +421 2 5443-5502 | Direct +421 2 5930-0717


signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ClassNotFoundException: JaccProvider$Factory

dblevins
Administrator
In reply to this post by Martin Vysny-2

On Jan 21, 2008, at 7:19 AM, Martin Vysny wrote:

>
> On Wed, 2008-01-16 at 14:16 -0800, David Blevins wrote:
>> On Jan 16, 2008, at 12:15 PM, Dain Sundstrom wrote:
>>
>>> Caused by:
>>> java
>>> .lang
>>> .ClassNotFoundException:org
>>> .apache.openejb.core.security.JaccProvider
>>> $Factory
>>>      at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>>>      at java.security.AccessController.doPrivileged(Native Method)
>>>      at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>> [...]
>>>      at java.lang.Class.forName(Class.java:247)
>>>      at
>>> javax
>>> .security
>>> .jacc
>>> .PolicyConfigurationFactory
>>> .getPolicyConfigurationFactory(PolicyConfigurationFactory.java:131)
>>>      ... 44 more
>>>
>>> But, if you look at our spec code for
>>> javax.security.jacc.PolicyConfigurationFactory, there is no code on
>>> line 131, and after browsing the full history of that file, there
>>> has never been a call to Class.forName on line 247.  Do you have a
>>> second (possibly one from Sun), implementation of the JACC spec in
>>> your lib directory or one of your applications?
>>
>> That's an interesting possibility.  Could be there is another jar in
>> your classpath providing the jacc api and it randomly ends up before
>> ours (and presumably it's blowing up in it's static initializer).
>>
>> Looks like you're in maven2/surefire when this happens.  It should be
>> possible to get a list of the jars in your classpath via the code I
>> posted earlier (surefire's classloader is a subclass of
>> URLClassLoader).  Then you should be able to look in them and see how
>> many copies copy of javax/security/jacc/
>> PolicyConfigurationFactory.class you have.
>>
>> I've got a script for grepping through jars that might be handy:
>>   http://docs.codehaus.org/display/ninja/grepjar
>>
>> -David
>>
>
> Hi all,
>  thanks again, you were right! There was javaee-1.4.jar in the
> classpath along with geronimo-jacc implementation. When we removed
> javaee-1.4.jar from classpath, OpenEJB started succesfully.
>  It was quite an interesting bug though, because on computer A it
> worked even with javaee-1.4 on classpath (regardless of whether javaee
> was first or last on the classpath), on computer B it failed. Perhaps
> some classloader caused it - I don't know for sure. However, to fix  
> this
> issue just remove javaee (or other non-OpenEJB/Geronimo JACC
> implementation) from classpath.

Maven doesn't behave consistently from one computer to another in  
terms of the order it processes the dependencies.  I think it must be  
using a HashMap (or similar collection where order is not guaranteed)  
to hold the deps while doing it's include/exclude and other sort of  
processing.  We had a similar issue in our JAXB tree for the ejb-
jar.xml data.  We were keeping the resulting EnterpriseBean jaxb  
objects in a HashMap and then the order in which they'd be written to  
xml was randomly breaking tests for some people sometimes.  We  
switched it to use TreeMap instead and the problem disappeared.

> When I tried to put it
> into the static {} block the same classloader was reported. This is  
> what
> I expected - if you do some classloader magic while loading JACC, you
> probably restore old classloader in the finally{} statement.

This is good.  It seemed less likely that this was the issue, but you  
never know.  After your report I did add some classloader swap/restore  
around the JACC loading code in the case that the impl is ours -- I  
grab our impl java.lang.Class and set it's classloader before we ask  
JACC to load the factory.  Won't affect your scenario as it was a  
classpath issue, but I figured the problem could still occur if  
someone did swap the thread classloader and didn't swap it back (or  
had a library they called that did that).

Anyway, glad to hear things are working well!

-David