You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Rafael Marins <ra...@neociclo.com> on 2010/12/28 06:53:22 UTC

Problem reusing JAAS login modules

Hi,

When using the PropertiesLoginModule from a blueprint file in my bundle located at the /OSGI-INF/blueprint/ folder, I've encountered problem with ClassNotFoundException. But I can get it working properly when deploying the blueprint xml into the /deploy/ folder.

Check the logging stack trace here: http://pastebin.com/yFiKkpg3 (at line 57)

From my blueprint file: accord-jaas-module.xml

  ...
   <jaas:config name="accord">
    <jaas:module className="org.apache.karaf.jaas.modules.properties.PropertiesLoginModule" 
                 flags="required">
        users = $[karaf.base]/etc/accord-users.properties
        debug = true
    </jaas:module>
  </jaas:config>
  ...

Any ideas on what must be done to solve this problem? 

--
Rafael Marins





Re: Problem reusing JAAS login modules

Posted by Charles Moulliard <cm...@gmail.com>.
Hi,

As mentioned in your log, you have a classloading issue :

Caused by: java.lang.ClassNotFoundException:
org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
	at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:772)

reported by org.jboss.netty.

Be carefull, when you start OSGI project in a J2EE application server
! The classloading mechanism are not the same.

Regards,

Charles Moulliard

Sr. Principal Solution Architect - FuseSource
Apache Committer

Blog : http://cmoulliard.blogspot.com
Twitter : http://twitter.com/cmoulliard
Linkedin : http://www.linkedin.com/in/charlesmoulliard
Skype: cmoulliard



On Tue, Dec 28, 2010 at 6:53 AM, Rafael Marins
<ra...@neociclo.com> wrote:
> Hi,
> When using the PropertiesLoginModule from a blueprint file in my bundle
> located at the /OSGI-INF/blueprint/ folder, I've encountered problem with
> ClassNotFoundException. But I can get it working properly when deploying the
> blueprint xml into the /deploy/ folder.
> Check the logging stack trace here: http://pastebin.com/yFiKkpg3 (at line
> 57)
> From my blueprint file: accord-jaas-module.xml
>   ...
>    <jaas:config name="accord">
>     <jaas:module
> className="org.apache.karaf.jaas.modules.properties.PropertiesLoginModule"
>                  flags="required">
>         users = $[karaf.base]/etc/accord-users.properties
>         debug = true
>     </jaas:module>
>   </jaas:config>
>   ...
> Any ideas on what must be done to solve this problem?
> --
> Rafael Marins
>
>
>
>

Re: Problem reusing JAAS login modules

Posted by Rafael Marins <ra...@neociclo.com>.
Hi Guillaume,

When dropped into the deploy/ folder, the deployer is adding Karaf JAAS Config and OSGI Blueprint Services imports, as paste below:

Imported Packages (accord-jaas-module.xml - from webconsole)

	org.apache.aries.blueprint,version=0.2.0.incubating from org.apache.aries.blueprint (7)
	org.apache.aries.blueprint.ext,version=0.2.0.incubating from org.apache.aries.blueprint (7)
	org.apache.camel,version=2.5.0 from org.apache.camel.camel-core (183)
	org.apache.camel.spi,version=2.5.0 from org.apache.camel.camel-core (183)
	org.apache.karaf.jaas.config,version=2.1.2 from org.apache.karaf.jaas.config (8)
	org.apache.karaf.jaas.config.impl,version=2.1.2 from org.apache.karaf.jaas.config (8)
	org.osgi.service.blueprint.container,version=1.0.1 from org.apache.aries.blueprint (7)

But when the blueprint file is processed from within my bundle, in the OSGI-INF/blueprint/ folder, only the OSGI Blueprint Service were added:

