You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Wessel Pieterse <we...@ordercloud.co.za> on 2012/06/10 23:21:10 UTC

org.apache.shiro.config.ConfigurationException: Unable to instantiate class when implementing custom Realms

Hi

I am trying to Implement a custom autherization Realm on JBOSS AS7 server.
But when adding the custom realm to the shiro.ini I get 

22:21:26,778 ERROR [org.apache.shiro.web.env.EnvironmentLoader] (MSC service
thread 1-5) Shiro environment initialization failed:
org.apache.shiro.config.ConfigurationException: Unable to instantiate class
[org.apache.shiro.realm.CachingRealm] for object named 'orderCloudRealm'. 
Please ensure you've specified the fully qualified class name correctly.
        at
org.apache.shiro.config.ReflectionBuilder.createNewInstance(ReflectionBuilder.java:148)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.config.ReflectionBuilder.buildObjects(ReflectionBuilder.java:119)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.config.IniSecurityManagerFactory.buildInstances(IniSecurityManagerFactory.java:170)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:119)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.config.IniSecurityManagerFactory.createSecurityManager(IniSecurityManagerFactory.java:97)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:83)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.config.IniSecurityManagerFactory.createInstance(IniSecurityManagerFactory.java:41)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.config.IniFactorySupport.createInstance(IniFactorySupport.java:123)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.util.AbstractFactory.getInstance(AbstractFactory.java:47)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.web.env.IniWebEnvironment.createWebSecurityManager(IniWebEnvironment.java:203)
[shiro-web-1.2.0.jar:1.2.0]
        at
org.apache.shiro.web.env.IniWebEnvironment.configure(IniWebEnvironment.java:99)
[shiro-web-1.2.0.jar:1.2.0]
        at
org.apache.shiro.web.env.IniWebEnvironment.init(IniWebEnvironment.java:92)
[shiro-web-1.2.0.jar:1.2.0]
        at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:45)
[shiro-core-1.2.0.jar:1.2.0]
        at org.apache.shiro.util.LifecycleUtils.init(LifecycleUtils.java:40)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.web.env.EnvironmentLoader.createEnvironment(EnvironmentLoader.java:226)
[shiro-web-1.2.0.jar:1.2.0]
        at
org.apache.shiro.web.env.EnvironmentLoader.initEnvironment(EnvironmentLoader.java:138)
[shiro-web-1.2.0.jar:1.2.0]
        at
org.apache.shiro.web.env.EnvironmentLoaderListener.contextInitialized(EnvironmentLoaderListener.java:58)
[shiro-web-1.2.0.jar:1.2.0]
        at
org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3392)
[jbossweb-7.0.13.Final.jar:]
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:3850)
[jbossweb-7.0.13.Final.jar:]
        at
org.jboss.as.web.deployment.WebDeploymentService.start(WebDeploymentService.java:90)
[jboss-as-web-7.1.1.Final.jar:7.1.1.Final]
        at
org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
        at
org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
        at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
[rt.jar:1.6.0_22]
        at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
[rt.jar:1.6.0_22]
        at java.lang.Thread.run(Thread.java:679) [rt.jar:1.6.0_22]
Caused by: org.apache.shiro.util.InstantiationException: Unable to
instantiate class [org.apache.shiro.realm.CachingRealm]
        at org.apache.shiro.util.ClassUtils.newInstance(ClassUtils.java:179)
[shiro-core-1.2.0.jar:1.2.0]
        at org.apache.shiro.util.ClassUtils.newInstance(ClassUtils.java:164)
[shiro-core-1.2.0.jar:1.2.0]
        at
org.apache.shiro.config.ReflectionBuilder.createNewInstance(ReflectionBuilder.java:141)
[shiro-core-1.2.0.jar:1.2.0]
        ... 24 more
Caused by: java.lang.InstantiationException
        at
sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:48)
[rt.jar:1.6.0_22]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
[rt.jar:1.6.0_22]
        at java.lang.Class.newInstance0(Class.java:372) [rt.jar:1.6.0_22]
        at java.lang.Class.newInstance(Class.java:325) [rt.jar:1.6.0_22]
        at org.apache.shiro.util.ClassUtils.newInstance(ClassUtils.java:177)
[shiro-core-1.2.0.jar:1.2.0]
        ... 26 more


My web.xml is 

<listener>
   
<listener-class>org.apache.shiro.web.env.EnvironmentLoaderListener</listener-class>
</listener>
 
<filter>
    <filter-name>ShiroFilter</filter-name>
    <filter-class>org.apache.shiro.web.servlet.ShiroFilter</filter-class>
</filter>
 
<filter-mapping>
    <filter-name>ShiroFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

my shiro.ini contains

orderCloudRealm =  com.unijunction.ordercloud.security.realm.OrderCloudRealm


securityManager.realms = $orderCloudRealm

authc.loginUrl = /login.xhtml

[users]
# The 'users' section is for simple deployments
# when you only need a small number of statically-defined 
# set of User accounts.

[roles]
# The 'roles' section is for simple deployments
# when you only need a small number of statically-defined
# roles.

[urls]
# The 'urls' section is used for url-based security
# in web applications.  We'll discuss this

OrderCloudRealm

package com.unijunction.ordercloud.security.realm;

public abstract class OrderCloudRealm extends AuthorizingRealm {


    private static Logger LOG = Logger.getLogger(OrderCloudRealm.class);

    //Constructer
    public OrderCloudRealm(){
        this.setName("OrderCloudRealm");
        HashedCredentialsMatcher matcher = new HashedCredentialsMatcher();
        matcher.setHashAlgorithmName("SHA-256");
        setCredentialsMatcher(matcher);

        LOG.debug("OrderCloudRealm instantiated!");
    }

    protected AuthorizationInfo doGetAuthorizationInfo(final
PrincipalCollection principals) {....}

     @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken
token) throws AuthenticationException {....}
}


I have googled for a solution to this, but have found none at all. Any
solutions or ideas would be greatly appreciated.







--
View this message in context: http://shiro-user.582556.n2.nabble.com/org-apache-shiro-config-ConfigurationException-Unable-to-instantiate-class-when-implementing-custom-s-tp7577490.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: org.apache.shiro.config.ConfigurationException: Unable to instantiate class when implementing custom Realms

Posted by Wessel Pieterse <we...@ordercloud.co.za>.
Thank you very much. Was exactly my problem. Don't know how I missed it. :D

--
View this message in context: http://shiro-user.582556.n2.nabble.com/org-apache-shiro-config-ConfigurationException-Unable-to-instantiate-class-when-implementing-custom-s-tp7577490p7577492.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: org.apache.shiro.config.ConfigurationException: Unable to instantiate class when implementing custom Realms

Posted by Thilo-Alexander Ginkel <th...@ginkel.com>.
On Sun, Jun 10, 2012 at 11:21 PM, Wessel Pieterse
<we...@ordercloud.co.za> wrote:
> public abstract class OrderCloudRealm extends AuthorizingRealm {

You can't create instances of abstract classes. ;-)

Regards,
Thilo