I'm trying to port this example shiro-primefaces-example written for glassfish, but I have trobles with the datasource. The example has two config files:
glassfish-web.xml:
<glassfish-web-app error-url="">
<context-root>/shiro-primefaces-example</context-root>
<resource-ref>
<res-ref-name>jdbc/shiro-primefaces</res-ref-name>
<jndi-name>java:app/jdbc/shiro-primefaces</jndi-name>
</resource-ref>
<class-loader delegate="false"/>
<parameter-encoding default-charset="UTF-8"/>
</glassfish-web-app>
glassfish-resources.xml:
<resources>
<jdbc-connection-pool name="pool/shiro-primefaces"
datasource-classname="org.postgresql.ds.PGConnectionPoolDataSource"
res-type="javax.sql.ConnectionPoolDataSource"
steady-pool-size="5"
pool-resize-quantity="1"
max-pool-size="10">
<property name="serverName" value="localhost"/>
<property name="PortNumber" value="5432"/>
<property name="DatabaseName" value="shiro_primefaces"/>
<property name="User" value="shiro_primefaces"/>
<property name="Password" value="testpass"/>
</jdbc-connection-pool>
<jdbc-resource pool-name="pool/shiro-primefaces" jndi-name="java:app/jdbc/shiro-primefaces"/>
</resources>
My datasource in standalone.xml is "java:jboss/datasources/mysql".
shiro.ini:
...
datasource.resourceName = java:jboss/datasources/mysql
...
When I try to login I get this error:
...
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
... 50 more
Caused by: java.lang.NullPointerException
at org.example.shiro.bean.security.ShiroLoginBean.doLogin(ShiroLoginBean.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
Do you need to create the file jboss-web.xml or something?
You need to remove, glassfish-web.xml, glassfish-resources.xml and the next lines from web.xml:
<resource-ref>
<res-ref-name>jdbc/shiro-primefaces</res-ref-name>
<res-type>javax.sql.ConnectionPoolDataSource</res-type>
<res-auth>Container</res-auth>
<lookup-name>java:app/jdbc/shiro-primefaces</lookup-name>
</resource-ref>
You need to add the next lines to shiro.ini file with your datasource:
datasource.resourceName = java:jboss/datasources/mysql