Imported Packages (org.neociclo.accord.server.server-core bundle - from webconsole)

	javax.security.auth,version=0.0.0 from org.apache.felix.framework (0)
	javax.security.auth.callback,version=0.0.0 from org.apache.felix.framework (0)
	javax.security.auth.login,version=0.0.0 from org.apache.felix.framework (0)
	javax.security.auth.spi,version=0.0.0 from org.apache.felix.framework (0)
	org.osgi.service.blueprint,version=1.0.1 from org.apache.aries.blueprint (7)


Best regards,
--
Rafael Marins




On Dec 28, 2010, at 8:15 AM, Guillaume Nodet wrote:

> It's certainly a missing import package.  When drpped into the deploy
> folder, the deployer will automatically add the required import
> packages.


Re: Problem reusing JAAS login modules

Posted by Guillaume Nodet <gn...@gmail.com>.
It's certainly a missing import package.  When drpped into the deploy
folder, the deployer will automatically add the required import
packages.

On Tuesday, December 28, 2010, Rafael Marins <ra...@neociclo.com> wrote:
> Hi,
> When using the PropertiesLoginModule from a blueprint file in my bundle located at the /OSGI-INF/blueprint/ folder, I've encountered problem with ClassNotFoundException. But I can get it working properly when deploying the blueprint xml into the /deploy/ folder.
> Check the logging stack trace here: http://pastebin.com/yFiKkpg3 (at line 57)
> From my blueprint file: accord-jaas-module.xml
>   ...   <jaas:config name="accord">    <jaas:module className="org.apache.karaf.jaas.modules.properties.PropertiesLoginModule"                  flags="required">        users = $[karaf.base]/etc/accord-users.properties        debug = true    </jaas:module>  </jaas:config>  ...
> Any ideas on what must be done to solve this problem?
> --Rafael Marins
>
>
>
>
>

-- 
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Re: Problem reusing JAAS login modules

Posted by Rafael Marins <ra...@neociclo.com>.
Hi Andreas,

Filled the issue KARAF-344 to report and track the problem.

Best,
--
Rafael Marins



On Dec 28, 2010, at 4:28 PM, Rafael Marins wrote:

> Hi Andreas,
> 
> I've prepared the attached project to test this behavior. You can build and simply follow the steps:
> 
> karaf@root> osgi:install \-s mvn:org.neociclo.samples.karaf/jaas-config-requires-restart/1.0-SNAPSHOT
> Bundle ID: 330
> karaf@root> nc:jaaslogin user pwd
> org.osgi.service.blueprint.container.ServiceUnavailableException: Service is unavailable
> 	at org.apache.aries.blueprint.container.ReferenceListRecipe$ServiceDispatcher.call(ReferenceListRecipe.java:201)
> 	at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe$CgLibProxyFactory$1.loadObject(AbstractServiceReferenceRecipe.java:652)
> 	at org.apache.karaf.jaas.config.JaasRealm$$EnhancerByCGLIB$$59154.getName(<generated>)
> 	at org.apache.karaf.jaas.config.impl.OsgiConfiguration.getAppConfigurationEntry(OsgiConfiguration.java:52)
> 	at javax.security.auth.login.LoginContext.init(LoginContext.java:243)
> 	at javax.security.auth.login.LoginContext.<init>(LoginContext.java:367)
> 	at javax.security.auth.login.LoginContext.<init>(LoginContext.java:444)
> 	at org.neociclo.samples.karaf.JaasLoginShellCommand.doExecute(JaasLoginShellCommand.java:41)
> 	at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
> 	at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
> 	at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:50)
> 	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)
> 	at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)
> 	at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)
> 	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)
> 	at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)
> 	at org.apache.karaf.shell.console.jline.Console.run(Console.java:169)
> 	at java.lang.Thread.run(Thread.java:680)
> Failed to load LoginContext for realm=nctestkaraf@root> shutdown
> 
> localhost:karaf rmarins$ ./bin/karaf 
>         __ __                  ____      
>        / //_/____ __________ _/ __/      
>       / ,<  / __ `/ ___/ __ `/ /_        
>      / /| |/ /_/ / /  / /_/ / __/        
>     /_/ |_|\__,_/_/   \__,_/_/         
> 
>   Apache Karaf (2.1.2)
> 
> Hit '<tab>' for a list of available commands
> and '[cmd] --help' for help on a specific command.
> Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown Karaf.
> 
> karaf@root> nc:jaaslogin user pwd
> javax.security.auth.login.FailedLoginException: User user does not exist
> 	at org.apache.karaf.jaas.modules.properties.PropertiesLoginModule.login(PropertiesLoginModule.java:97)
> 	at org.apache.karaf.jaas.boot.ProxyLoginModule.login(ProxyLoginModule.java:83)
> 	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 javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
> 	at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
> 	at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
> 	at java.security.AccessController.doPrivileged(Native Method)
> 	at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
> 	at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
> 	at org.neociclo.samples.karaf.JaasLoginShellCommand.doExecute(JaasLoginShellCommand.java:61)
> 	at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
> 	at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
> 	at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:50)
> 	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)
> 	at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)
> 	at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)
> 	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)
> 	at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)
> 	at org.apache.karaf.shell.console.jline.Console.run(Console.java:169)
> 	at java.lang.Thread.run(Thread.java:680)
> Login failed
> 
> karaf@root> nc:jaaslogin karaf karaf
> Login succeed for realm=nctest, user=karaf
> 
> karaf@root>
> <jaas-config-requires-restart.zip>
> Best regards,
> --
> Rafael Marins
> 
> 
> 
> 
> On Dec 28, 2010, at 2:56 PM, Andreas Pieber wrote:
> 
>> Not ad-hoc, but if you can provide a very simple example to reproduce the
>> problem and create an issue for it I can take a look at it.
>> 
>> kind regards,
>> andreas
> 


