Monday, August 29, 2011

How it's easy to configure ports in Jboss AS7

If you want to change/configure your ports server on Jboss AS7, all you need is to modify entries under socket-binding-group for standalone.xml and socket-binding-groups for domain.xml, for example in standalone.xml:















Very easiest way! doens't it ?

Sunday, August 28, 2011

Ldap Realm configuration on Jboss AS7

In Jboss 6 and lower the ldap Realm was configured in the login-config.xml file like :
 


com.sun.jndi.ldap.LdapCtxFactory
simple
....



On jboss 7 the ldap Realm configuration has a little changed, it become on the standalone.xml (or in domain.xml) as a security domain under :
 
As bellow:







...




Note that the xml parser has changed in Jboss 7, so you should convert every module-option tag so that the lowest level data element for the module-option tag was replaced by the attribute value= and the tag was converted to a self-closing tag, for example:


com.sun.jndi.ldap.LdapCtxFactory

Become:




For our blog ldap directory, the wall configuration become :



















also,




needs to be changed to:







else ModuleClassLoader won't load the com.sun.jndi.ldap.LdapCtxFactory which is needed in ldap authentication modules, and obviously you ll need org.jboss.security.auth.spi.LdapLoginModule on classpath.

Saturday, August 20, 2011

Configure your Jboss AS7 to be accessible from the network

If you want to have the web console as well as your web application accessible from the network, you have to change the default configuration of JBoss.

1) go to standalone/configuration
2) Open the file standalone.xml (or domain.xml)
3) Look for the lines :








4) Change both IP address from 127.0.0.1 to the ip address of your network interface. Note that your complex deployment the server may have 2 ip adresses 1 for business flows and 1 for management flows.
5) Kill JBossAS and restart

The Admin console should be accessible now from your desktop computer at http://:9990/console ;-)

Sunday, August 7, 2011

Spring3 and JSF2 integration using CDI annotations

In this blog i show you how to use @Inject in your JSF managed beans to directly inject the Spring beans instead of instantiating a Spring application context and using the getBean methode from that context and also how Spring will manage your JSF beans ;-)


In order to inject Spring beans into JSF managed beans using @Inject, the following needs to be done:


1)web.xml

 
org.springframework.web.context.ContextLoaderListener


contextConfigLocation

classpath:/applicationContext.xml


org.springframework.web.context.request.RequestContextListener


2) faces-config.xml

 
org.springframework.web.jsf.el.SpringBeanFacesELResolver

3) applicationContext.xml





4) JSF Managed bean

 @ManagedBean(name="blogJSFBean")
@Controller
@ViewScoped
public class MainBean implements Serializable {
private static final long serialVersionUID = -5012655116147710604L;
@Inject
private SpringBean myBlogBean;


To keep it standard i have changed @Managedean to @Named witch is a CDI standard annotation suported by Spring also (as an alternate to @Service and @Controller)

The big problem i have found that the scope view (@ViewScoped) isn't supported by Spring (also Flash scope …) so i have developped the view scope as Spring custom scope following this article: http://cagataycivici.wordpress.com/2010/02/17/port-jsf-2-0s-viewscope-to-spring-3-0/


my bean become:

 @Named("blogJSFBean")
@Scope (value="view")
public class MainBean implements Serializable {
private static final long serialVersionUID = -5012655116147710604L;
@Inject
private SpringBean myBlogBean;


In general the big difference i have found is that Spring and JSF bean from Java EE 6 use a different scoping! Spring do not support standard scope annotation used in JSF and CDI. To get it work i have followed a workaround to import JSF/CDI bean into Spring:

http://matthiaswessendorf.wordpress.com/2010/05/06/using-cdi-scopes-with-spring-3/

Finaly with all this configuration and workarounds, i have been able to inject Spring beans into JSF using @Inject and @Named Java EE standard annotaion and a custom Spring scope to import JSF/CDI scope