You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by reinisv <sh...@orbit-x.de> on 2012/10/08 01:03:58 UTC

Re: Shiro in CDI/JPA2/JSF2 project

Despite the code from Melvyn (thanks man!) and tip from atomicknight
(cheers!) in this thread:
http://shiro-user.582556.n2.nabble.com/Realm-can-not-be-managed-by-CDI-td7502061.html

I still can't manage to make it work :-/

I assume this is caused by my CDI implementation framework (OpenWebbeans)
and the way I am bootstrapping the IoC container.

What happens is that in my customized EnvironmentLoaderListener the injected
Realm is null. I attempted to inject some of my beans and debugging showed
that injection is not working at all.

I know this is only indirectly related to shiro, but still could be useful
for anyone who will attempt to enable OWB CDI in shiro.

So my question is this - based on web.xml, is the issue that OWB is also
bootstrapping through ServletContextListerner? Or are there some other
obvious errors that would cause IoC not to work in my customized
EnvironmentLoaderListener?

web.xml
-----------------------------
	<listener>
	
<listener-class>org.apache.webbeans.servlet.WebBeansConfigurationListener</listener-class>
	</listener>
	<listener>
	
<listener-class>myco.web.filter.CdiWebEnvironmentLoaderListener</listener-class>
	</listener>
	<listener>
	
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</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>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>

	<servlet>
		<servlet-name>Faces Servlet</servlet-name>
		<servlet-class>org.apache.myfaces.webapp.MyFacesServlet</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>
	<servlet-mapping>
		<servlet-name>Faces Servlet</servlet-name>
		<url-pattern>*.xhtml</url-pattern>
	</servlet-mapping>
--------------------------------------

Thank you for your help
Reinis



--
View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro-in-CDI-JPA2-JSF2-project-tp7577437p7577848.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Shiro in CDI/JPA2/JSF2 project

Posted by melvyndekort <me...@mdekort.nl>.
Hi,

It's difficult to see what you did without some code.
I've made a simple example of my code and put it on Dropbox.
You can download it here:
http://dl.dropbox.com/u/6753023/shiro_cdi_example.tar.gz

Greetz,

Melvyn



On Tue, Dec 11, 2012 at 5:46 AM, vinnywm [via Shiro User] <
ml-node+s582556n7578034h81@n2.nabble.com> wrote:

> I'm going through the same problem. I've done all the changes recommended
> here but nothing work.
>
> The error that is thrown is: (says it is not a required type of
> WebEnvironment)
>
> WARNING: java.lang.IllegalStateException: ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException:
> org.apache.shiro.config.ConfigurationException: Custom WebEnvironment class
> [br.com.webbiz.saga.control.listener.CdiEnvironmentListener] is not of
> required type [org.apache.shiro.web.env.WebEnvironment]
> java.lang.IllegalStateException: ContainerBase.addChild: start:
> org.apache.catalina.LifecycleException:
> org.apache.shiro.config.ConfigurationException: Custom WebEnvironment class
> [br.com.webbiz.saga.control.listener.CdiEnvironmentListener] is not of
> required type [org.apache.shiro.web.env.WebEnvironment]
>
> What do I do?
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://shiro-user.582556.n2.nabble.com/Shiro-in-CDI-JPA2-JSF2-project-tp7577437p7578034.html
>  To unsubscribe from Shiro in CDI/JPA2/JSF2 project, click here<http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=7577437&code=bWVsdnluQG1kZWtvcnQubmx8NzU3NzQzN3w4NzA5MDUzNzE=>
> .
> NAML<http://shiro-user.582556.n2.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://shiro-user.582556.n2.nabble.com/Shiro-in-CDI-JPA2-JSF2-project-tp7577437p7578039.html
Sent from the Shiro User mailing list archive at Nabble.com.

Re: Shiro in CDI/JPA2/JSF2 project

Posted by sh...@xoxy.net.
Sounds like the scenario described here:
https://issues.apache.org/jira/browse/OWB-481

Try adding some logging/print statements to see if the two
ServletContextListeners are being initialized in the expected order. If
not, it looks like you'll need to manually bootstrap OpenWebBeans.