Re: Problem reusing JAAS login modules

Posted by Rafael Marins <ra...@neociclo.com>.
Hi Andreas,

I've prepared the attached project to test this behavior. You can build and simply follow the steps:

karaf@root> osgi:install \-s mvn:org.neociclo.samples.karaf/jaas-config-requires-restart/1.0-SNAPSHOT
Bundle ID: 330
karaf@root> nc:jaaslogin user pwd
org.osgi.service.blueprint.container.ServiceUnavailableException: Service is unavailable
	at org.apache.aries.blueprint.container.ReferenceListRecipe$ServiceDispatcher.call(ReferenceListRecipe.java:201)
	at org.apache.aries.blueprint.container.AbstractServiceReferenceRecipe$CgLibProxyFactory$1.loadObject(AbstractServiceReferenceRecipe.java:652)
	at org.apache.karaf.jaas.config.JaasRealm$$EnhancerByCGLIB$$59154.getName(<generated>)
	at org.apache.karaf.jaas.config.impl.OsgiConfiguration.getAppConfigurationEntry(OsgiConfiguration.java:52)
	at javax.security.auth.login.LoginContext.init(LoginContext.java:243)
	at javax.security.auth.login.LoginContext.<init>(LoginContext.java:367)
	at javax.security.auth.login.LoginContext.<init>(LoginContext.java:444)
	at org.neociclo.samples.karaf.JaasLoginShellCommand.doExecute(JaasLoginShellCommand.java:41)
	at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
	at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
	at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:50)
	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)
	at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)
	at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)
	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)
	at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)
	at org.apache.karaf.shell.console.jline.Console.run(Console.java:169)
	at java.lang.Thread.run(Thread.java:680)
Failed to load LoginContext for realm=nctestkaraf@root> shutdown

localhost:karaf rmarins$ ./bin/karaf 
        __ __                  ____      
       / //_/____ __________ _/ __/      
      / ,<  / __ `/ ___/ __ `/ /_        
     / /| |/ /_/ / /  / /_/ / __/        
    /_/ |_|\__,_/_/   \__,_/_/         

  Apache Karaf (2.1.2)

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.
Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown Karaf.

