[JBoss AS 7 Development] - JBoss AS 7.1.1.Final custom login module for remoting and custom principal
by Sebastian Raue
Sebastian Raue [https://community.jboss.org/people/sraue] created the discussion
"JBoss AS 7.1.1.Final custom login module for remoting and custom principal"
To view the discussion, visit: https://community.jboss.org/message/726343#726343
--------------------------------------------------------------
For remoting we have made a custom login module which extends org.jboss.security.auth.spi.AbstractServerLoginModule.
The overwritten method getIdenttity() returns a custom principal - ApplicationPrincipal.
We can access the principal inside our ejbs via
@Resource
public SessionContext sessionContext;
....
Principal principal = sessionContext.getCallerPrincipal();
....
but we get a ClassCastException when we try to cast the returned Principal into ApplicationPrincipal.
On the other hand principal.getClass().getName() returns the expected class name.
The problem is that our login module is deployed as a jboss module (<jboss-home>/modules) - inside a jar which also
contains ApplicationPrincipal. The ear containing our ejb.jar which contains our ejbs also contains a copy of ApplicationPrincipal.
The problem is that our custom login module and the ApplicationPrincipal are loaded by one class loader and our
ejbs and the ApplicationPrincipal copy are loaded by another class loader. The ApplicationPrincipal from the login module which we get
by calling sessionContext.getCallerPrincipal() in the ejb is no ApplicationPrincipal known by the ejbs.
What can we do to solve this problem?
I have tried to put the custom login module code into our ear and adjusted the "module" attribute value of <login-module>
in our standalone.xml to deployment.<app-name>.ear.<ejb-jar-name>.jar but it did not work. Exception on the remote client was:
javax.security.sasl.SaslException: Authentication failed: all available authentication mechanisms failed
As a separate module and the respective <login-module> configuration in standalone.xml the authentication works fine with our login module
- we only have the described ClassCastException problem.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/726343#726343]
Start a new discussion in JBoss AS 7 Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
13 years
[JBoss AS 7 Development] - [Proposal] Resolve expression values on system properties
by Guillaume Grossetie
Guillaume Grossetie [https://community.jboss.org/people/grossetieg] created the discussion
"[Proposal] Resolve expression values on system properties"
To view the discussion, visit: https://community.jboss.org/message/759709#759709
--------------------------------------------------------------
Hi,
The StringPropertyReplacer class already provide a method #replaceProperties that replace ${expression} value with system properties. I think that it can be useful to resolve expression on system properties with system properties.
Example :
<system-properties>
<property name="my.image.dir" value="${jboss.server.data.dir}/image"/>
</system-properties>
Sure I can do the work on my code but I don't want to reference jboss system property :
<system-properties>
<property name="my.image.dir" value="image"/>
</system-properties>
System.getProperty("jboss.server.data.dir") + "/" + System.getProperty("my.image.dir");
If we use StringPropertyReplacer we can also do sometthing like :
<system-properties>
<property name="my.dir" value="/my/dir"/>
<property name="my.image.dir" value="${my.dir:/home}/image"/>
</system-properties>
The basic idea is to check if the added/removed/changed system property resolve expression :
setSystemProperty("my.image.dir", "${jboss.server.data.dir}/image");
# my.image.dir = "${jboss.server.data.dir}/image"
setSystemProperty("jboss.server.data.dir", "/opt/jboss");
# retrieve my.image.dir property, resolve expression and setSystemProperty("my.image.dir", "/opt/jboss/image");
# my.image.dir = /opt/jboss/image
The resolved expression will not be stored on the standalone.xml/domain.xml file.
What do you think ?
Guillaume.
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/759709#759709]
Start a new discussion in JBoss AS 7 Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
13 years
[JBoss AS 7 Development] - @PersistenceContext is null in jboss7
by yunshi tan
yunshi tan [https://community.jboss.org/people/yunshi] created the discussion
"@PersistenceContext is null in jboss7"
To view the discussion, visit: https://community.jboss.org/message/759623#759623
--------------------------------------------------------------
Hi all,
I am migrating jboss4.2.3 -> jboss7 and I am totally blocked by the probleme that @PersistenceContext always returns me NULL in the EJB jars.
Here are the projects in my deployment :
deployment
-----------------------------
- hibernate-ejb-1.jar
| - src/main/java ... some entities and DAO
| - src/main/resources
| - META-INF
| - hibernate.cfg.xml
| - persistence.xml
- seam2App.ear
| - module1.jar
| - module2.jar
| - war1.war
hibernate-ejb-1.jar offers some DAO functions for my seam2App.ear and other applications. *However, in hibernate-ejb-1.jar, all the @PersistenceContext EntityManager returns NULL.*
*Here is the persistence.xml*
<persistence xmlns=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="xxx-unit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/xxxxxDS</jta-data-source>
<properties>
<property name="hibernate.ejb.cfgfile" value="/META-INF/hibernate.cfg.xml"/>
<property name="jboss.entity.manager.factory.jndi.name" value="java:jboss/EntityManagerFactories/xxx"/>
<property name="hibernate.session_factory_name" value="java:jboss/hibernate/SessionFactoryxxx"/>
<property name="jboss.as.jpa.providerModule" value="org.hibernate:3" />
</properties>
</persistence-unit>
</persistence>
In the *cosole*, I have
12:15:49,752 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named xxxDAOImpl in deployment unit deployment "xxxxxxx-SNAPSHOT.jar" are as follows:
java:global/xxxxxx-SNAPSHOT/xxxxxxDAOImpl!com.xxxx.dao.common.remotexxxxxxDAORemote
java:app/xxxxxx-SNAPSHOT/xxxxxxDAOImpl!com.xxxxxx.dao.common.remote.xxxxxxDAORemote
java:module/xxxxxxDAOImpl!com.xxxxxx.dao.common.remote.xxxxxxDAORemote
java:jboss/exported/xxxxxx-SNAPSHOT/xxxxxxDAOImpl!com.xxxxxx.dao.common.remote.xxxxxxDAORemote
java:global/xxxxxx-SNAPSHOT/xxxxxxDAOImpl!com.xxxxxx.dao.common.local.xxxxxxDAOLocal
java:app/xxxxxx-SNAPSHOT/xxxxxxDAOImpl!com.xxxxxx.dao.common.local.xxxxxxDAOLocal
java:module/xxxxxxDAOImpl!com.xxxxxx.dao.common.local.xxxxxxDAOLocal
In other applications who depend on hibernate-ejb-1.jar, I tried to get the Ejb like this:
context = new InitialContext();
DAO dao= (DAO ) context. lookup("java:global/xxxxxx-SNAPSHOT/xxxxxxDAOImpl!com.xxxxxx.dao.common.local.xxxxxxDAOLocal");
*DAO.java looks like this*
@Stateless
public class DAOImpl implements DAOLocal, DAORemote{
@PersistenceContext
private EntityManager entityManager;
public List<Bean> findAll() {
Query query = createNamedQuery(Bean.FIND_ALL);
if(query!=null)
return query.getResultList();
return null;
}
}
However, I have the NPE because @PersistenceContext EntityManager entityManager is always null.
The probleme is :
--------------------------------------------------------------
Reply to this message by going to Community
[https://community.jboss.org/message/759623#759623]
Start a new discussion in JBoss AS 7 Development at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&con...]
13 years