12 Replies Latest reply: Feb 14, 2009 12:30 AM by Jose Alvarez de Lara RSS

jboss-dukes-bank app

Jose Alvarez de Lara Novice

Hi,

I am trying to compile jboss-dukes-bank and deploy on JBoss-4.2.2.GA using NetBeans IDE, but I can not.

The problem is that even having define jboss.j2ee property correctly including all jars, there are some packages that the system does not find. And I am thinking it is a problem of J2EE version in my JBoss.

Is there anybody that had tried and got it. I mean, I am very interested on get it because is a very nice application and following I can learn to work with that IDE.

Here are some of the errors:

somPath\jboss-dukes-bank\src\com\sun\ebank\web\template\DefinitionTag.java:31: package javax.servlet.jsp does not exist
import javax.servlet.jsp.JspTagException;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\DefinitionTag.java:32: package javax.servlet.jsp does not exist
import javax.servlet.jsp.PageContext;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\DefinitionTag.java:33: package javax.servlet.jsp.tagext does not exist
import javax.servlet.jsp.tagext.SimpleTagSupport;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\DefinitionTag.java:37: cannot find symbol
symbol: class SimpleTagSupport
public class DefinitionTag extends SimpleTagSupport {
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\InsertTag.java:32: package javax.servlet.jsp does not exist
import javax.servlet.jsp.JspTagException;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\InsertTag.java:33: package javax.servlet.jsp does not exist
import javax.servlet.jsp.PageContext;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\InsertTag.java:34: package javax.servlet.jsp.tagext does not exist
import javax.servlet.jsp.tagext.SimpleTagSupport;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\InsertTag.java:38: cannot find symbol
symbol: class SimpleTagSupport
public class InsertTag extends SimpleTagSupport {
\jboss-dukes-bank\src\com\sun\ebank\web\template\InsertTag.java:54: cannot find symbol
symbol : class JspTagException
location: class com.sun.ebank.web.template.InsertTag
 public void doTag() throws JspTagException {
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\ParameterTag.java:31: package javax.servlet.jsp.tagext does not exist
import javax.servlet.jsp.tagext.*;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\ParameterTag.java:32: package javax.servlet.jsp does not exist
import javax.servlet.jsp.PageContext;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\ParameterTag.java:36: cannot find symbol
symbol: class SimpleTagSupport
public class ParameterTag extends SimpleTagSupport {
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\ScreenTag.java:31: package javax.servlet.jsp.tagext does not exist
import javax.servlet.jsp.tagext.SimpleTagSupport;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\ScreenTag.java:32: package javax.servlet.jsp does not exist
import javax.servlet.jsp.PageContext;
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\ScreenTag.java:36: cannot find symbol
symbol: class SimpleTagSupport
public class ScreenTag extends SimpleTagSupport {
somPath \jboss-dukes-bank\src\com\sun\ebank\web\template\DefinitionTag.java:62: cannot find symbol
symbol : method getJspBody()
location: class com.sun.ebank.web.template.DefinitionTag
 getJspBody()



Thanking in advance,
Oggie

  • 1. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Hi all,

    I am getting it, but I need to know where can I see the JNDI names of my EJBs on JBoss 4.2.2 Ga.

    Any help?

    Thanks a lot,
    pepelara

  • 2. Re: jboss-dukes-bank app
    jaikiran pai Master

    Follow the steps mentioned here http://www.jboss.org/community/docs/DOC-9583

  • 3. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Thank you.

    This application is a little bit complicated.

    Thanks again,
    pepelara

  • 4. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Hi,
    I was googling and I have solved the problem about the InitialContex: I was needing to add some jar into the prject.

    Now I have some problems when callin some local-home interfaces from the ejbCreate mthod of a Session Bean. My code is as followes:

    package com.sun.ebank.util;
    
    
    /**
     * This interface defines names in code used as args for lookup().
     */
    public interface CodedNames {
     public static final String BANK_DATABASE = "java:/DefaultDS";
     public static final String ACCOUNT_EJBHOME = "java:comp/env/ejb/AccountEJB";
     public static final String ACCOUNT_CONTROLLER_EJBHOME = "AccountControllerEJB";
     public static final String ACCOUNT_EJBHOME = "java:comp/env/ejb/CustomerEJB";
     public static final String CUSTOMER_CONTROLLER_EJBHOME = "CustomerControllerEJB";
     public static final String TX_EJBHOME = "java:comp/env/ejb/TxEJB";
     public static final String TX_CONTROLLER_EJBHOME = "TxControllerEJB";
    }
    


    where the ACCOUNT_CONTROLLER_EJBHOME, CUSTOMER_CONTROLLER_EJBHOME and TX_CONTROLLER_EJBHOME are the session bean that access to my ACCOUNT_EJBHOME, ACCOUNT_EJBHOME and TX_EJBHOME on their respectively ejbCreate method.

    The way to call the diferents EJBs is as followes,

    package com.sun.ebank.util;
    
    import java.util.Properties;
    import javax.rmi.PortableRemoteObject;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import com.sun.ebank.ejb.account.AccountHome;
    import com.sun.ebank.ejb.account.AccountControllerHome;
    import com.sun.ebank.ejb.customer.CustomerHome;
    import com.sun.ebank.ejb.customer.CustomerControllerHome;
    import com.sun.ebank.ejb.tx.TxHome;
    import com.sun.ebank.ejb.tx.TxControllerHome;
    
    
    /**
     * This helper class fetches EJB home references.
     */
    public final class EJBGetter {
     public static AccountHome getAccountHome() throws NamingException {
     Context initial = getInitialContext();
     //InitialContext initial = new InitialContext();
     Object objref = initial.lookup(CodedNames.ACCOUNT_EJBHOME);
    
     //return (AccountHome) PortableRemoteObject.narrow(objref, AccountHome.class);
     return (AccountHome)objref;
     }
    
     public static AccountControllerHome getAccountControllerHome()
     throws NamingException {
     Context initial = getInitialContext();
     //InitialContext initial = new InitialContext();
     Object objref = initial.lookup(CodedNames.ACCOUNT_CONTROLLER_EJBHOME);
    
     return (AccountControllerHome) PortableRemoteObject.narrow(objref,
     AccountControllerHome.class);
     }
    
     public static CustomerHome getCustomerHome() throws NamingException {
     Context initial = getInitialContext();
     //InitialContext initial = new InitialContext();
     Object objref = initial.lookup(CodedNames.CUSTOMER_EJBHOME);
    
     //return (CustomerHome) PortableRemoteObject.narrow(objref, CustomerHome.class);
     return (CustomerHome)objref;
     }
    
     public static CustomerControllerHome getCustomerControllerHome()
     throws NamingException {
     Context initial = getInitialContext();
     //InitialContext initial = new InitialContext();
     Object objref = initial.lookup(CodedNames.CUSTOMER_CONTROLLER_EJBHOME);
    
     return (CustomerControllerHome) PortableRemoteObject.narrow(objref,
     CustomerControllerHome.class);
     }
    
     public static TxHome getTxHome() throws NamingException {
     Context initial = getInitialContext();
     //InitialContext initial = new InitialContext();
     Object objref = initial.lookup(CodedNames.TX_EJBHOME);
    
     //return (TxHome) PortableRemoteObject.narrow(objref, TxHome.class);
     return (TxHome)objref;
     }
    
     public static TxControllerHome getTxControllerHome()
     throws NamingException {
     Context initial = getInitialContext();
     //InitialContext initial = new InitialContext();
     Object objref = initial.lookup(CodedNames.TX_CONTROLLER_EJBHOME);
    
     return (TxControllerHome) PortableRemoteObject.narrow(objref,
     TxControllerHome.class);
     }
    
     private static Context getInitialContext(){
     Context ctx = null;
    
     Properties env = new Properties();
     env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
     env.put(Context.PROVIDER_URL, "localhost:1099");
     env.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
     env.put("j2ee.clientName", "bank-client");
    
     try {
     // Get an initial context
     ctx = new InitialContext(env);
     System.out.println("Got context");
     } catch (NamingException ne) {
     // TODO Auto-generated catch block
     System.out.println("Did not get context");
     ne.printStackTrace();
     }
    
     return ctx;
     }
    }
    


    but when I try it, the first call to the session bean works ok, but from the ejbCreate of this session bean I cannot call the entities beans. The system throws an exception,

    java.rmi.ServerException: EJBException:; nested exception is:
     javax.ejb.EJBException: ejbCreate: comp not bound
     at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:365)
     at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:136)
     at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
     at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:637)
     at org.jboss.ejb.Container.invoke(Container.java:981)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
     at org.jboss.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:231)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
     at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
     at $Proxy16.invoke(Unknown Source)
     at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
     at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
     at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
     at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
    Caused by: javax.ejb.EJBException: ejbCreate: comp not bound
     at com.sun.ebank.ejb.customer.CustomerControllerBean.ejbCreate(CustomerControllerBean.java:280)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at org.jboss.ejb.StatefulSessionContainer.createSession(StatefulSessionContainer.java:278)
     at org.jboss.ejb.StatefulSessionContainer.createHome(StatefulSessionContainer.java:337)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at org.jboss.invocation.Invocation.performCall(Invocation.java:359)
     at org.jboss.ejb.StatefulSessionContainer$ContainerInterceptor.invokeHome(StatefulSessionContainer.java:549)
     at org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:145)
     at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invokeHome(CachedConnectionInterceptor.java:189)
     at org.jboss.ejb.plugins.CallValidationInterceptor.invokeHome(CallValidationInterceptor.java:56)
     at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:125)
     at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:173)
     at org.jboss.ejb.plugins.TxInterceptorBMT.invokeHome(TxInterceptorBMT.java:71)
     at org.jboss.ejb.plugins.StatefulSessionInstanceInterceptor.invokeHome(StatefulSessionInstanceInterceptor.java:143)
     at org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:132)
     at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invokeHome(ProxyFactoryFinderInterceptor.java:107)
     at org.jboss.ejb.SessionContainer.internalInvokeHome(SessionContainer.java:637)
     at org.jboss.ejb.Container.invoke(Container.java:981)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
     at org.jboss.invocation.unified.server.UnifiedInvoker.invoke(UnifiedInvoker.java:231)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:585)
     at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
     at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
     at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
     at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
     at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
     at javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:201)
     at $Proxy16.invoke(Unknown Source)
     at org.jboss.remoting.ServerInvoker.invoke(ServerInvoker.java:769)
     at org.jboss.remoting.transport.socket.ServerThread.processInvocation(ServerThread.java:573)
     at org.jboss.remoting.transport.socket.ServerThread.dorun(ServerThread.java:373)
     at org.jboss.remoting.transport.socket.ServerThread.run(ServerThread.java:166)
     at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:163)
     at org.jboss.remoting.Client.invoke(Client.java:1634)
     at org.jboss.remoting.Client.invoke(Client.java:548)
     at org.jboss.invocation.unified.interfaces.UnifiedInvokerProxy.invoke(UnifiedInvokerProxy.java:183)
     at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:365)
     at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:197)
     at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
     at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
     at org.jboss.proxy.ejb.HomeInterceptor.invoke(HomeInterceptor.java:184)
     at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
     at $Proxy0.create(Unknown Source)
     at com.sun.ebank.appclient.DataModel.<init>(DataModel.java:127)
     at com.sun.ebank.appclient.EventHandle.<init>(EventHandle.java:51)
     at com.sun.ebank.appclient.BankAdmin.main(BankAdmin.java:587)


    This is in case I name the entities "java:comp/env/ejb/myEJB" because if I just name the ejb "myEJB" the exception should be

    java.rmi.ServerException: EJBException:; nested exception is:
     javax.ejb.EJBException: ejbCreate: myEJB not bound
     at etc...
    


    The question is that the entities interfaces are locals son I do not know the way to call them.

    Any help over there.

    Thank you,
    Jose Alvarez de Lara

  • 5. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Hi,

    I have solved my problems with the JNDI and the desktop client works ok.
    But I have no idea of how the web client works. I have been googling and I have discovered a new class ContextListener that I do not know what is its function in the web app.

    Please, help.
    Jose Alvarez de Lara

  • 6. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Hi,

    I was studying my web app and I have got the problem. It is in the class DefinitionTag that extends SimpleTagSupport. In the method,

    public void doTag() {
     try {
     getJspBody()
     .invoke(null);
    
     Definition definition = new Definition();
     PageContext context = (PageContext) getJspContext();
     setScreen(screenId);
     ArrayList params = (ArrayList) screens.get(this.screenId);
     Iterator ir = null;
    
     if (params != null) {
     ir = params.iterator();
    
     int cont = 0;
     while (ir.hasNext()){
     definition.setParam((Parameter) ir.next());
     cont ++;
     }
     Debug.println("DefinitionTag: params defined: " + cont);
    
     // put the definition in the page context
     context.setAttribute(definitionName, definition,
     PageContext.APPLICATION_SCOPE);
     } else {
     Debug.println("DefinitionTag: params are not defined.");
     }
     } catch (Exception ex) {
     ex.printStackTrace();
     }
     }
    


    the line ArrayList params = (ArrayList) screens.get(this.screenId); returns null, so the rest of the code

    if (params != null) {
     ir = params.iterator();
    
     int cont = 0;
     while (ir.hasNext()){
     definition.setParam((Parameter) ir.next());
     cont ++;
     }
     Debug.println("DefinitionTag: params defined: " + cont);
    
     // put the definition in the page context
     context.setAttribute(definitionName, definition,
     PageContext.APPLICATION_SCOPE);
     } else {
     Debug.println("DefinitionTag: params are not defined.");
     }
    


    returns, on the console, the message: "DefinitionTag: params are not defined." And it is because the value of this.screenId is,

    "${requestScope['javax.servlet.forward.servlet_path']}"

    that belong to screendefinitions.jspf as follow,

    <%@ taglib uri="SimpleTagLibrary" prefix="tt" %>
    <tt:definition name="bank" screen="${requestScope['javax.servlet.forward.servlet_path']}">
     <tt:screen screenId="/main">
     <tt:parameter name="title" value="Duke's Bank" direct="true"/>
     <tt:parameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:parameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:parameter name="body" value="/main.jsp" direct="false"/>
     </tt:screen>
    
     <tt:screen screenId="/transferAck">
     <tt:parameter name="title" direct="true">
     <jsp:attribute name="value" >
     <fmt:message key="TitleTransferSucceeded"/>
     </jsp:attribute>
     </tt:parameter>
     <tt:parameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:parameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:parameter name="body" value="/transferAck.jsp" direct="false"/>
     </tt:screen>
    
     <tt:screen screenId="/transferFunds">
     <tt:parameter name="title" direct="true">
     <jsp:attribute name="value" >
     <fmt:message key="TitleTransferFunds"/>
     </jsp:attribute>
     </tt:parameter>
     <tt:parameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:parameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:parameter name="body" value="/transferFunds.jsp" direct="false"/>
     </tt:screen>
    
     <tt:screen screenId="/atmAck">
     <tt:parameter name="title" direct="true">
     <jsp:attribute name="value" >
     <fmt:message key="TitleWDSucceeded"/>
     </jsp:attribute>
     </tt:parameter>
     <tt:parameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:parameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:parameter name="body" value="/atmAck.jsp" direct="false"/>
     </tt:screen>
    
     <tt:screen screenId="/atm">
     <tt:parameter name="title" direct="true">
     <jsp:attribute name="value" >
     <fmt:message key="TitleWD"/>
     </jsp:attribute>
     </tt:parameter>
     <tt:parameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:parameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:parameter name="body" value="/atm.jsp" direct="false"/>
     </tt:screen>
    
     <tt:screen screenId="/accountHist">
     <tt:parameter name="title" direct="true">
     <jsp:attribute name="value" >
     <fmt:message key="TitleAccountHistory"/>
     </jsp:attribute>
     </tt:parameter>
     <tt:parameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:parameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:parameter name="body" value="/accountHist.jsp" direct="false"/>
     </tt:screen>
    
     <tt:screen screenId="/accountList">
     <tt:parameter name="title" direct="true">
     <jsp:attribute name="value" >
     <fmt:message key="TitleAccountList"/>
     </jsp:attribute>
     </tt:parameter>
     <tt:parameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:parameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:parameter name="body" value="/accountList.jsp" direct="false"/>
     </tt:screen>
    
     <tt:screen screenId="/logoff">
     <tt:parameter name="title" direct="true">
     <jsp:attribute name="value" >
     <fmt:message key="TitleLogoff" />
     </jsp:attribute>
     </tt:parameter>
     <tt:parameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:parameter name="links" value="/template/nolinks.jsp" direct="false"/>
     <tt:parameter name="body" value="/logoff.jsp" direct="false"/>
     </tt:screen>
    </tt:definition>
    


    I think the value might to be "/main", "/transferFunds", etc...
    and this is my problem.

    Will you help me?

    Merry Christmas,
    Jose Alvarez de Lara(Oggie Svennson)

  • 7. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Going on with the Duke’s Bank, I have made some changes in then code. I am trying it because learning. But now appears an exception that is,

    Unable find setter method for paramName attribute

    Then code is as follow,

    public class Definition {
     private HashMap params = new HashMap();
    
     public void setParam(Parameter p) {
     params.put(p.getParamName(), p);
     }
    
     public Parameter getParam(String name) {
     return (Parameter) params.get(name);
     }
    }
    


    public class Parameter {
     private String paramName;
     private boolean direct;
     private String paramValue;
    
     public Parameter(String name, String value, boolean isDirect) {
     this.paramName = name;
     this.direct = isDirect;
     this.paramValue = value;
     }
    
     public String getParamName() {
     return paramName;
     }
    
     public boolean getIsDirect() {
     return direct;
     }
    
     public String getParamValue() {
     return paramValue;
     }
    }
    


    public class DefinitionTag extends SimpleTagSupport {
     private String name = null;
     private String screen = null;
     private HashMap screens = null;
    
     public DefinitionTag() {
     super();
     }
    
     public HashMap getScreens() {
     return screens;
     }
    
     public void setName(String name) {
     this.name = name;
     }
    
     public void setScreen(String screenId) {
     this.screen = screenId;
     }
    
     public void doTag() {
     try {
     screens = new HashMap();
    
     getJspBody()
     .invoke(null);
    
     Definition myDefinition = new Definition();
     PageContext context = (PageContext) getJspContext();
     ArrayList params = (ArrayList) screens.get(screen);
     Iterator ir = null;
    
     if (params != null) {
     ir = params.iterator();
    
     while (ir.hasNext())
     myDefinition.setParam((Parameter) ir.next());
    
     // put the definition in the page context
     context.setAttribute(name, myDefinition,
     context.APPLICATION_SCOPE);
     } else {
     Debug.println("DefinitionTag: params are not defined.");
     }
     } catch (Exception ex) {
     ex.printStackTrace();
     }
     }
    }
    


    public class ParameterTag extends SimpleTagSupport {
     private String paramName = null;
     private String paramValue = null;
     private String direct = null;
    
     public ParameterTag() {
     super();
     }
    
     public void setParamName(String paramName) {
     this.paramName = paramName;
     }
    
     public void setParamValue(String paramValue) {
     this.paramValue = paramValue;
     }
    
     public void setDirect(String isDirectString) {
     this.direct = isDirectString;
     }
    
     public void doTag() {
     boolean isDirect = false;
    
     if ((direct != null) &&
     direct.toLowerCase()
     .equals("true")) {
     isDirect = true;
     }
    
     try {
     // retrieve the parameters list
     if (paramName != null) {
     ArrayList parameters =
     ((ScreenTag) getParent()).getParameters();
    
     if (parameters != null) {
     Parameter param =
     new Parameter(paramName, paramValue, isDirect);
     parameters.add(param);
     } else {
     Debug.println("ParameterTag: parameters do not exist.");
     }
    
     }
     } catch (Exception e) {
     Debug.println("ParameterTag: error in doTag: " + e);
     }
     }
    }
    


    public class ScreenTag extends SimpleTagSupport {
     private String screenId;
     private ArrayList parameters = null;
    
     public ScreenTag() {
     super();
     }
    
     public ArrayList getParameters() {
     return parameters;
     }
    
     public void setScreenId(String screenId) {
     this.screenId = screenId;
     }
    
     public void doTag() {
     parameters = new ArrayList();
    
     HashMap screens = (HashMap) ((DefinitionTag) getParent()).getScreens();
    
     if (screens != null) {
     try {
     if (!screens.containsKey(screenId)) {
     screens.put(screenId, parameters);
     }
    
     getJspBody()
     .invoke(null);
     } catch (Exception ex) {
     ex.printStackTrace();
     }
     } else {
     Debug.println("ScreenTag: Unable to get screens object.");
     }
     }
    }
    


    public class InsertTag extends SimpleTagSupport {
     private String parameter = null;
     private String definition = null;
    
     public InsertTag() {
     super();
     }
    
     public void setParameter(String parameter) {
     this.parameter = parameter;
     }
    
     public void setDefinition(String name) {
     this.definition = name;
     }
    
     public void doTag() throws JspTagException {
     Definition myDefinition = null;
     Parameter myParameter = null;
     boolean directInclude = false;
    
     PageContext context = (PageContext) getJspContext();
    
     // get the definition from the page context
     myDefinition =
     (Definition) context.getAttribute(definition,
     context.APPLICATION_SCOPE);
    
     // get the parameter
     if ((parameter != null) && (myDefinition != null)) {
     myParameter = (Parameter) myDefinition.getParam(parameter);
     }
    
     if (myParameter != null) {
     directInclude = myParameter.getIsDirect();
     }
    
     try {
     // if parameter is direct, print to out
     if (directInclude && (myParameter != null)) {
     context.getOut()
     .print(myParameter.getParamValue());
     }
     // if parameter is indirect, include results of dispatching to page
     else {
     if ((myParameter != null) && (myParameter.getParamValue() != null)) {
     context.include(myParameter.getParamValue());
     }
     }
     } catch (Exception ex) {
     Throwable rootCause = null;
    
     if (ex instanceof ServletException) {
     rootCause = ((ServletException) ex).getRootCause();
     }
    
     throw new JspTagException(ex.getMessage(), rootCause);
     }
     }
    }
    


    Another change I made was to put jsp extension to the file screendefinitions.jspf. Now is screendefinitions.jsp and is as follow,

    <tt:mydefinition name="bank" screen='<%= (String)request.getAttribute("selectedScreen") %>'>
     <tt:myscreen screenId="/main">
     <tt:myparameter paramName="title" paramValue="Duke's Bank" direct="true"/>
     <tt:myparameter paramName="banner" paramValue="/template/banner.jsp" direct="false"/>
     <tt:myparameter paramName="links" paramValue="/template/links.jsp" direct="false"/>
     <tt:myparameter paramName="body" paramValue="/main.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/transferAck">
     <tt:myparameter paramName="title" paramValue="TransferSucceeded" direct="true"/>
     <tt:myparameter paramName="banner" paramValue="/template/banner.jsp" direct="false"/>
     <tt:myparameter paramName="links" paramValue="/template/links.jsp" direct="false"/>
     <tt:myparameter paramName="body" paramValue="/transferAck.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/transferFunds">
     <tt:myparameter paramName="title" paramValue="TransferFunds" direct="true"/>
     <tt:myparameter paramName="banner" paramValue="/template/banner.jsp" direct="false"/>
     <tt:myparameter paramName="links" paramValue="/template/links.jsp" direct="false"/>
     <tt:myparameter paramName="body" paramValue="/transferFunds.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/atmAck">
     <tt:myparameter paramName="title" paramValue="WDSucceeded" direct="true"/>
     <tt:myparameter paramName="banner" paramValue="/template/banner.jsp" direct="false"/>
     <tt:myparameter paramName="links" paramValue="/template/links.jsp" direct="false"/>
     <tt:myparameter paramName="body" paramValue="/atmAck.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/atm">
     <tt:myparameter paramName="title" paramValue="WD" direct="true"/>
     <tt:myparameter paramName="banner" paramValue="/template/banner.jsp" direct="false"/>
     <tt:myparameter paramName="links" paramValue="/template/links.jsp" direct="false"/>
     <tt:myparameter paramName="body" paramValue="/atm.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/accountHist">
     <tt:myparameter paramName="title" paramValue="AccountHistory" direct="true"/>
     <tt:myparameter paramName="banner" paramValue="/template/banner.jsp" direct="false"/>
     <tt:myparameter paramName="links" paramValue="/template/links.jsp" direct="false"/>
     <tt:myparameter paramName="body" paramValue="/accountHist.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/accountList">
     <tt:myparameter paramName="title" paramValue="AccountList" direct="true"/>
     <tt:myparameter paramName="banner" paramValue="/template/banner.jsp" direct="false"/>
     <tt:myparameter paramName="links" paramValue="/template/links.jsp" direct="false"/>
     <tt:myparameter paramName="body" paramValue="/accountList.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/logoff">
     <tt:myparameter paramName="title" paramValue="Logoff" direct="true"/>
     <tt:myparameter paramName="banner" paramValue="/template/banner.jsp" direct="false"/>
     <tt:myparameter paramName="links" paramValue="/template/nolinks.jsp" direct="false"/>
     <tt:myparameter paramName="body" paramValue="/logoff.jsp" direct="false"/>
     </tt:myscreen>
    </tt:mydefinition>
    


    As you can see my code does not has any line of jsp code yet. I think is the right way considering the tutorials I have been reading over there.

    Please help about this exception. I think I am close to the solution.

    Thanks and best regards,
    Jose Alvarez de Lara

  • 8. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Hi,

    I have got it!!!

    As the thread has a lot of visits, can I post the solution about the web client?

    Best regards,
    Jose Alvarez de Lara

  • 9. Re: jboss-dukes-bank app
    jaikiran pai Master

     

    "pepelara" wrote:

    As the thread has a lot of visits, can I post the solution about the web client?



    Sure, feel free to post the solution which might help others :)

  • 10. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Hi,

    You will have to download the "J2EE 1.4 Tutorial Update 2 (for Sun Java System Application Server Platform Edition 8 Update 1) June 22, 2004". The link is
    http://java.sun.com/j2ee/1.4/previous_downloads.html. You will find it at the bottom of the page.

    You can find a tutorial about the Duke’s Bank on
    http://www.student.nada.kth.se/~d95-cro/j2eetutorial14/doc/Ebank.html

    The first thing you have to do is protecting the Web Client Resources. I have used MySQL as follow,

    #1.- Create two tables
    -users, with two fields (username, passwd) and fill the table with the users as your own. In my case I followed the tutorial,

    username passwd
    200 j2ee
    admin admin

    and some other users that I have created on the desktop client. I mean (201, 201), (164, 164), etc where user and pass are the same value

    -userroles, with two fields (username, userRoles) and fill the table as follow

    username userRoles
    200 bankCustomer
    admin bankAdmin

    and the rest of the users with the role bankCustomer.

    #2.- The next step is setup the datasource and security policy on JBoss

    In your mysql-ds.xml, in the directory jboss-4.2.2.GA\server\default\deploy create de datasource as follow,

    <datasources>
    <local-tx-datasource>
    <jndi-name>DefaultDS</jndi-name>
    <connection-url>jdbc:mysql://localhost:3306/yourDB</connection-url>
    <driver-class>com.mysql.jdbc.Driver</driver-class>
    <user-name>yourUser</user-name>
    <password>yourPasswd</password>
     <exception-sorter-class-name>
    org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter
     </exception-sorter-class-name>
     <metadata>
     <type-mapping>mySQL</type-mapping>
     </metadata>
    </local-tx-datasource>
    </datasources>
    


    And the security policy, in the directory jboss-4.2.2.GA\server\default\conf\login-config.xml, as follow,

    <application-policy name="dukesbank">
     <authentication>
     <login-module code="org.jboss.security.auth.spi.DatabaseServerLoginModule" flag="required">
     <module-option name="dsJndiName">java:/DefaultDS</module-option>
     <module-option name="principalsQuery">
     select passwd from Users where username=?
     </module-option>
     <module-option name="rolesQuery">
     select userRoles,'Roles' from UserRoles where username=?
     </module-option>
     </login-module>
     </authentication>
     </application-policy>
    


    #3.- Now the structure of our application

    I have developed the application on Eclipse 3.2.2 IDE so my tree is as follow,

    The root of the application will be the name of it. I named it JBossDukesBank. So,

    JBossDukesBank
     src
     com.sun.ebank.appclient
     BankAdmin.java
     DataModel.java
     EventHandle.java
     AdminMessages_es.properties
     AdminMessages.properties
     com.sun.ebank.ejb.account
     Account.java
     AccountBean.java
     AccountController.java
     AccountControllerBean.java
     AccountControllerHome.java
     AccountHome.java
     com.sun.ebank.ejb.customer
     Customer.java
     CustomerBean.java
     CustomerController.java
     CustomerControllerBean.java
     CustomerControllerHome.java
     CustomerHome.java
     com.sun.ebank.ejb.exception
     (All the ejb exception classes)
     com.sun.ebank.ejb.tx
     Tx.java
     TxBean.java
     TxController.java
     TxControllerBean.java
     TxControllerHome.java
     TxHome.java
     com.sun.ebank.util
     AccountDetails.java
     CodedNames.java
     CustomerDetails.java
     DateHelper.java
     DBHelper.java
     Debug.java
     DomainUtil.java
     EJBGetter.java
     TxDetails.java
     com.sun.ebank.web
     AccountHistoryBean.java
     ATMBean.java
     BeanManager.java
     ContextListener.java
     CustomerBean.java
     DateHelper.java
     Dispatcher.java
     TransferBean.java
     WebMessages_en.properties
     WebMessages_es.properties
     WebMesages.properties
     com.sun.ebank.web.template
     Debug.java
     Definition.java
     DefinitionTag.java
     InsertTag.java
     Parameter.java
     ParameterTag.java
     ScreenTag.java
    


    Now you have to import the jars. From the folder /server/default/lib all jars and from /client/, jboss-client.jar, jbossall-client.jar and jbossws-common.jar. I am not sure if needed but my app works ok.

    Following, I have created some other folders on the structure tree. The dd (deployment descriptors) folder,

    dd
     client
     application-client.xml
     jboss-client.xml
     client-app
     application.xml
     ejb
     ejb-jar.xml
     web-app
     application.xml
    


    dd/client/application-client.xml.-

    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE application-client PUBLIC
     '-//Sun Microsystems, Inc.//DTD J2EE Application Client 1.3//EN'
     'http://java.sun.com/dtd/application-client_1_3.dtd'>
    <application-client>
     <display-name>BankAdmin</display-name>
     <ejb-ref>
     <ejb-ref-name>ejb/CustomerControllerEJB</ejb-ref-name>
     <ejb-ref-type>Session</ejb-ref-type>
     <home>com.sun.ebank.ejb.customer.CustomerControllerHome</home>
     <remote>com.sun.ebank.ejb.customer.CustomerController</remote>
     </ejb-ref>
    
     <ejb-ref>
     <ejb-ref-name>ejb/AccountControllerEJB</ejb-ref-name>
     <ejb-ref-type>Session</ejb-ref-type>
     <home>com.sun.ebank.ejb.account.AccountControllerHome</home>
     <remote>com.sun.ebank.ejb.account.AccountController</remote>
     </ejb-ref>
    
     <ejb-ref>
     <ejb-ref-name>ejb/TxControllerEJB</ejb-ref-name>
     <ejb-ref-type>Session</ejb-ref-type>
     <home>com.sun.ebank.ejb.tx.TxControllerHome</home>
     <remote>com.sun.ebank.ejb.tx.TxController</remote>
     </ejb-ref>
    </application-client>
    


    dd/client/jboss-client.xml.-

    <jboss-client>
     <jndi-name>bank-client</jndi-name>
    
     <ejb-ref>
     <ejb-ref-name>ejb/AccountControllerEJB</ejb-ref-name>
     <jndi-name>accountController</jndi-name>
     </ejb-ref>
    
     <ejb-ref>
     <ejb-ref-name>ejb/CustomerControllerEJB</ejb-ref-name>
     <jndi-name>customerController</jndi-name>
     </ejb-ref>
    
     <ejb-ref>
     <ejb-ref-name>ejb/TxControllerEJB</ejb-ref-name>
     <jndi-name>txController</jndi-name>
     </ejb-ref>
    
    </jboss-client>
    


    dd/client-app/application.xml.-

    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
     <display-name>JBossDukesBank-Client</display-name>
     <description>Application description</description>
     <module>
     <ejb>bank-ejb.jar</ejb>
     </module>
     <module>
     <java>bank-client.jar</java>
     </module>
     <security-role>
     <role-name>bankCustomer</role-name>
     </security-role>
    </application>
    


    dd/ejb/ejb-jar.xml.-

    <?xml version="1.0" encoding="UTF-8"?>
    <ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee" version="2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
    <display-name>DukesBankEJBJAR</display-name>
    <enterprise-beans>
     <entity>
     <ejb-name>AccountEJB</ejb-name>
     <local-home>com.sun.ebank.ejb.account.AccountHome</local-home>
     <local>com.sun.ebank.ejb.account.Account</local>
     <ejb-class>com.sun.ebank.ejb.account.AccountBean</ejb-class>
     <persistence-type>Bean</persistence-type>
     <prim-key-class>java.lang.String</prim-key-class>
     <reentrant>false</reentrant>
     <resource-ref>
     <description>Conexion BD</description>
     <res-ref-name>jdbc/DefaultDS</res-ref-name>
     <res-type>javax.sql.DataSource</res-type>
     <jndi-name>java:/DefaultDS</jndi-name>
     <res-auth>Container</res-auth>
     </resource-ref>
     </entity>
     <entity>
     <ejb-name>CustomerEJB</ejb-name>
     <local-home>com.sun.ebank.ejb.customer.CustomerHome</local-home>
     <local>com.sun.ebank.ejb.customer.Customer</local>
     <ejb-class>com.sun.ebank.ejb.customer.CustomerBean</ejb-class>
     <persistence-type>Bean</persistence-type>
     <prim-key-class>java.lang.String</prim-key-class>
     <reentrant>false</reentrant>
     <resource-ref>
     <description>Conexion BD</description>
     <res-ref-name>jdbc/DefaultDS</res-ref-name>
     <res-type>javax.sql.DataSource</res-type>
     <jndi-name>java:/DefaultDS</jndi-name>
     <res-auth>Container</res-auth>
     </resource-ref>
     </entity>
     <entity>
     <ejb-name>TxEJB</ejb-name>
     <local-home>com.sun.ebank.ejb.tx.TxHome</local-home>
     <local>com.sun.ebank.ejb.tx.Tx</local>
     <ejb-class>com.sun.ebank.ejb.tx.TxBean</ejb-class>
     <persistence-type>Bean</persistence-type>
     <prim-key-class>java.lang.String</prim-key-class>
     <reentrant>false</reentrant>
     <resource-ref>
     <description>Conexion BD</description>
     <res-ref-name>jdbc/DefaultDS</res-ref-name>
     <res-type>javax.sql.DataSource</res-type>
     <jndi-name>java:/DefaultDS</jndi-name>
     <res-auth>Container</res-auth>
     </resource-ref>
     </entity>
     <session>
     <ejb-name>AccountControllerEJB</ejb-name>
     <home>com.sun.ebank.ejb.account.AccountControllerHome</home>
     <remote>com.sun.ebank.ejb.account.AccountController</remote>
     <ejb-class>com.sun.ebank.ejb.account.AccountControllerBean</ejb-class>
     <session-type>Stateful</session-type>
     <transaction-type>Bean</transaction-type>
     <ejb-local-ref>
     <ejb-ref-name>ejb/AccountEJB</ejb-ref-name>
     <ejb-ref-type>Entity</ejb-ref-type>
     <local-home>AccountHome</local-home>
     <local>Account</local>
     <ejb-link>AccountEJB</ejb-link>
     </ejb-local-ref>
     <ejb-local-ref>
     <ejb-ref-name>ejb/CustomerEJB</ejb-ref-name>
     <ejb-ref-type>Entity</ejb-ref-type>
     <local-home>CustomerHome</local-home>
     <local>Customer</local>
     <ejb-link>CustomerEJB</ejb-link>
     </ejb-local-ref>
     </session>
     <session>
     <ejb-name>CustomerControllerEJB</ejb-name>
     <home>com.sun.ebank.ejb.customer.CustomerControllerHome</home>
     <remote>com.sun.ebank.ejb.customer.CustomerController</remote>
     <ejb-class>com.sun.ebank.ejb.customer.CustomerControllerBean</ejb-class>
     <session-type>Stateful</session-type>
     <transaction-type>Bean</transaction-type>
     <ejb-local-ref>
     <ejb-ref-name>ejb/CustomerEJB</ejb-ref-name>
     <ejb-ref-type>Entity</ejb-ref-type>
     <local-home>CustomerHome</local-home>
     <local>Customer</local>
     <ejb-link>CustomerEJB</ejb-link>
     </ejb-local-ref>
     </session>
     <session>
     <ejb-name>TxControllerEJB</ejb-name>
     <home>com.sun.ebank.ejb.tx.TxControllerHome</home>
     <remote>com.sun.ebank.ejb.tx.TxController</remote>
     <ejb-class>com.sun.ebank.ejb.tx.TxControllerBean</ejb-class>
     <session-type>Stateful</session-type>
     <transaction-type>Bean</transaction-type>
     <ejb-local-ref>
     <ejb-ref-name>ejb/TxEJB</ejb-ref-name>
     <ejb-ref-type>Entity</ejb-ref-type>
     <local-home>TxHome</local-home>
     <local>Tx</local>
     <ejb-link>TxEJB</ejb-link>
     </ejb-local-ref>
     <ejb-local-ref>
     <ejb-ref-name>ejb/AccountEJB</ejb-ref-name>
     <ejb-ref-type>Entity</ejb-ref-type>
     <local-home>AccountHome</local-home>
     <local>Account</local>
     <ejb-link>AccountEJB</ejb-link>
     </ejb-local-ref>
     </session>
    </enterprise-beans>
    </ejb-jar>
    


    dd/web-app/application.xml.-

    <?xml version="1.0" encoding="UTF-8"?>
    <application xmlns="http://java.sun.com/xml/ns/j2ee" version="1.4"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com /xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd">
     <display-name>JBossDukesBank-WEB</display-name>
     <description>Application description</description>
     <module>
     <ejb>bank-ejb.jar</ejb>
     </module>
     <module>
     <web>
     <web-uri>bank-web.war</web-uri>
     <context-root>bank</context-root>
     </web>
     </module>
     <security-role>
     <role-name>bankCustomer</role-name>
     </security-role>
    </application>
    


    I use this folder to build the ear (JBossDukesBank.ear) that I will explain later.

    And at last, the WebContent folder. This folder is the ROOT of the JSP pages and its structure is the same that you have downloaded. It looks like this,


    WebContent
    *.jsp
    WebMessages*.properties
    template
    *.jsp
    *.jspf
    WEB-INF
    classes
    - the compiled classes of the web app
    lib
    jstl.jar
    standard.jar
    tags
    tutorial-template.tld
    jboss-web.xml
    web.xml
    
    jboss-web.xml.-
    
    

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE jboss-web PUBLIC
    "-//JBoss//DTD Web Application 2.3V2//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-web_3_2.dtd">
    <jboss-web>
    <!-- Uncomment this element to add security for the application -->
    <security-domain>java:/jaas/dukesbank</security-domain>

    <resource-ref>
    Conexion BD
    <res-ref-name>jdbc/DefaultDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <jndi-name>java:/DefaultDS</jndi-name>
    </resource-ref>
    </jboss-web>
    
    web.xml.-
    
    

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app>
    <display-name>JBoss DukesBankWAR</display-name>
    <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>WebMessages</param-value>
    </context-param>


    <display-name>Dispatcher</display-name>
    <servlet-name>Dispatcher</servlet-name>
    <servlet-class>com.sun.ebank.web.Dispatcher</servlet-class>


    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/accountHist</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/accountList</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/atm</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/atmAck</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/main</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/transferAck</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/transferFunds</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/logon</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/logonError</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/logoff</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
    <servlet-name>Dispatcher</servlet-name>
    <url-pattern>/error</url-pattern>
    </servlet-mapping>

    <jsp-config>
    <jsp-property-group>
    <display-name>bank</display-name>
    <url-pattern>*.jsp</url-pattern>
    <el-enabled>true</el-enabled>
    <scripting-enabled>true</scripting-enabled>
    <include-prelude>/template/prelude.jspf</include-prelude>
    </jsp-property-group>
    </jsp-config>

    <!--#Security constraints -->
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>User Authentication Policy</web-resource-name>
    <url-pattern>/*</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>*</role-name>
    </auth-constraint>
    </security-constraint>

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Bank Customers Authentication Policy</web-resource-name>
    <url-pattern>/template/*</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>bankCustomer</role-name>
    </auth-constraint>
    </security-constraint>

    <security-role>
    <role-name>bankCustomer</role-name>
    </security-role>

    <welcome-file-list>
    <welcome-file>/main.jsp</welcome-file>
    </welcome-file-list>

    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>Duke's Bank</realm-name>
    <form-login-config>
    <form-login-page>/logon.jsp</form-login-page>
    <form-error-page>/logonError.jsp</form-error-page>
    </form-login-config>
    </login-config>

    <error-page>
    <error-code>404</error-code>
    /template/errorpage.jsp
    </error-page>
    <error-page>
    <exception-type>java.lang.Throwable</exception-type>
    /template/errorpage.jsp
    </error-page>


    <taglib-uri>http://java.sun.com/jsp/jstl/fmt</taglib-uri>
    <taglib-location>/WEB-INF/lib/fmt.tld</taglib-location>


    <taglib-uri>http://java.sun.com/jsp/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/lib/c.tld</taglib-location>


    <ejb-ref>
    <ejb-ref-name>ejb/AccountControllerEJB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    com.sun.ebank.ejb.account.AccountControllerHome
    com.sun.ebank.ejb.account.AccountController
    <ejb-link>AccountControllerEJB</ejb-link>
    </ejb-ref>

    <ejb-ref>
    <ejb-ref-name>ejb/CustomerControllerEJB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    com.sun.ebank.ejb.customer.CustomerControllerHome
    com.sun.ebank.ejb.customer.CustomerController
    <ejb-link>CustomerControllerEJB</ejb-link>
    </ejb-ref>

    <ejb-ref>
    <ejb-ref-name>ejb/TxControllerEJB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    com.sun.ebank.ejb.tx.TxControllerHome
    com.sun.ebank.ejb.tx.TxController
    <ejb-link>TxControllerEJB</ejb-link>
    </ejb-ref>

    <resource-ref>
    Conexion BD
    <res-ref-name>jdbc/DefaultDS</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    </web-app>
    
    In the web.xml you have to put attention on the stanzas,
    
    

    <jsp-config>
    <jsp-property-group>
    <display-name>bank</display-name>
    <url-pattern>*.jsp</url-pattern>
    <el-enabled>true</el-enabled>
    <scripting-enabled>true</scripting-enabled>
    <include-prelude>/template/prelude.jspf</include-prelude>
    </jsp-property-group>
    </jsp-config>
    
    Here I let in my JSPs both JSP scripting and JSTL EL.
    
    

    <!--#Security constraints -->
    <security-constraint>
    <web-resource-collection>
    <web-resource-name>User Authentication Policy</web-resource-name>
    <url-pattern>/*</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>*</role-name>
    </auth-constraint>
    </security-constraint>

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>Bank Customers Authentication Policy</web-resource-name>
    <url-pattern>/template/*</url-pattern>
    <http-method>GET</http-method>
    <http-method>POST</http-method>
    </web-resource-collection>
    <auth-constraint>
    <role-name>bankCustomer</role-name>
    </auth-constraint>
    </security-constraint>

    <security-role>
    <role-name>bankCustomer</role-name>
    </security-role>
    
    My idea was to authenticate just one time but the web client need authentication in two steps: when login and when you start to operate with the accounts. Once you start to operate you can feel free. By the other hand I have just declared one role as bankCustomer.
    
    

    <login-config>
    <auth-method>FORM</auth-method>
    <realm-name>Duke's Bank</realm-name>
    <form-login-config>
    <form-login-page>/logon.jsp</form-login-page>
    <form-error-page>/logonError.jsp</form-error-page>
    </form-login-config>
    </login-config>
    
    <auth-method>FORM</auth-method> means the way you have to authenticate. Here you reach an interesting point that is the logon.jsp. I am going to explain,
    
    

    <%@ include file="/template/prelude.jspf/" %>



    <fmt:message key="TitleLogon"/>



    <h3><fmt:message key="Logon"/> <fmt:message key="Submit"/>.</h3>
    <form action="j_security_check" method=post>





    <fmt:message key="CustomerId"/>





    <fmt:message key="Password"/>







    <input type="submit" value="<fmt:message key="Submit"/>">












    
    When you put in your browser the URL http://localhost:8080/main you are redirect to the form logon.jsp just only to authenticate and nothing else. Later you go to the dispatcher to follow the flow of the application. I mean, the form is just one automatic step to go inside the application. All I have explained at the begining is prepare for just this step.
    
    And this is the application.
    
    Changes in the code.-
    
    CodedNames.java
    
    

    package com.sun.ebank.util;

    /**
    * This interface defines names in code used as args for lookup().
    */
    public interface CodedNames {
    public static final String BANK_DATABASE = "java:/DefaultDS";
    public static final String ACCOUNT_EJB = "java:comp/env/ejb/AccountEJB";
    public static final String ACCOUNT_CONTROLLER_EJB = "AccountControllerEJB";
    public static final String CUSTOMER_EJB = "java:comp/env/ejb/CustomerEJB";
    public static final String CUSTOMER_CONTROLLER_EJB = "CustomerControllerEJB";
    public static final String TX_EJB = "java:comp/env/ejb/TxEJB";
    public static final String TX_CONTROLLER_EJB = "TxControllerEJB";
    }
    
    As you can see to call the Session Bean I use the name declared in the ejb-jar.xml but when I call the Entity Beans I use java:comp/…
    
    EJBGetter.java
    
    


    package com.sun.ebank.util;

    import java.util.Properties;
    import javax.rmi.PortableRemoteObject;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import com.sun.ebank.ejb.account.AccountHome;
    import com.sun.ebank.ejb.account.AccountControllerHome;
    import com.sun.ebank.ejb.customer.CustomerHome;
    import com.sun.ebank.ejb.customer.CustomerControllerHome;
    import com.sun.ebank.ejb.tx.TxHome;
    import com.sun.ebank.ejb.tx.TxControllerHome;
    import com.sun.ebank.util.Debug;

    /**
    * This helper class fetches EJB home references.
    */
    public final class EJBGetter {
    public static AccountHome getAccountHome() throws NamingException {
    InitialContext initial = new InitialContext();
    Object objref = initial.lookup(CodedNames.ACCOUNT_EJB);
    return (AccountHome)objref;
    }

    public static AccountControllerHome getAccountControllerHome()
    throws NamingException {
    Context initial = getInitialContext();
    Object objref = initial.lookup(CodedNames.ACCOUNT_CONTROLLER_EJB);
    return (AccountControllerHome) PortableRemoteObject.narrow(objref,
    AccountControllerHome.class);
    }

    public static CustomerHome getCustomerHome() throws NamingException {
    InitialContext initial = new InitialContext();
    Object objref = initial.lookup(CodedNames.CUSTOMER_EJB);
    return (CustomerHome)objref;
    }

    public static CustomerControllerHome getCustomerControllerHome()
    throws NamingException {
    Context initial = getInitialContext();
    Object objref = initial.lookup(CodedNames.CUSTOMER_CONTROLLER_EJB);
    return (CustomerControllerHome) PortableRemoteObject.narrow(objref,
    CustomerControllerHome.class);
    }

    public static TxHome getTxHome() throws NamingException {
    InitialContext initial = new InitialContext();
    return (TxHome)objref;
    }

    public static TxControllerHome getTxControllerHome()
    throws NamingException {
    Context initial = getInitialContext();
    Object objref = initial.lookup(CodedNames.TX_CONTROLLER_EJB);
    return (TxControllerHome) PortableRemoteObject.narrow(objref,
    TxControllerHome.class);
    }

    private static Context getInitialContext(){
    Context ctx = null;

    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
    env.put(Context.PROVIDER_URL, "localhost:1099");
    env.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
    env.put("j2ee.clientName", "bank-client");

    try {
    // Get an initial context
    ctx = new InitialContext(env);
    System.out.println("Got context");
    Debug.print("Obtenido Contexto: ", ctx);
    } catch (NamingException ne) {
    // TODO Auto-generated catch block
    System.out.println("Did not get context");
    ne.printStackTrace();
    }

    return ctx;
    }
    }
    // EJBGetter
    
    As you can see, to call the Session Bean I first setup the InitialContext and return the Home Interface using PortableRemoteObject.narrow. But when I call the Entity Beans I do not.
    
    Changes on the web client.
    
    Dispatcher.java
    
    

    package com.sun.ebank.web;

    import javax.servlet.http.*;
    import com.sun.ebank.util.Debug;
    import java.util.*;
    import java.math.BigDecimal;

    public class Dispatcher extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) {
    HttpSession session = request.getSession(true);

    BeanManager beanManager =
    (BeanManager) session.getAttribute("beanManager");

    if (beanManager == null) {
    Debug.print("Creating bean manager.");
    beanManager = new BeanManager();
    session.setAttribute("beanManager", beanManager);
    }

    String selectedScreen = request.getServletPath();
    Debug.print(selectedScreen);

    CustomerBean customerBean = new CustomerBean();
    customerBean.setBeanManager(beanManager);
    request.setAttribute("customerBean", customerBean);

    if (selectedScreen.equals("/accountHist")) {
    AccountHistoryBean accountHistoryBean = new AccountHistoryBean();

    try {
    accountHistoryBean.setBeanManager(beanManager);
    accountHistoryBean.setCustomerBean(customerBean);
    accountHistoryBean.setAccountId(request.getParameter(
    "accountId"));
    accountHistoryBean.setSortOption(Integer.parseInt(
    request.getParameter("sortOption")));
    accountHistoryBean.setActivityView(Integer.parseInt(
    request.getParameter("activityView")));
    accountHistoryBean.setDate(Integer.parseInt(
    request.getParameter("date")));
    accountHistoryBean.setYear(Integer.parseInt(
    request.getParameter("year")));
    accountHistoryBean.setSinceDay(Integer.parseInt(
    request.getParameter("sinceDay")));
    accountHistoryBean.setSinceMonth(Integer.parseInt(
    request.getParameter("sinceMonth")));
    accountHistoryBean.setBeginDay(Integer.parseInt(
    request.getParameter("beginDay")));
    accountHistoryBean.setBeginMonth(Integer.parseInt(
    request.getParameter("beginMonth")));
    accountHistoryBean.setEndDay(Integer.parseInt(
    request.getParameter("endDay")));
    accountHistoryBean.setEndMonth(Integer.parseInt(
    request.getParameter("endMonth")));
    } catch (NumberFormatException e) {
    }

    accountHistoryBean.doTx();
    request.setAttribute("accountHistoryBean", accountHistoryBean);

    } else if(selectedScreen.equals("/logoff")) {
    try {
    Debug.print("Forwarding to template from doGet().");
    request.getRequestDispatcher("/logoff.jsp")
    .forward(request, response);
    } catch (Exception ex) {
    }
    }

    try {
    Debug.print("Forwarding to template from doGet().");
    request.getRequestDispatcher("/template/template.jsp")
    .forward(request, response);
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    }

    public void doPost(HttpServletRequest request, HttpServletResponse response) {
    HttpSession session = request.getSession(true);

    ResourceBundle messages =
    (ResourceBundle) session.getAttribute("messages");

    if (messages == null) {
    Locale locale = request.getLocale();
    Debug.print(locale.getDisplayName());
    messages = ResourceBundle.getBundle("com.sun.ebank.web.WebMessages", locale);

    if (messages == null) {
    Debug.print("Didn't locate resource bundle.");
    }

    session.setAttribute("messages", messages);
    }

    String selectedScreen = request.getServletPath();
    Debug.print(selectedScreen);

    BeanManager beanManager =
    (BeanManager) session.getAttribute("beanManager");

    if (beanManager == null) {
    beanManager = new BeanManager();
    session.setAttribute("beanManager", beanManager);
    }

    CustomerBean customerBean = new CustomerBean();
    customerBean.setBeanManager(beanManager);
    request.setAttribute("customerBean", customerBean);

    if (selectedScreen.equals("/accountHist")) {
    AccountHistoryBean accountHistoryBean = new AccountHistoryBean();

    try {
    accountHistoryBean.setBeanManager(beanManager);
    accountHistoryBean.setCustomerBean(customerBean);
    accountHistoryBean.setAccountId(request.getParameter(
    "accountId"));
    accountHistoryBean.setSortOption(Integer.parseInt(
    request.getParameter("sortOption")));
    accountHistoryBean.setActivityView(Integer.parseInt(
    request.getParameter("activityView")));
    accountHistoryBean.setYear(Integer.parseInt(
    request.getParameter("year")));
    accountHistoryBean.setDate(Integer.parseInt(
    request.getParameter("date")));
    accountHistoryBean.setSinceDay(Integer.parseInt(
    request.getParameter("sinceDay")));
    accountHistoryBean.setSinceMonth(Integer.parseInt(
    request.getParameter("sinceMonth")));
    accountHistoryBean.setBeginDay(Integer.parseInt(
    request.getParameter("beginDay")));
    accountHistoryBean.setBeginMonth(Integer.parseInt(
    request.getParameter("beginMonth")));
    accountHistoryBean.setEndDay(Integer.parseInt(
    request.getParameter("endDay")));
    accountHistoryBean.setEndMonth(Integer.parseInt(
    request.getParameter("endMonth")));
    } catch (NumberFormatException e) {
    // Not possible
    }

    accountHistoryBean.doTx();
    request.setAttribute("accountHistoryBean", accountHistoryBean);

    } else if (selectedScreen.equals("/transferAck")) {
    String fromAccountId = (String)request.getParameter("fromAccountId");
    String toAccountId = (String)request.getParameter("toAccountId");

    if ((fromAccountId == null) || (toAccountId == null)) {
    request.setAttribute("errorMessage",
    messages.getString("AccountError"));

    try {
    request.getRequestDispatcher("/error.jsp")
    .forward(request, response);
    } catch (Exception ex) {
    }
    } else {
    TransferBean transferBean = new TransferBean();

    try {
    transferBean.setMessages(messages);
    transferBean.setBeanManager(beanManager);
    transferBean.setFromAccountId(fromAccountId);
    transferBean.setToAccountId(toAccountId);
    transferBean.setTransferAmount((new BigDecimal(
    request.getParameter("transferAmount"))).setScale(2));

    String errorMessage = transferBean.doTx();

    if (errorMessage != null) {
    request.setAttribute("errorMessage", errorMessage);

    try {
    request.getRequestDispatcher("/error.jsp")
    .forward(request, response);
    } catch (Exception ex) {
    }
    }

    request.setAttribute("transferBean", transferBean);

    } catch (NumberFormatException e) {
    request.setAttribute("errorMessage",
    messages.getString("AmountError"));

    try {
    request.getRequestDispatcher("/error.jsp")
    .forward(request, response);
    } catch (Exception ex) {
    }
    }
    }
    } else if (selectedScreen.equals("/atmAck")) {
    ATMBean atmBean = new ATMBean();

    try {
    customerBean.setBeanManager(beanManager);
    atmBean.setMessages(messages);
    atmBean.setBeanManager(beanManager);
    atmBean.setCustomerBean(customerBean);
    atmBean.setAccountId(request.getParameter("accountId"));
    atmBean.setAmount((new BigDecimal(request.getParameter("amount"))).setScale(
    2));
    atmBean.setOperation(Integer.parseInt(request.getParameter(
    "operation")));

    String errorMessage = atmBean.doTx();

    if (errorMessage != null) {
    request.setAttribute("errorMessage", errorMessage);

    try {
    request.getRequestDispatcher("/error.jsp")
    .forward(request, response);
    } catch (Exception ex) {
    }
    }

    request.setAttribute("atmBean", atmBean);

    } catch (NumberFormatException e) {
    request.setAttribute("errorMessage",
    messages.getString("AmountError"));

    try {
    request.getRequestDispatcher("/error.jsp")
    .forward(request, response);
    } catch (Exception ex) {
    }
    }
    }

    try {
    Debug.print("Forwarding to template from doPost().");
    request.getRequestDispatcher("/template/template.jsp")
    .forward(request, response);
    } catch (Exception ex) {
    }
    }
    }
    
    In the doGet() method I wrote the logoff option. It did not come in the downloaded code.
    
    I did changes in the package com.sun.ebank.web.template where the Tag Libs
    are declared but I am not sure if it is needed. The changes are as follow (you can compare with the downloaded code).
    
    DefinitionTag.java
    

    public class DefinitionTag extends SimpleTagSupport {
    private String definitionName = null;
    private String screenId = null;
    private HashMap screens = null;

    public DefinitionTag() {
    super();
    }

    public HashMap getScreens() {
    return screens;
    }

    public void setName(String name) {
    this.definitionName = name;
    }

    public void setScreen(String screenId) {
    this.screenId = screenId;
    }

    public String getName() {
    return this.definitionName;
    }

    public String getScreen(PageContext context) {
    return (String)context.getRequest().getAttribute(this.screenId);
    }

    public void doTag() {
    try {
    screens = new HashMap();

    getJspBody().
    invoke(null);

    Definition myDefinition = new Definition();
    PageContext context = (PageContext) getJspContext();
    String screenId = getScreen(context);
    ArrayList params = (ArrayList) screens.get(screenId);
    Iterator ir = null;

    if (params != null) {
    ir = params.iterator();

    while (ir.hasNext())
    myDefinition.setParam((Parameter) ir.next());

    // put the definition in the page context
    context.setAttribute(definitionName, myDefinition,
    context.APPLICATION_SCOPE);
    } else {
    Debug.println("DefinitionTag: params are not defined.");
    }
    } catch (Exception ex) {
    ex.printStackTrace();
    }
    }
    }
    
    InsertTag.java
    

    public class InsertTag extends SimpleTagSupport {
    private String parameterName = null;
    private String definitionName = null;

    public InsertTag() {
    super();
    }

    public void setParameter(String parameter) {
    this.parameterName = parameter;
    }

    public void setDefinition(String name) {
    this.definitionName = name;
    }

    public String getParameter() {
    return this.parameterName;
    }

    public String getDefinition() {
    return this.definitionName;
    }

    public void doTag() throws JspTagException {
    Definition myDefinition = null;
    Parameter myParameter = null;
    boolean directInclude = false;

    PageContext context = (PageContext) getJspContext();

    // get the definition from the page context
    myDefinition =
    (Definition) context.getAttribute(definitionName,
    context.APPLICATION_SCOPE);

    // get the parameter
    if ((parameterName != null) && (myDefinition != null)) {
    myParameter = (Parameter) myDefinition.getParam(parameterName);
    }

    if (myParameter != null) {
    directInclude = myParameter.isDirect();
    }

    try {
    // if parameter is direct, print to out
    if (directInclude && (myParameter != null)) {
    context.getOut()
    .print(myParameter.getValue());
    }
    // if parameter is indirect, include results of dispatching to page
    else {
    if ((myParameter != null) && (myParameter.getValue() != null)) {
    context.include(myParameter.getValue());
    }
    }
    } catch (Exception ex) {
    Throwable rootCause = null;

    if (ex instanceof ServletException) {
    rootCause = ((ServletException) ex).getRootCause();
    }

    throw new JspTagException(ex.getMessage(), rootCause);
    }
    }
    }
    
    Parameter.java
    

    public class Parameter {
    private String name;
    private boolean isDirect;
    private String value;

    public Parameter(String name, String value, boolean isDirect) {
    this.name = name;
    this.isDirect = isDirect;
    this.value = value;
    }

    public String getName() {
    return name;
    }

    public boolean isDirect() {
    return isDirect;
    }

    public String getValue() {
    return value;
    }
    }
    
    ParameterTag.java
    

    public class ParameterTag extends SimpleTagSupport {
    private String paramName = null;
    private String paramValue = null;
    private String isDirectString = null;

    public ParameterTag() {
    super();
    }

    public void setName(String paramName) {
    this.paramName = paramName;
    }

    public void setValue(String paramValue) {
    this.paramValue = paramValue;
    }

    public void setDirect(String isDirectString) {
    this.isDirectString = isDirectString;
    }

    public void doTag() {
    boolean isDirect = false;

    if ((isDirectString != null) &&
    isDirectString.toLowerCase()
    .equals("true")) {
    isDirect = true;
    }

    try {
    // retrieve the parameters list
    if (paramName != null) {
    ArrayList parameters =
    ((ScreenTag) getParent()).getParameters();

    if (parameters != null) {
    Parameter param =
    new Parameter(paramName, paramValue, isDirect);
    parameters.add(param);
    } else {
    Debug.println("ParameterTag: parameters do not exist.");
    }
    }
    } catch (Exception e) {
    Debug.println("ParameterTag: error in doTag: " + e);
    }
    }
    }
    
    ScreenTag.java
    
    
    public class ScreenTag extends SimpleTagSupport {
     private String screenId;
     private ArrayList parameters = null;
    
     public ScreenTag() {
     super();
     }
    
     public ArrayList getParameters() {
     return parameters;
     }
    
     public void setScreenId(String screenId) {
     this.screenId = screenId;
     }
    
     public void doTag() {
     parameters = new ArrayList();
    
     HashMap screens = (HashMap) ((DefinitionTag) getParent()).getScreens();
    
     if (screens != null) {
     try {
     if (!screens.containsKey(screenId)) {
     screens.put(screenId, parameters);
     }
    
     getJspBody()
     .invoke(null);
     } catch (Exception ex) {
     ex.printStackTrace();
     }
     } else {
     Debug.println("ScreenTag: Unable to get screens object.");
     }
     }
    }
    
    
    
    The tutorial-template.tld left as follow,
    
    <taglib xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
     version="2.0">
     <description>A tag library exercising SimpleTag handlers.</description>
     <tlib-version>1.0</tlib-version>
     <short-name>SimpleTagLibrary</short-name>
     <uri>http://localhost:8080/bank/tags</uri>
     <tag>
     <name>mydefinition</name>
     <tag-class>com.sun.ebank.web.template.DefinitionTag</tag-class>
     <body-content>scriptless</body-content>
     <attribute>
     <name>name</name>
     <required>true</required>
     <rtexprvalue>true</rtexprvalue>
     </attribute>
     <attribute>
     <name>screen</name>
     <required>true</required>
     <rtexprvalue>true</rtexprvalue>
     </attribute>
     </tag>
     <tag>
     <name>myscreen</name>
     <tag-class>com.sun.ebank.web.template.ScreenTag</tag-class>
     <body-content>scriptless</body-content>
     <attribute>
     <name>screenId</name>
     <required>true</required>
     <rtexprvalue>true</rtexprvalue>
     </attribute>
     </tag>
     <tag>
     <name>myparameter</name>
     <tag-class>com.sun.ebank.web.template.ParameterTag</tag-class>
     <body-content>scriptless</body-content>
     <attribute>
     <name>name</name>
     <required>true</required>
     <rtexprvalue>true</rtexprvalue>
     </attribute>
     <attribute>
     <name>value</name>
     <required>true</required>
     <rtexprvalue>true</rtexprvalue>
     </attribute>
     <attribute>
     <name>direct</name>
     <required>true</required>
     <rtexprvalue>true</rtexprvalue>
     </attribute>
     </tag>
     <tag>
     <name>myinsert</name>
     <tag-class>com.sun.ebank.web.template.InsertTag</tag-class>
     <body-content>scriptless</body-content>
     <attribute>
     <name>definition</name>
     <required>true</required>
     <rtexprvalue>true</rtexprvalue>
     </attribute>
     <attribute>
     <name>parameter</name>
     <required>true</required>
     <rtexprvalue>true</rtexprvalue>
     </attribute>
     </tag>
    </taglib>
    
    
    
    And the screendefinitions.jspf changes to screendefinitions.jsp with the following code (no JSP script),
    
    <%@page contentType="text/html" pageEncoding="UTF-8" isELIgnored="false" %>
    
    <tt:mydefinition name="bank" screen="${requestScope['javax.servlet.forward.servlet_path']}">
     <tt:myscreen screenId="/main">
     <tt:myparameter name="title" value="Duke's Bank" direct="true"/>
     <tt:myparameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:myparameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:myparameter name="body" value="/main.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/transferAck">
     <tt:myparameter name="title" value="TransferSucceeded" direct="true"/>
     <tt:myparameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:myparameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:myparameter name="body" value="/transferAck.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/transferFunds">
     <tt:myparameter name="title" value="TransferFunds" direct="true"/>
     <tt:myparameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:myparameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:myparameter name="body" value="/transferFunds.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/atmAck">
     <tt:myparameter name="title" value="WDSucceeded" direct="true"/>
     <tt:myparameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:myparameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:myparameter name="body" value="/atmAck.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/atm">
     <tt:myparameter name="title" value="WD" direct="true"/>
     <tt:myparameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:myparameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:myparameter name="body" value="/atm.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/accountHist">
     <tt:myparameter name="title" value="AccountHistory" direct="true"/>
     <tt:myparameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:myparameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:myparameter name="body" value="/accountHist.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/accountList">
     <tt:myparameter name="title" value="AccountList" direct="true"/>
     <tt:myparameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:myparameter name="links" value="/template/links.jsp" direct="false"/>
     <tt:myparameter name="body" value="/accountList.jsp" direct="false"/>
     </tt:myscreen>
     <tt:myscreen screenId="/logoff">
     <tt:myparameter name="title" value="Logoff" direct="true"/>
     <tt:myparameter name="banner" value="/template/banner.jsp" direct="false"/>
     <tt:myparameter name="links" value="/template/nolinks.jsp" direct="false"/>
     <tt:myparameter name="body" value="/logoff.jsp" direct="false"/>
     </tt:myscreen>
    </tt:mydefinition>
    
    
    
    It is important to understand the needed to put at the top of the page the tag,
    
    
    <%@page contentType="text/html" pageEncoding="UTF-8" isELIgnored="false" %>
    
    
    
    It helps to the page to execute EL code. Put it in all the JSPs that use EL. It is important too that you include, <%@ include file=�/template/prelude.jspf� %> in all the JSPs that use prefix c or fmt
    
    As you can see I use in the <tt:…> satanza the name declared in the tutorial-template.tld
    
    And I think that is all. To end how I build the application. I use an XML Ant file,
    
    jboss-build.xml
    
    <project name="JBossDukesBank" default="all" basedir=".">
    
     <property file="jboss-build.properties"/>
    
     <property name="lib.dir" value="${basedir}/libs"/>
     <property name="src.dir" value="${basedir}/src"/>
     <property name="build.dir" value="${basedir}/build"/>
     <property name="conf.dir" value="${basedir}/dd"/>
     <property name="web.dir" value="${basedir}/web"/>
    
     <property name="web.content.dir" location="${basedir}/WebContent"/>
     <property name="web.inf.dir" location="${web.content.dir}/WEB-INF"/>
     <property name="classes.dir" location="${web.inf.dir}/classes"/>
     <property name="app.lib.dir" location="${web.inf.dir}/lib"/>
     <property name="autentiaApp.lib.dir" location="libs"/>
    
     <!-- The classpath for running the client -->
     <path id="client.classpath">
     <pathelement location="${build.dir}"/>
     <fileset dir="${jboss.home}/client">
     <include name="**/*.jar"/>
     </fileset>
     </path>
    
     <!-- The build classpath -->
     <path id="axis.classpath">
     <pathelement location="${build.dir}"/>
     <fileset dir="/Users/orb/Desktop/axis-1_1/lib">
     <include name="*.jar"/>
     </fileset>
     <fileset dir="${jboss.server}/lib/">
     <include name="javax.servlet*.jar"/>
     </fileset>
     </path>
    
    
     <!-- The build classpath -->
     <path id="build.classpath">
     <path refid="client.classpath"/>
     <fileset dir="${jboss.server}/lib/">
     <include name="javax.servlet*.jar"/>
     </fileset>
     </path>
    
     <!-- MySQL classpath -->
     <path id="mysql.classpath">
     <pathelement location="${jboss.server}/lib/mysql-connector-java-5.1.6-bin.jar"/>
     </path>
    
     <!-- =================================================================== -->
     <!-- Initialises the build. -->
     <!-- =================================================================== -->
    
     <target name="prepare">
     <mkdir dir="${build.dir}"/>
     </target>
    
     <!-- =================================================================== -->
     <!-- Package EJB. -->
     <!-- =================================================================== -->
     <target name="package-ejb">
     <delete file="jar/bank-ejb.jar"/>
    
     <jar jarfile="jar/bank-ejb.jar">
     <metainf dir="${conf.dir}/ejb" includes="**/*.xml" />
    
     <fileset dir="${build.dir}">
     <include name="com/sun/ebank/ejb/account/**"/>
     <include name="com/sun/ebank/ejb/customer/**"/>
     <include name="com/sun/ebank/ejb/tx/**"/>
     <include name="com/sun/ebank/ejb/exception/**"/>
     <include name="com/sun/ebank/util/**"/>
     </fileset>
     </jar>
     </target>
    
     <!-- =================================================================== -->
     <!-- Cliente Desktop. -->
     <!-- =================================================================== -->
     <target name="package-client">
    
     <delete file="jar/bank-client.jar"/>
    
     <copy todir="${build.dir}">
     <fileset dir="${src.dir}">
     <include name="**/appclient/*.properties"/>
     </fileset>
     <mapper type="flatten"/>
     </copy>
    
     <jar jarfile="jar/bank-client.jar">
     <metainf dir="dd/client" includes="*.xml"/>
     <fileset dir="${build.dir}">
     <include name="com/sun/ebank/appclient/**"/>
     </fileset>
     </jar>
     </target>
    
     <!-- =================================================================== -->
     <!-- Cliente Web. -->
     <!-- =================================================================== -->
    
     <macrodef name="package-web">
     <attribute name="war.file.name" default="bank-web.war"/>
     <element name="add.filesets" optional="true"/>
     <sequential>
    
     <delete file="jar/bank-web.war"/>
    
     <copy file="${web.content.dir}/logon.jsp" tofile="${web.content.dir}/logon2.jsp" />
     <copy file="${src.dir}/com/sun/ebank/web/WebMessages.properties"
     tofile="${src.dir}/com/sun/ebank/web/WebMessages_en.properties" />
     <copy todir="${app.lib.dir}" preservelastmodified="true">
     <fileset dir="${autentiaApp.lib.dir}" includes="*.jar" excludes="servlet-api.jar"/>
     </copy>
     <copy todir="${web.content.dir}" preservelastmodified="true">
     <fileset dir="${src.dir}/com/sun/ebank/web/" includes="*.properties" />
     </copy>
    
     <war basedir="${web.content.dir}" destfile="jar/@{war.file.name}" duplicate="fail"
     webxml="${web.inf.dir}/web.xml" excludes="WEB-INF/web.xml">
     <add.filesets/>
     </war>
    
     <!--
     <delete verbose="true">
     <fileset dir="${web.content.dir}/WEB-INF/classes/com/sun/ebank/ejb" includes="**/*.class"/>
     </delete>
    
     <delete verbose="true">
     <fileset dir="${web.content.dir}/WEB-INF/classes/com/sun/ebank/util" includes="**/*.class"/>
     </delete>
     -->
     </sequential>
     </macrodef>
    
     <!-- =================================================================== -->
     <!-- Creates an ear file containing the ejb jars and the clients. -->
     <!-- =================================================================== -->
     <target name="assemble-app">
     <delete file="jar/JBossDukesBank.ear"/>
     <ear destfile="jar/JBossDukesBank.ear" appxml="dd/application.xml">
     <fileset dir="jar" includes="bank-ejb.jar,bank-client.jar,bank-web.war"/>
     </ear>
     </target>
    
     <!-- =================================================================== -->
     <!-- Deploys the EAR file by copying into the jar deploy directory. -->
     <!-- =================================================================== -->
     <target name="deploy">
     <copy file="jar/JBossDukesBank.ear" todir="${basedir}/jar"/>
     </target>
    
     <target name="package-web">
     <package-web/>
     </target>
    
     <target name="all" depends="package-ejb,package-web,package-client,assemble-app,deploy" />
    
    </project>
    
    
    
    As you can see I use three packages: the -ejb.jar that include the EJBs, the package EJBExceptions and the package util. And as stand alone the clients: the desktop client and the web client. When I assemble all together in the JBossDukesBank.ear, both clients have access to the common –ejb.jar
    
    Thanks a lot
    Jose Alvarez de Lara
    
    For any question I will be here.


  • 11. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Excuse me. I forgot to say two things

    Th main.jsp looks like this,

    <%@ include file="/template/prelude.jspf" %>
    
    <% request.getSession().invalidate(); %>
    <center>
    <h3><fmt:message key="Welcome"/></h3>
    </center>
    


    You need to invalidate the session on start

    And the refering jboss-build.properties looks like this,
    # Set the path to the JBoss directory containing the JBoss application server
    # (This is the one containing directories like "bin", "client" etc.)
    
    jboss.home = <your JBoss installed home>
    jboss.server=${jboss.home}/server/default
    jboss.deploy.dir=${jboss.server}/deploy
    


  • 12. Re: jboss-dukes-bank app
    Jose Alvarez de Lara Novice

    Hi,

    If you want to see the banner in the Dukes web app
    you have got to code the banner.jsp as follows,

    <center>
    <img src="/bank/template/banner.gif" alt="Duke's Bank">
    </center>
    


    and change the web.xml as follows,

    <jsp-config>
     <jsp-property-group>
     <display-name>bank</display-name>
     <url-pattern>/bank/*</url-pattern>
     <el-enabled>true</el-enabled>
     <scripting-enabled>true</scripting-enabled>
     <include-prelude>/template/prelude.jspf</include-prelude>
     </jsp-property-group>
    </jsp-config>
    


    Regards,
    Jose Alvarez de Lara