karaf@root> nc:jaaslogin user pwd
javax.security.auth.login.FailedLoginException: User user does not exist
	at org.apache.karaf.jaas.modules.properties.PropertiesLoginModule.login(PropertiesLoginModule.java:97)
	at org.apache.karaf.jaas.boot.ProxyLoginModule.login(ProxyLoginModule.java:83)
	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 javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
	at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
	at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
	at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
	at org.neociclo.samples.karaf.JaasLoginShellCommand.doExecute(JaasLoginShellCommand.java:61)
	at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:38)
	at org.apache.felix.gogo.commands.basic.AbstractCommand.execute(AbstractCommand.java:35)
	at org.apache.felix.gogo.runtime.shell.CommandProxy.execute(CommandProxy.java:50)
	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:229)
	at org.apache.felix.gogo.runtime.shell.Closure.executeStatement(Closure.java:162)
	at org.apache.felix.gogo.runtime.shell.Pipe.run(Pipe.java:101)
	at org.apache.felix.gogo.runtime.shell.Closure.execute(Closure.java:79)
	at org.apache.felix.gogo.runtime.shell.CommandSessionImpl.execute(CommandSessionImpl.java:71)
	at org.apache.karaf.shell.console.jline.Console.run(Console.java:169)
	at java.lang.Thread.run(Thread.java:680)
Login failed

karaf@root> nc:jaaslogin karaf karaf
Login succeed for realm=nctest, user=karaf

karaf@root>

Best regards,
--
Rafael Marins




On Dec 28, 2010, at 2:56 PM, Andreas Pieber wrote:

> Not ad-hoc, but if you can provide a very simple example to reproduce the
> problem and create an issue for it I can take a look at it.
> 
> kind regards,
> andreas


Re: Problem reusing JAAS login modules

Posted by Andreas Pieber <an...@gmail.com>.
Not ad-hoc, but if you can provide a very simple example to reproduce the
problem and create an issue for it I can take a look at it.

kind regards,
andreas

On Tue, Dec 28, 2010 at 02:52:21PM -0200, Rafael Marins wrote:
> Hi Andreas,
> 
> Changing the imports to meet the specific package just worked for my bundle, which encompass both the jaas configuration blueprint xml and the oftp-context.xml with Camel routes. Thanks everybody!!!
> 
> What did the trick was simply the:
> 
>     <accord.osgi.import.additional>
>       org.apache.karaf.jaas.modules.properties;version="[2.1.2,3)"
>     </accord.osgi.import.additional>
> 
> 
> Although, restarting Karaf was required. The JAAS realm is not found when used after a fresh features:install accord-server. Any guess why?
> 
> Best regards,
> --
> Rafael Marins
> 
> 
> 
> 
> On Dec 28, 2010, at 10:24 AM, Andreas Pieber wrote:
> 
> > your pom looks ok so far... The imports * is not taken into account (not sure y) but the
> > easiest solution is to
> > 
> > 1) put your blueprint into deploy
> > 2) get all imported packages
> > 3) explicitly add those packages as imports (do not use *) (e.g. use
> > XXXX.karaf.config and XXX.karaf.config.impl, ...).
> > 
> > This should do the trick
> > 
> > kind regards,
> > andreas
> 

Re: Problem reusing JAAS login modules

Posted by Rafael Marins <ra...@neociclo.com>.
Hi Andreas,

Changing the imports to meet the specific package just worked for my bundle, which encompass both the jaas configuration blueprint xml and the oftp-context.xml with Camel routes. Thanks everybody!!!

What did the trick was simply the:

    <accord.osgi.import.additional>
      org.apache.karaf.jaas.modules.properties;version="[2.1.2,3)"
    </accord.osgi.import.additional>


Although, restarting Karaf was required. The JAAS realm is not found when used after a fresh features:install accord-server. Any guess why?

Best regards,
--
Rafael Marins




On Dec 28, 2010, at 10:24 AM, Andreas Pieber wrote:

> your pom looks ok so far... The imports * is not taken into account (not sure y) but the
> easiest solution is to
> 
> 1) put your blueprint into deploy
> 2) get all imported packages
> 3) explicitly add those packages as imports (do not use *) (e.g. use
> XXXX.karaf.config and XXX.karaf.config.impl, ...).
> 
> This should do the trick
> 
> kind regards,
> andreas


Re: Problem reusing JAAS login modules

Posted by Andreas Pieber <an...@gmail.com>.
your pom looks ok so far... The imports * is not taken into account (not sure y) but the
easiest solution is to

1) put your blueprint into deploy
2) get all imported packages
3) explicitly add those packages as imports (do not use *) (e.g. use
XXXX.karaf.config and XXX.karaf.config.impl, ...).

This should do the trick

kind regards,
andreas

On Tue, Dec 28, 2010 at 10:12:49AM -0200, Rafael Marins wrote:
>    Hi Andreas,
> 
>    Sure, check it out here: [1]http://pastebin.com/fx9JF873
>    Best regards,
>    --
>    Rafael Marins
>    On Dec 28, 2010, at 9:43 AM, Andreas Pieber wrote:
> 
>      Can you upload the effective pom for
>      org.neociclo.accord.server.server-core [1]?
>      kind regards,
>      andreas
>      [1] [2]http://maven.apache.org/plugins/maven-help-plugin/effective-p
>      om-mojo.html
> 
> References
> 
>    1. http://pastebin.com/fx9JF873
>    2. http://maven.apache.org/plugins/maven-help-plugin/effective-pom-mojo.html

Re: Problem reusing JAAS login modules

Posted by Rafael Marins <ra...@neociclo.com>.
Hi Andreas,

Sure, check it out here: http://pastebin.com/fx9JF873

Best regards,
--
Rafael Marins




On Dec 28, 2010, at 9:43 AM, Andreas Pieber wrote:

> Can you upload the effective pom for org.neociclo.accord.server.server-core [1]?
> 
> kind regards,
> andreas
> 
> [1] http://maven.apache.org/plugins/maven-help-plugin/effective-pom-mojo.html


Re: Problem reusing JAAS login modules

Posted by Andreas Pieber <an...@gmail.com>.
Can you upload the effective pom for org.neociclo.accord.server.server-core [1]?

kind regards,
andreas

[1] http://maven.apache.org/plugins/maven-help-plugin/effective-pom-mojo.html

On Tue, Dec 28, 2010 at 09:40:53AM -0200, Rafael Marins wrote:
>    Hi Andreas,
> 
>    There is
>    a <accord.osgi.import>${accord.osgi.import.pkg}</accord.osgi.import>...
>    almost the same result.
> 
>    Best regards,
>    --
>    Rafael Marins
>    On Dec 28, 2010, at 9:32 AM, Andreas Pieber wrote:
> 
>      maybe I'm blind, but shouldn't this line:
>      <Import-Package>${accord.osgi.import}</Import-Package>
>      look like:
>      <Import-Package>${accord.osgi.import.pkg}</Import-Package>
>      kind regards,
>      andreas

Re: Problem reusing JAAS login modules

Posted by Rafael Marins <ra...@neociclo.com>.
Hi Andreas,

There is a <accord.osgi.import>${accord.osgi.import.pkg}</accord.osgi.import>... almost the same result.

Best regards,
--
Rafael Marins




On Dec 28, 2010, at 9:32 AM, Andreas Pieber wrote:

> maybe I'm blind, but shouldn't this line:
> 
> <Import-Package>${accord.osgi.import}</Import-Package>
> 
> look like:
> 
> <Import-Package>${accord.osgi.import.pkg}</Import-Package>
> 
> 
> kind regards,
> andreas


Re: Problem reusing JAAS login modules

Posted by Andreas Pieber <an...@gmail.com>.
maybe I'm blind, but shouldn't this line:

<Import-Package>${accord.osgi.import}</Import-Package>

look like:

<Import-Package>${accord.osgi.import.pkg}</Import-Package>


kind regards,
andreas

On Tue, Dec 28, 2010 at 09:25:24AM -0200, Rafael Marins wrote:
> Hi JB,
> 
> Thanks everybody for all replies.
> 
> I suspected about it and included org.apache.karaf.modules.* to the bundle imports, but didn't worked. The maven-bundle-plugin simply don't put that import statement it in the Manifest as there is no Java package imports. See the pom statements:
> 
> From the org.neociclo.accord.server.server-core bundle's pom:
> 
>   <artifactId>server-core</artifactId>
>   <packaging>bundle</packaging>
>   <name>Accord Server :: Core</name>
> 
>   <properties>
>     <!-- OSGi bundle custom properties -->
>     <accord.osgi.export.pkg>
>       org.neociclo.accord.server.*
>     </accord.osgi.export.pkg>
>     <accord.osgi.private.pkg>
>       org.neociclo.accord.server.impl.*
>     </accord.osgi.private.pkg>
>     <accord.osgi.import.additional>
>       org.apache.karaf.jaas.config.*;version="[2.1.2,3)",
>       org.apache.karaf.jaas.modules.*;version="[2.1.2,3)"
>     </accord.osgi.import.additional>
>   </properties>
> 
> From the parent pom:
> 
>   <properties>
> ...
>     <accord.osgi.name>${project.name}</accord.osgi.name>
>     <accord.osgi.import.accord.version>version="[$(version;==;${accord.osgi.version.clean}),$(version;=+;${accord.osgi.version.clean}))"</accord.osgi.import.accord.version>
>     <accord.osgi.import.strict.version>version="[$(version;===;${accord.osgi.version.clean}),$(version;==+;${accord.osgi.version.clean}))"</accord.osgi.import.strict.version>
>     <accord.osgi.import.default.version>[$(version;==;$(@)),$(version;+;$(@)))</accord.osgi.import.default.version>
>     <accord.osgi.import.defaults>
>       org.springframework.*;version="[3.0,4)",
>       org.apache.camel.*;version="[2.5,3)",
>       org.slf4j.*;version="[1.5,1.6)",
>     </accord.osgi.import.defaults>
>     <accord.osgi.import.before.defaults />
>     <accord.osgi.import.additional />
>     <accord.osgi.import.pkg>
>       !${accord.osgi.export.pkg},
>       org.neociclo.accord.server.*;${accord.osgi.import.accord.version},
>       ${accord.osgi.import.before.defaults},
>       ${accord.osgi.import.defaults},
>       ${accord.osgi.import.additional},
>       *
>     </accord.osgi.import.pkg>
>     <accord.osgi.activator />
>     <accord.osgi.failok>false</accord.osgi.failok>
>     <accord.osgi.private.pkg>!*</accord.osgi.private.pkg>
>     <accord.osgi.export>${accord.osgi.export.pkg};${accord.osgi.version}</accord.osgi.export>
>     <accord.osgi.version>version=${project.version}</accord.osgi.version>
>     <accord.osgi.split.pkg>-split-package:=first</accord.osgi.split.pkg>
>     <accord.osgi.import>${accord.osgi.import.pkg}</accord.osgi.import>
>     <accord.osgi.dynamic />
>     <accord.osgi.symbolic.name>${project.groupId}.${project.artifactId}</accord.osgi.symbolic.name>
>     <accord.osgi.exclude.dependencies>false</accord.osgi.exclude.dependencies>
> ...
> 
>       <plugin>
>         <groupId>org.apache.felix</groupId>
>         <artifactId>maven-bundle-plugin</artifactId>
>         <version>${felix-version}</version>
>         <extensions>true</extensions>
>         <configuration>
>           <excludeDependencies>${accord.osgi.exclude.dependencies}</excludeDependencies>
>           <instructions>
>             <Bundle-Name>${accord.osgi.name}</Bundle-Name>
>             <Bundle-SymbolicName>${accord.osgi.symbolic.name}</Bundle-SymbolicName>
>             <Bundle-Activator>${accord.osgi.activator}</Bundle-Activator>
>             <Export-Package>${accord.osgi.export}</Export-Package>
>             <Import-Package>${accord.osgi.import}</Import-Package>
>             <DynamicImport-Package>${accord.osgi.dynamic}</DynamicImport-Package>
>             <Private-Package>${accord.osgi.private.pkg}</Private-Package>
>             <Implementation-Title>Neociclo Accord</Implementation-Title>
>             <Implementation-Version>${project.version}</Implementation-Version>
>             <_versionpolicy>${accord.osgi.import.default.version}</_versionpolicy>
>             <_failok>${accord.osgi.failok}</_failok>
>           </instructions>
>         </configuration>
>       </plugin>
> ...
> 
> 
> And it produced the MANIFEST.MF with:
> 
> Bundle-SymbolicName: org.neociclo.accord.server.server-core
> Import-Package: javax.security.auth,javax.security.auth.callback,javax
>  .security.auth.login,javax.security.auth.spi,org.osgi.service.bluepri
>  nt;version="[1.0.0,2.0.0)"
> 
> 
> 
> Best regards,
> --
> Rafael Marins
> 
> 
> 
> 
> On Dec 28, 2010, at 4:34 AM, Jean-Baptiste Onofré wrote:
> 
> > Hi Rafael,
> > 
> > it's certainly due to classloader issue. Could you paste your bundle pom to see the Import-Package statement ?
> > 
> > Regards
> > JB
> 

Re: Problem reusing JAAS login modules

Posted by Rafael Marins <ra...@neociclo.com>.
Hi JB,

Thanks everybody for all replies.

I suspected about it and included org.apache.karaf.modules.* to the bundle imports, but didn't worked. The maven-bundle-plugin simply don't put that import statement it in the Manifest as there is no Java package imports. See the pom statements:

From the org.neociclo.accord.server.server-core bundle's pom:

  <artifactId>server-core</artifactId>
  <packaging>bundle</packaging>
  <name>Accord Server :: Core</name>

  <properties>
    <!-- OSGi bundle custom properties -->
    <accord.osgi.export.pkg>
      org.neociclo.accord.server.*
    </accord.osgi.export.pkg>
    <accord.osgi.private.pkg>
      org.neociclo.accord.server.impl.*
    </accord.osgi.private.pkg>
    <accord.osgi.import.additional>
      org.apache.karaf.jaas.config.*;version="[2.1.2,3)",
      org.apache.karaf.jaas.modules.*;version="[2.1.2,3)"
    </accord.osgi.import.additional>
  </properties>

From the parent pom:

  <properties>
...
    <accord.osgi.name>${project.name}</accord.osgi.name>
    <accord.osgi.import.accord.version>version="[$(version;==;${accord.osgi.version.clean}),$(version;=+;${accord.osgi.version.clean}))"</accord.osgi.import.accord.version>
    <accord.osgi.import.strict.version>version="[$(version;===;${accord.osgi.version.clean}),$(version;==+;${accord.osgi.version.clean}))"</accord.osgi.import.strict.version>
    <accord.osgi.import.default.version>[$(version;==;$(@)),$(version;+;$(@)))</accord.osgi.import.default.version>
    <accord.osgi.import.defaults>
      org.springframework.*;version="[3.0,4)",
      org.apache.camel.*;version="[2.5,3)",
      org.slf4j.*;version="[1.5,1.6)",
    </accord.osgi.import.defaults>
    <accord.osgi.import.before.defaults />
    <accord.osgi.import.additional />
    <accord.osgi.import.pkg>
      !${accord.osgi.export.pkg},
      org.neociclo.accord.server.*;${accord.osgi.import.accord.version},
      ${accord.osgi.import.before.defaults},
      ${accord.osgi.import.defaults},
      ${accord.osgi.import.additional},
      *
    </accord.osgi.import.pkg>
    <accord.osgi.activator />
    <accord.osgi.failok>false</accord.osgi.failok>
    <accord.osgi.private.pkg>!*</accord.osgi.private.pkg>
    <accord.osgi.export>${accord.osgi.export.pkg};${accord.osgi.version}</accord.osgi.export>
    <accord.osgi.version>version=${project.version}</accord.osgi.version>
    <accord.osgi.split.pkg>-split-package:=first</accord.osgi.split.pkg>
    <accord.osgi.import>${accord.osgi.import.pkg}</accord.osgi.import>
    <accord.osgi.dynamic />
    <accord.osgi.symbolic.name>${project.groupId}.${project.artifactId}</accord.osgi.symbolic.name>
    <accord.osgi.exclude.dependencies>false</accord.osgi.exclude.dependencies>
...

      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>${felix-version}</version>
        <extensions>true</extensions>
        <configuration>
          <excludeDependencies>${accord.osgi.exclude.dependencies}</excludeDependencies>
          <instructions>
            <Bundle-Name>${accord.osgi.name}</Bundle-Name>
            <Bundle-SymbolicName>${accord.osgi.symbolic.name}</Bundle-SymbolicName>
            <Bundle-Activator>${accord.osgi.activator}</Bundle-Activator>
            <Export-Package>${accord.osgi.export}</Export-Package>
            <Import-Package>${accord.osgi.import}</Import-Package>
            <DynamicImport-Package>${accord.osgi.dynamic}</DynamicImport-Package>
            <Private-Package>${accord.osgi.private.pkg}</Private-Package>
            <Implementation-Title>Neociclo Accord</Implementation-Title>
            <Implementation-Version>${project.version}</Implementation-Version>
            <_versionpolicy>${accord.osgi.import.default.version}</_versionpolicy>
            <_failok>${accord.osgi.failok}</_failok>
          </instructions>
        </configuration>
      </plugin>
...


And it produced the MANIFEST.MF with:

Bundle-SymbolicName: org.neociclo.accord.server.server-core
Import-Package: javax.security.auth,javax.security.auth.callback,javax
 .security.auth.login,javax.security.auth.spi,org.osgi.service.bluepri
 nt;version="[1.0.0,2.0.0)"



Best regards,
--
Rafael Marins




On Dec 28, 2010, at 4:34 AM, Jean-Baptiste Onofré wrote:

> Hi Rafael,
> 
> it's certainly due to classloader issue. Could you paste your bundle pom to see the Import-Package statement ?
> 
> Regards
> JB


Re: Problem reusing JAAS login modules

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Rafael,

it's certainly due to classloader issue. Could you paste your bundle pom 
to see the Import-Package statement ?

Regards
JB

On 12/28/2010 06:53 AM, Rafael Marins wrote:
> Hi,
>
> When using the PropertiesLoginModule from a blueprint file in my bundle
> located at the /OSGI-INF/blueprint/ folder, I've encountered problem
> with ClassNotFoundException. But I can get it working properly when
> deploying the blueprint xml into the /deploy/ folder.
>
> Check the logging stack trace here: http://pastebin.com/yFiKkpg3 (at
> line 57)
>
>  From my blueprint file: accord-jaas-module.xml
>
> ...
> <jaas:config name="accord">
> <jaas:module
> className="org.apache.karaf.jaas.modules.properties.PropertiesLoginModule"
> flags="required">
> users = $[karaf.base]/etc/accord-users.properties
> debug = true
> </jaas:module>
> </jaas:config>
> ...
>
> Any ideas on what must be done to solve this problem?
>
> --
> Rafael Marins
>
>
>
>