Thank you for visiting! If you liked the site, please add a bookmark, else add a critical comment! Would you like to visit Greece? Traditional Greek flag This real estate site is only available in Greek! The holy mountain
Showing posts with label EJB 3. Show all posts
Showing posts with label EJB 3. Show all posts

Sunday 16 September 2012

Processing BLOBs via the ImageServlet

In this post an alternative code version to the traditional ImageServlet  will be given, supplementing the one presented in the book named Oracle Fusion Developer Guide (p.409), by F.Nimphius and L.Munsinger and other official Oracle aces' and employees' blogs. This alternative version will use the  EJB 3 way to get rid of the surplus database definition hard coded in the doGet() method. As an epilogue, further criticism will be provided, against using that technique of obtaining jdbc connections to the database.

Here is the modified code, with the original straight jdbc code commented out:

package actionbazaar.view.servlet;


import actionbazaar.buslogic.PlaceItem;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.OutputStream;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import oracle.jbo.domain.BlobDomain;

import org.apache.log4j.Logger;


public class ImageServlet extends HttpServlet {
    private static final String CONTENT_TYPE = "image/jpg; charset=utf-8";
    @SuppressWarnings("compatibility:988932384557339885")
    private static final long serialVersionUID = 1L;
    private Logger logger = Logger.getLogger(this.getClass().getName());
   
    public void init(ServletConfig config) throws ServletException {
        super.init(config);
    }

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response) throws ServletException,
                                                           IOException {
        response.setContentType(CONTENT_TYPE);
        Long itemId = new Long(request.getParameter("itemId"));
        if (logger.isDebugEnabled())
            logger.debug("itemId = " + itemId);
        try {
                Context context = new InitialContext();
                PlaceItem placeItem = (PlaceItem)context.lookup("ejb3inaction-Model-PlaceItem#actionbazaar.buslogic.PlaceItem");
                byte[] image  = placeItem.getImageByItemId(itemId);

            if (image != null) {
                BlobDomain bld = new BlobDomain(image);

                OutputStream os = response.getOutputStream();
                BufferedInputStream in =  new BufferedInputStream(bld.getBinaryStream());
                int b;
                byte[] buffer = new byte[10240];

                while ((b = in.read(buffer, 0, 10240)) != -1) {
                    os.write(buffer, 0, b);
                }
                os.close();
            } else {
                    if (logger.isDebugEnabled())
                        logger.debug("No  image exists yet for itemId: " + itemId);
                }
        } catch (NamingException e){
            e.printStackTrace();   
        }
        catch (IOException e){
            e.printStackTrace();   
        }
       /*
        Connection conn = null;


        try {
            Context ctx = new InitialContext();

//Datasource as defined in <res-ref-name> element of weblogic.xml
            DataSource ds =
                (DataSource)ctx.lookup("jdbc/ActionBazaarEJB3inActionDS");

            conn = ds.getConnection();
            PreparedStatement statement =
                conn.prepareStatement("SELECT IMAGE " +
                                      " FROM ITEMS" +
                                    " WHERE ITEM_ID= ? ");
            statement.setInt(1, new Integer(itemId));
            ResultSet rs = statement.executeQuery();

            if (rs.next()) {
                Blob blob = rs.getBlob("IMAGE");

                BufferedInputStream in =
                    new BufferedInputStream(blob.getBinaryStream());
                int b;
                byte[] buffer = new byte[10240];

                while ((b = in.read(buffer, 0, 10240)) != -1) {
                    os.write(buffer, 0, b);
                }
                os.close();

            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (conn != null) {

                    conn.close();
                }

            } catch (SQLException sqle) {
                sqle.printStackTrace();

            }

        }*/
      
    }

   }


Besides hard coding the database connection string and the SQL query too, using doGet() instead of init() to setup a database connection and destroy() to close it, is not widely considered a good idea. Thus, a newer version of the servlet code  will be most welcome, due to performance reasons as well. Presenting that code would go beyond the scope of such a post, so I am turning once again to the Oracle experts mentioned above for another alternative solution!

References

http://tompeez.wordpress.com/2011/12/16/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-3/
http://www.baigzeeshan.com/2010/09/store-images-in-blob-in-oracle-adf.html
http://ranajitsahoo.blogspot.gr/2008/04/how-to-display-content-of-blob-column.html
http://www.javaranch.com/journal/200601/JDBCConnectionPooling.html

Tuesday 20 March 2012

Obtaining the selected values of a selectManyChoice component

Searching for selectManyChoice  in the J2EE or fusion  11g developer guides does not return more than a series of drag and drop instructions. Again, the programmer is left at one's own devises, to improvise in order to find the solution. This is no exception to the rule that when in need or emergency, the only thing one is certain to find in a technical guide document is missing information! Even the difference in the  number of pages between the two guides is huge; showing a heavy bias to using ADF based on business components, only. 
This post is a jsf and ejb 3 full source code example, including necessary import statements; showing how to snag the user selections, when a selectManyChoice component  is used.  It could be considered as a complement to the article named:

How to access selected rows in an af:selectManyChoice component, by Frank Nimphius


which focuses only on ADF business components. Two versions of the code will follow, a ADF (licensed) and an open source one. 

First, the ADF version:

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1" title="Create new order"
                 binding="#{backingBeanScope.backing_createOrder.d1}">
      <af:messages id="m1"
                   binding="#{backingBeanScope.backing_createOrder.m1}"/>
      <af:form id="f1" binding="#{backingBeanScope.backing_createOrder.f1}">
        <af:pageTemplate viewId="/WEB-INF/templates/templateABDef.jspx"
                         id="pt1">
          <f:facet name="content">
            <af:panelStretchLayout id="psl1"
                                   binding="#{backingBeanScope.backing_createOrder.psl1}">
              <f:facet name="center">
                <af:panelFormLayout id="pfl1"
                                    binding="#{backingBeanScope.backing_createOrder.pfl1}">
                  <af:selectManyChoice label="Select one or more items"
                                       binding="#{backingBeanScope.backing_createOrder.smc1}"
                                       id="smc1">
                    <f:selectItems value="#{backingBeanScope.backing_createOrder.allItems}"
                                   binding="#{backingBeanScope.backing_createOrder.si1}"
                                   id="si1"/>
                  </af:selectManyChoice>
                  <af:selectOneChoice label="Billing Info"
                                      binding="#{backingBeanScope.backing_createOrder.soc1}"
                                      id="soc1">
                    <f:selectItems value="#{backingBeanScope.backing_createOrder.allBillingInfos}"
                                   binding="#{backingBeanScope.backing_createOrder.si2}"
                                   id="si2"/>
                  </af:selectOneChoice>
                  <af:inputText value="#{securityContext.userName}"
                                label="#{bindings.bidderId.hints.label}"
                                required="#{bindings.bidderId.hints.mandatory}"
                                columns="#{bindings.bidderId.hints.displayWidth}"
                                maximumLength="#{bindings.bidderId.hints.precision}"
                                shortDesc="#{bindings.bidderId.hints.tooltip}"
                                id="it3"
                                binding="#{backingBeanScope.backing_createOrder.it3}"
                                rendered="true">
                    <f:validator binding="#{bindings.bidderId.validator}"/>
                  </af:inputText>
                  <af:selectOneChoice label="Shipping info"
                                      binding="#{backingBeanScope.backing_createOrder.soc2}"
                                      id="soc2">
                    <f:selectItems value="#{backingBeanScope.backing_createOrder.allShippingInfos}"
                                   binding="#{backingBeanScope.backing_createOrder.si3}"
                                   id="si3"/>
                  </af:selectOneChoice>
                  <af:commandButton text="create order"
                                    binding="#{backingBeanScope.backing_createOrder.cb1}"
                                    id="cb1"
                                    action="#{backingBeanScope.backing_createOrder.createNewOrder}"/>
                </af:panelFormLayout>
              </f:facet>
            </af:panelStretchLayout>
          </f:facet>
        </af:pageTemplate>
      </af:form>
    </af:document>
  </f:view>
  <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_createOrder-->
</jsp:root>

The bean:

package actionbazaar.view.backing;


import actionbazaar.buslogic.PlaceBillingInfo;
import actionbazaar.buslogic.PlaceItem;
import actionbazaar.buslogic.PlaceOrder;
import actionbazaar.buslogic.PlaceShippingInfo;

import actionbazaar.persistence.BillingInfo;
import actionbazaar.persistence.Item;
import actionbazaar.persistence.ShippingInfo;

import actionbazaar.view.CustomBackingBean;

import java.util.ArrayList;
import java.util.List;

import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;

import javax.faces.application.Application;
import javax.faces.component.UISelectItems;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import oracle.adf.share.ADFContext;
import oracle.adf.view.rich.component.rich.RichDocument;
import oracle.adf.view.rich.component.rich.RichForm;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.input.RichSelectManyChoice;
import oracle.adf.view.rich.component.rich.input.RichSelectOneChoice;
import oracle.adf.view.rich.component.rich.layout.RichPanelFormLayout;
import oracle.adf.view.rich.component.rich.layout.RichPanelStretchLayout;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;
import oracle.adf.view.rich.component.rich.output.RichMessages;


public class CreateOrder extends CustomBackingBean {
    private RichInputText it3;
    private RichPanelFormLayout pfl1;
    private RichPanelStretchLayout psl1;
    private RichForm f1;
    private RichMessages m1;
    private RichDocument d1;
   
    private String bidderId ;
    private ArrayList<SelectItem> allItems;
    private ArrayList<SelectItem> orderItems;
    private ArrayList<SelectItem> shippingInfos;
    private ArrayList<SelectItem> billingInfos;

    private RichCommandButton cb1;
    private RichSelectOneChoice soc1;
    private UISelectItems si2;
    private RichSelectOneChoice soc2;
    private UISelectItems si3;
    private RichSelectManyChoice smc1;
    private UISelectItems si1;

    public CreateOrder() {
      bidderId = ADFContext.getCurrent().getSecurityContext().getUserName();
     // getAllBillingInfos();
      //getAllShippingInfos();
    }

  public ArrayList<SelectItem> getAllItems() {
   try {
       InitialContext context = new InitialContext();
       PlaceItem beanRemote = (PlaceItem) context.lookup( "ejb3inaction-Model-PlaceItem#actionbazaar.buslogic.PlaceItem");
       List<Item> allItems = beanRemote.getItemFindAll();
       orderItems = new ArrayList<SelectItem>(allItems.size());
       for (Item item : allItems) {
             Long itemId = item.getItemId();
             String itemName= item.getItemName();
             SelectItem selectItem = new SelectItem(itemId, itemName);
             orderItems.add(selectItem);
       }
         logger.debug("orderItems.size() " + orderItems.size());
         this.setOrderItems(orderItems);
       } catch (NamingException e) {
           System.err.println(e.getMessage());
   }
     return orderItems;
   }
 
  public ArrayList<SelectItem> getAllBillingInfos() {
   try {
         InitialContext context = new InitialContext();
         PlaceBillingInfo beanRemote1 = (PlaceBillingInfo)context.lookup("ejb3inaction-Model-PlaceBillingInfo#actionbazaar.buslogic.PlaceBillingInfo");
                      
         List<BillingInfo> alllBillingInfos = beanRemote1.getBillingInfoFindByUserId(bidderId);
         billingInfos = new ArrayList<SelectItem>(alllBillingInfos.size());
         for (BillingInfo bi : alllBillingInfos) {
             Long billingId = bi.getBillingId();
             String billingName= bi.getAccountNo() + " " + bi.getCardType() + " " + bi.getExpiryDate() +" " + bi.getSecretCode();
             SelectItem selectItem1 = new SelectItem(billingId, billingName);
             billingInfos.add(selectItem1);
       }
         logger.debug("billingInfos.size() " + billingInfos.size());
       this.setBillingInfos(billingInfos);
       } catch (NamingException e) {
           System.err.println(e.getMessage());
   }
   return billingInfos;
   }

   public ArrayList<SelectItem> getAllShippingInfos() {
   try {
       InitialContext context = new InitialContext();
       PlaceShippingInfo beanRemote2 = (PlaceShippingInfo)context.lookup("ejb3inaction-Model-PlaceShippingInfo#actionbazaar.buslogic.PlaceShippingInfo");
       List<ShippingInfo> allShippingInfos = beanRemote2.getShippingInfoFindAll();
       shippingInfos = new ArrayList<SelectItem>(allShippingInfos.size());
       for (ShippingInfo si : allShippingInfos) {
             Long ShippingInfoId = si.getShippingId();
             String ShippingInfoName= si.getStreet() + " " + si.getCity() + " " + si.getState();
             SelectItem selectItem2 = new SelectItem(ShippingInfoId, ShippingInfoName);
             shippingInfos.add(selectItem2);
       }
         logger.debug("shippingInfos.size() " + shippingInfos.size());
         this.setShippingInfos(shippingInfos);
       } catch (NamingException e) {
           System.err.println(e.getMessage());
   }
   return shippingInfos;
   }
 
  public Object createNewOrder() {
        try {
                              
                  FacesContext ctx = FacesContext.getCurrentInstance();
                  ELContext ectx =ctx.getELContext();
                  Application app = ctx.getApplication();
                  ExpressionFactory factory = app.getExpressionFactory();
                /*  An alternate way which works too*/
                /*
                 java.util.ArrayList billingIdUIComponents = (java.util.ArrayList)si2.getValue();
                 SelectItem billingIdItem=(SelectItem)billingIdUIComponents.get(0);
                 Long billingId = new Long( billingIdItem.getValue().toString() );
                 */
                  ValueExpression ve =   factory.createValueExpression(ectx,   "#{backingBeanScope.backing_createOrder.soc1.value}",Object.class );
                  Long billingId = new Long(ve.getValue(ectx).toString());
                  ValueExpression ve1= factory.createValueExpression(ectx,   "#{backingBeanScope.backing_createOrder.soc2.value}",Object.class );
                  Long shippingId = new Long( ve1.getValue(ectx).toString());
                 ValueExpression ve2= factory.createValueExpression(ectx,   "#{backingBeanScope.backing_createOrder.smc1.value}",Object.class );
                 /*selectManyChoice working alternate*/
               /*   ArrayList<Object> selectedItemsId =  (ArrayList<Object>)ve2.getValue(ectx);
                 ArrayList<Long> itemsId = new ArrayList<Long>(selectedItemsId.size());
                 for (int i = 0; i < selectedItemsId.size(); i++) {
                      Long val = new Long(selectedItemsId.get(i).toString());
                      logger.debug( "itemId " + val);
                      itemsId.add(val);
                  }
               */
                   
                 ArrayList itemIdUIComponents = (java.util.ArrayList)si1.getValue();
                 ArrayList<Long> itemsId = new ArrayList<Long>(itemIdUIComponents.size());
                 for (int i = 0; i < itemIdUIComponents.size(); i++) {
                      SelectItem selectedItemsId =(SelectItem)itemIdUIComponents.get(i);
                      Long itemId = new Long( selectedItemsId.getValue().toString() );
                      itemsId.add(itemId);
                }
               
         
       
                 if (logger.isDebugEnabled())
                         logger.debug(  "bidderId " + bidderId +"  billingId " + billingId +  " shippingId " + shippingId);
                 InitialContext context = new InitialContext();
                 PlaceOrder facadeSessionEJB = (PlaceOrder)context.lookup("ejb3inaction-Model-PlaceOrder#actionbazaar.buslogic.PlaceOrder");
                 facadeSessionEJB.addOrder(bidderId, itemsId, shippingId, billingId );
                 if (logger.isDebugEnabled())
                         logger.debug(  "itemsId " + itemsId.get(0) +"  billingId " +  " shippingId " );
               } catch (NamingException e) {
                    System.err.println(e.getMessage());
               }
         return null;
    }


    public void setIt3(RichInputText it3) {
        this.it3 = it3;
    }

    public RichInputText getIt3() {
        return it3;
    }


    public void setPfl1(RichPanelFormLayout pfl1) {
        this.pfl1 = pfl1;
    }

    public RichPanelFormLayout getPfl1() {
        return pfl1;
    }

    public void setPsl1(RichPanelStretchLayout psl1) {
        this.psl1 = psl1;
    }

    public RichPanelStretchLayout getPsl1() {
        return psl1;
    }

    public void setF1(RichForm f1) {
        this.f1 = f1;
    }

    public RichForm getF1() {
        return f1;
    }

    public void setM1(RichMessages m1) {
        this.m1 = m1;
    }

    public RichMessages getM1() {
        return m1;
    }

    public void setD1(RichDocument d1) {
        this.d1 = d1;
    }

    public RichDocument getD1() {
        return d1;
    }

    public void setAllItems(ArrayList<SelectItem> allItems) {
        this.allItems = allItems;
    }

    public void setOrderItems(ArrayList<SelectItem> orderItems) {
        this.orderItems = orderItems;
    }


    public void setCb1(RichCommandButton cb1) {
        this.cb1 = cb1;
    }

    public RichCommandButton getCb1() {
        return cb1;
    }

    public void setShippingInfos(ArrayList<SelectItem> shippingInfos) {
        this.shippingInfos = shippingInfos;
    }

    public void setBillingInfos(ArrayList<SelectItem> billingInfos) {
        this.billingInfos = billingInfos;
    }

    public void setSoc1(RichSelectOneChoice soc1) {
        this.soc1 = soc1;
    }

    public RichSelectOneChoice getSoc1() {
        return soc1;
    }

    public void setSi2(UISelectItems si2) {
        this.si2 = si2;
    }

    public UISelectItems getSi2() {
        return si2;
    }

    public void setSoc2(RichSelectOneChoice soc2) {
        this.soc2 = soc2;
    }

    public RichSelectOneChoice getSoc2() {
        return soc2;
    }

    public void setSi3(UISelectItems si3) {
        this.si3 = si3;
    }

    public UISelectItems getSi3() {
        return si3;
    }

    public void setSmc1(RichSelectManyChoice smc1) {
        this.smc1 = smc1;
    }

    public RichSelectManyChoice getSmc1() {
        return smc1;
    }

    public void setSi1(UISelectItems si1) {
        this.si1 = si1;
    }

    public UISelectItems getSi1() {
        return si1;
    }
}


Second, the J2EE open source version, starting with the page:

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html">
    <jsp:output omit-xml-declaration="true" doctype-root-element="HTML"
                doctype-system="http://www.w3.org/TR/html4/loose.dtd"
                doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
        <html>
            <head>
                <meta http-equiv="Content-Type"
                      content="text/html; charset=UTF-8"/>
                <h:messages/>
            </head>
            <body>
                <div align="center">
                    <h:form>
                        <h:panelGrid columns="2"
                                     binding="#{backing_createOrder.panelGrid11}"
                                     id="panelGrid11"
                                     style="vertical-align:middle;">
                            <h:outputLabel value="Select items"
                                           binding="#{backing_createOrder.outputLabel31}"
                                           id="outputLabel31"/>
                            <h:selectManyListbox binding="#{backing_createOrder.selectManyListbox11}"
                                                 id="selectManyListbox11"
                                                 required="true">
                                <f:selectItems value="#{backing_createOrder.allItems}"
                                               binding="#{backing_createOrder.selectItems41}"
                                               id="selectItems41"/>
                            </h:selectManyListbox>
                            <h:outputLabel value="Bidder"
                                           binding="#{backing_createOrder.outputLabel11}"
                                           id="outputLabel11"/>
                            <h:inputText binding="#{backing_createOrder.inputText11}"
                                         id="inputText11"
                                         value="#{backing_createOrder.bidderId}"/>
                            <h:outputLabel value="Billing details"
                                           binding="#{backing_createOrder.outputLabel21}"
                                           id="outputLabel21"/>
                            <h:selectOneListbox label="BillingInfo"
                                                binding="#{backing_createOrder.selectOneListbox11}"
                                                id="selectOneListbox11"
                                                required="true">
                                <f:selectItems value="#{backing_createOrder.allBillingInfos}"
                                               binding="#{backing_createOrder.selectItems21}"
                                               id="selectItems21"/>
                            </h:selectOneListbox>
                            <h:outputLabel value="Shipping details"
                                           binding="#{backing_createOrder.outputLabel41}"
                                           id="outputLabel41"/>
                            <h:selectOneListbox label="ShippingInfo"
                                                binding="#{backing_createOrder.selectOneListbox21}"
                                                id="selectOneListbox21"
                                                required="true">
                                <f:selectItems value="#{backing_createOrder.allShippingInfos}"
                                               binding="#{backing_createOrder.selectItems31}"
                                               id="selectItems31"/>
                            </h:selectOneListbox>
                            <f:facet name="footer">
                                <h:panelGroup binding="#{backing_createOrder.panelGroup1}"
                                              id="panelGroup1">
                                    <input type="reset" name="Reset"
                                           value="Reset"/>
                                    <h:commandButton value="create Order"
                                                     binding="#{backing_createOrder.commandButton11}"
                                                     id="commandButton11"
                                                     action="#{backing_createOrder.createNewOrder}"/>
                                </h:panelGroup>
                            </f:facet>
                            <f:facet name="header">
                                <h:outputFormat value="Create new order"
                                                binding="#{backing_createOrder.outputFormat11}"
                                                id="outputFormat11"/>
                            </f:facet>
                        </h:panelGrid>
                    </h:form>
                </div>
            </body>
        </html>
    </f:view>
    <!--oracle-jdev-comment:auto-binding-backing-bean-name:backing_createOrder-->
</jsp:root>

Finally, the bean:

package actionbazaar.backing;


import actionbazaar.buslogic.PlaceBillingInfo;
import actionbazaar.buslogic.PlaceItem;
import actionbazaar.buslogic.PlaceOrder;
import actionbazaar.buslogic.PlaceShippingInfo;

import actionbazaar.persistence.BillingInfo;
import actionbazaar.persistence.Item;
import actionbazaar.persistence.Order;
import actionbazaar.persistence.ShippingInfo;

import java.util.ArrayList;
import java.util.List;

import javax.el.ELContext;
import javax.el.ExpressionFactory;
import javax.el.ValueExpression;

import javax.faces.application.Application;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.component.UISelectItems;
import javax.faces.component.html.HtmlCommandButton;
import javax.faces.component.html.HtmlInputText;
import javax.faces.component.html.HtmlOutputFormat;
import javax.faces.component.html.HtmlOutputLabel;
import javax.faces.component.html.HtmlPanelGrid;
import javax.faces.component.html.HtmlPanelGroup;
import javax.faces.component.html.HtmlSelectManyListbox;
import javax.faces.component.html.HtmlSelectOneListbox;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.model.SelectItem;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import javax.servlet.http.HttpServletRequest;


@ManagedBean(name="backing_createOrder")
@RequestScoped
public class CreateOrder extends CustomBackingBean{
   
    private ArrayList<SelectItem> allItems;
    private ArrayList<SelectItem> orderItems;
    private ArrayList<SelectItem> shippingInfos;
    private ArrayList<SelectItem> billingInfos;
    private String bidderId  ;
    private FacesContext ctx;
    private ExternalContext ectx;
    private HtmlPanelGrid panelGrid1;
    private HtmlOutputLabel outputLabel1;
    private HtmlInputText inputText1;
    private HtmlSelectOneListbox selectOneListbox1;
    private UISelectItems selectItems2;
    private HtmlCommandButton commandButton1;
    private HtmlSelectOneListbox selectOneListbox2;
    private UISelectItems selectItems3;
    private HtmlOutputLabel outputLabel2;
    private HtmlOutputLabel outputLabel3;
    private HtmlOutputLabel outputLabel4;
    private HtmlSelectManyListbox selectManyListbox1;
    private UISelectItems selectItems4;
    private HtmlOutputFormat outputFormat1;
    private HtmlPanelGrid panelGrid11;
    private HtmlOutputLabel outputLabel31;
    private HtmlSelectManyListbox selectManyListbox11;
    private UISelectItems selectItems41;
    private HtmlOutputLabel outputLabel11;
    private HtmlInputText inputText11;
    private HtmlOutputLabel outputLabel21;
    private HtmlSelectOneListbox selectOneListbox11;
    private UISelectItems selectItems21;
    private HtmlOutputLabel outputLabel41;
    private HtmlSelectOneListbox selectOneListbox21;
    private UISelectItems selectItems31;
    private HtmlCommandButton commandButton11;
    private HtmlOutputFormat outputFormat11;
    private HtmlPanelGroup panelGroup1;

    public CreateOrder() {
            getAllItems();
            getAllShippingInfos();
            ctx = FacesContext.getCurrentInstance();
            ectx =ctx.getExternalContext();
            getAllBillingInfos();
    }
    public ArrayList<SelectItem> getAllItems() {
    try {
        InitialContext context = new InitialContext();
        PlaceItem beanRemote = (PlaceItem) context.lookup( "ejb3inaction-Model-PlaceItem#actionbazaar.buslogic.PlaceItem");
        List<Item> allItems = beanRemote.getItemFindAll();
        orderItems = new ArrayList<SelectItem>(allItems.size());
        for (Item item : allItems) {
              Long itemId = item.getItemId();
              String itemName= item.getItemName();
              SelectItem selectItem = new SelectItem(itemId, itemName);
              orderItems.add(selectItem);
        }
          logger.debug("orderItems.size() " + orderItems.size());
          this.setOrderItems(orderItems);
        } catch (NamingException e) {
            System.err.println(e.getMessage());
    }
    return orderItems;
    }
    public ArrayList<SelectItem> getAllBillingInfos() {
    try {
          InitialContext context = new InitialContext();
          PlaceBillingInfo beanRemote1 = (PlaceBillingInfo)context.lookup("ejb3inaction-Model-PlaceBillingInfo#actionbazaar.buslogic.PlaceBillingInfo");
                       
          List<BillingInfo> alllBillingInfos = beanRemote1.getBillingInfoFindByUserId( bidderId); //
          billingInfos = new ArrayList<SelectItem>(alllBillingInfos.size());
          for (BillingInfo bi : alllBillingInfos) {
              Long billingId = bi.getBillingId();
              String billingName= bi.getAccountNo() + " " + bi.getCardType() + " " + bi.getExpiryDate() +" " + bi.getSecretCode();
              SelectItem selectItem1 = new SelectItem(billingId, billingName);
              billingInfos.add(selectItem1);
        }
          logger.debug("billingInfos.size() " + billingInfos.size());
        this.setBillingInfos(billingInfos);
        } catch (NamingException e) {
            System.err.println(e.getMessage());
    }
    return billingInfos;
    }

    public ArrayList<SelectItem> getAllShippingInfos() {
    try {
        InitialContext context = new InitialContext();
        PlaceShippingInfo beanRemote2 = (PlaceShippingInfo)context.lookup("ejb3inaction-Model-PlaceShippingInfo#actionbazaar.buslogic.PlaceShippingInfo");
        List<ShippingInfo> allShippingInfos = beanRemote2.getShippingInfoFindAll();
        shippingInfos = new ArrayList<SelectItem>(allShippingInfos.size());
        for (ShippingInfo si : allShippingInfos) {
              Long ShippingInfoId = si.getShippingId();
              String ShippingInfoName= si.getStreet() + " " + si.getCity() + " " + si.getState();
              SelectItem selectItem2 = new SelectItem(ShippingInfoId, ShippingInfoName);
              shippingInfos.add(selectItem2);
        }
          logger.debug("shippingInfos.size() " + shippingInfos.size());
          this.setShippingInfos(shippingInfos);
        } catch (NamingException e) {
            System.err.println(e.getMessage());
    }
    return shippingInfos;
    }
  
    public Object createNewOrder() {
        try {
                                     
                   bidderId = (String)inputText11.getValue();           
                                                    
                   java.util.ArrayList billingIdUIComponents = (java.util.ArrayList)selectItems21.getValue();
                   SelectItem billingIdItem=(SelectItem)billingIdUIComponents.get(0);
                   Long billingId = new Long( billingIdItem.getValue().toString() );
                   /*
                   java.util.ArrayList shippingIdUIComponents = (java.util.ArrayList)selectItems31.getValue();
                   SelectItem shippingIdItem=(SelectItem)shippingIdUIComponents.get(0);
                   Long shippingId = new Long( shippingIdItem.getValue().toString());
                 */
                   ELContext elctx =ctx.getELContext();
                  Application app = ctx.getApplication();
                   ExpressionFactory factory = app.getExpressionFactory();
                   ValueExpression ve =   factory.createValueExpression(elctx,   "#{backing_createOrder.selectOneListbox21.value}",Object.class );
                   Long shippingId = new Long( ve.getValue(elctx).toString());
                
                  HttpServletRequest request =    (HttpServletRequest)ctx.getExternalContext().getRequest();
                  String[] selectedItemsId = request.getParameterValues("j_id_id2:selectManyListbox11");
                  
                 ArrayList<Long> itemsId = new ArrayList<Long>(selectedItemsId.length);
                 
                  for (int i = 0; i < selectedItemsId.length; i++) {
                      Long val = new Long(selectedItemsId[i].toString());
                       logger.debug( "itemId " + val);
                       itemsId.add(val);
                   }
                 if (logger.isDebugEnabled())
                         logger.debug(  "bidderId " + getBidderId() +"  billingId " + billingId +  " shippingId " + shippingId);
                 InitialContext context = new InitialContext();
                 PlaceOrder facadeSessionEJB = (PlaceOrder)context.lookup("ejb3inaction-Model-PlaceOrder#actionbazaar.buslogic.PlaceOrder");
                 facadeSessionEJB.addOrder(getBidderId(), itemsId, shippingId, billingId );
                             
               } catch (NamingException e) {
                    System.err.println(e.getMessage());
                    return null;
               }
         return "queryOrders";
    }


    public void setAllItems(ArrayList<SelectItem> allItems) {
        this.allItems = allItems;
    }

    public void setOrderItems(ArrayList<SelectItem> orderItems) {
        this.orderItems = orderItems;
    }

    public void setShippingInfos(ArrayList<SelectItem> shippingInfos) {
        this.shippingInfos = shippingInfos;
    }

    public void setBillingInfos(ArrayList<SelectItem> billingInfos) {
        this.billingInfos = billingInfos;
    }

    public void setBidderId(String bidderId) {
        this.bidderId = bidderId;
    }

    public String getBidderId() {
        return ectx.getRemoteUser();
    }


    public void setPanelGrid1(HtmlPanelGrid panelGrid1) {
        this.panelGrid1 = panelGrid1;
    }

    public HtmlPanelGrid getPanelGrid1() {
        return panelGrid1;
    }


    public void setOutputLabel1(HtmlOutputLabel outputLabel1) {
        this.outputLabel1 = outputLabel1;
    }

    public HtmlOutputLabel getOutputLabel1() {
        return outputLabel1;
    }

    public void setInputText1(HtmlInputText inputText1) {
        this.inputText1 = inputText1;
    }

    public HtmlInputText getInputText1() {
        return inputText1;
    }

    public void setSelectOneListbox1(HtmlSelectOneListbox selectOneListbox1) {
        this.selectOneListbox1 = selectOneListbox1;
    }

    public HtmlSelectOneListbox getSelectOneListbox1() {
        return selectOneListbox1;
    }

    public void setSelectItems2(UISelectItems selectItems2) {
        this.selectItems2 = selectItems2;
    }

    public UISelectItems getSelectItems2() {
        return selectItems2;
    }

    public void setCommandButton1(HtmlCommandButton commandButton1) {
        this.commandButton1 = commandButton1;
    }

    public HtmlCommandButton getCommandButton1() {
        return commandButton1;
    }


    public void setSelectOneListbox2(HtmlSelectOneListbox selectOneListbox2) {
        this.selectOneListbox2 = selectOneListbox2;
    }

    public HtmlSelectOneListbox getSelectOneListbox2() {
        return selectOneListbox2;
    }

    public void setSelectItems3(UISelectItems selectItems3) {
        this.selectItems3 = selectItems3;
    }

    public UISelectItems getSelectItems3() {
        return selectItems3;
    }

    public void setOutputLabel2(HtmlOutputLabel outputLabel2) {
        this.outputLabel2 = outputLabel2;
    }

    public HtmlOutputLabel getOutputLabel2() {
        return outputLabel2;
    }

    public void setOutputLabel3(HtmlOutputLabel outputLabel3) {
        this.outputLabel3 = outputLabel3;
    }

    public HtmlOutputLabel getOutputLabel3() {
        return outputLabel3;
    }

    public void setOutputLabel4(HtmlOutputLabel outputLabel4) {
        this.outputLabel4 = outputLabel4;
    }

    public HtmlOutputLabel getOutputLabel4() {
        return outputLabel4;
    }


    public ArrayList<SelectItem> getBillingInfos() {
        return billingInfos;
    }

    public void setSelectManyListbox1(HtmlSelectManyListbox selectManyListbox1) {
        this.selectManyListbox1 = selectManyListbox1;
    }

    public HtmlSelectManyListbox getSelectManyListbox1() {
        return selectManyListbox1;
    }

    public void setSelectItems4(UISelectItems selectItems4) {
        this.selectItems4 = selectItems4;
    }

    public UISelectItems getSelectItems4() {
        return selectItems4;
    }

    public void setOutputFormat1(HtmlOutputFormat outputFormat1) {
        this.outputFormat1 = outputFormat1;
    }

    public HtmlOutputFormat getOutputFormat1() {
        return outputFormat1;
    }

    public void setPanelGrid11(HtmlPanelGrid panelGrid11) {
        this.panelGrid11 = panelGrid11;
    }

    public HtmlPanelGrid getPanelGrid11() {
        return panelGrid11;
    }

    public void setOutputLabel31(HtmlOutputLabel outputLabel31) {
        this.outputLabel31 = outputLabel31;
    }

    public HtmlOutputLabel getOutputLabel31() {
        return outputLabel31;
    }

    public void setSelectManyListbox11(HtmlSelectManyListbox selectManyListbox11) {
        this.selectManyListbox11 = selectManyListbox11;
    }

    public HtmlSelectManyListbox getSelectManyListbox11() {
        return selectManyListbox11;
    }

    public void setSelectItems41(UISelectItems selectItems41) {
        this.selectItems41 = selectItems41;
    }

    public UISelectItems getSelectItems41() {
        return selectItems41;
    }

    public void setOutputLabel11(HtmlOutputLabel outputLabel11) {
        this.outputLabel11 = outputLabel11;
    }

    public HtmlOutputLabel getOutputLabel11() {
        return outputLabel11;
    }

    public void setInputText11(HtmlInputText inputText11) {
        this.inputText11 = inputText11;
    }

    public HtmlInputText getInputText11() {
        return inputText11;
    }

    public void setOutputLabel21(HtmlOutputLabel outputLabel21) {
        this.outputLabel21 = outputLabel21;
    }

    public HtmlOutputLabel getOutputLabel21() {
        return outputLabel21;
    }

    public void setSelectOneListbox11(HtmlSelectOneListbox selectOneListbox11) {
        this.selectOneListbox11 = selectOneListbox11;
    }

    public HtmlSelectOneListbox getSelectOneListbox11() {
        return selectOneListbox11;
    }

    public void setSelectItems21(UISelectItems selectItems21) {
        this.selectItems21 = selectItems21;
    }

    public UISelectItems getSelectItems21() {
        return selectItems21;
    }

    public void setOutputLabel41(HtmlOutputLabel outputLabel41) {
        this.outputLabel41 = outputLabel41;
    }

    public HtmlOutputLabel getOutputLabel41() {
        return outputLabel41;
    }

    public void setSelectOneListbox21(HtmlSelectOneListbox selectOneListbox21) {
        this.selectOneListbox21 = selectOneListbox21;
    }

    public HtmlSelectOneListbox getSelectOneListbox21() {
        return selectOneListbox21;
    }

    public void setSelectItems31(UISelectItems selectItems31) {
        this.selectItems31 = selectItems31;
    }

    public UISelectItems getSelectItems31() {
        return selectItems31;
    }

    public void setCommandButton11(HtmlCommandButton commandButton11) {
        this.commandButton11 = commandButton11;
    }

    public HtmlCommandButton getCommandButton11() {
        return commandButton11;
    }

    public void setOutputFormat11(HtmlOutputFormat outputFormat11) {
        this.outputFormat11 = outputFormat11;
    }

    public HtmlOutputFormat getOutputFormat11() {
        return outputFormat11;
    }

    public void setPanelGroup1(HtmlPanelGroup panelGroup1) {
        this.panelGroup1 = panelGroup1;
    }

    public HtmlPanelGroup getPanelGroup1() {
        return panelGroup1;
    }
}

Friday 24 February 2012

EJB 3 Deployment guide for WebLogic Server Version: 10.3.4.0

Apart from setting up a domain with the jrf libraries and data sources, presently the books and developer guides for  ADF 11g development do not delve into deployment troubleshooting details, as the prior ADF 10g documentation did. Moreover, the older docs included deployment directions for Tomcat, JBoss, etc, which is currently missing from the 11g versions. This rough guide is a supplement to the docs presenting solutions, workarounds, tips and hints to avoid exceptions during deployment. The following hints and tips about deployment apply to the versions below: Build JDEVADF_11.1.1.4.0_GENERIC_101227.1736.5923
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

The full version of the guide is available as a personalized pdf file for sale upon request. My contact details can be found at the "About me " page.

 EJB 3 Model security setup

 A primer to ADF security which focuses mainly on Oracle Business Components is given here:
Security for Everyone, By Frank Nimphius at:
http://www.oracle.com/technetwork/issue-archive/2012/12-jan/o12adf-1364748.html
Besides the usual web.xml entries etc, the EJB 3 model project may require more security entries in weblogic-application.xml, as java standard edition clients, ie junit testing ones, require that extra step. Since some people allege isCallerInRole(“”) always returns false, it seems that @RolesAllowed annotation only does not do the job.



private static Context getInitialContext(String user, String password) throws NamingException {
Hashtable env = new Hashtable();
// WebLogic Server 10.x connection details
env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
env.put(Context.PROVIDER_URL, "t3://127.0.0.1:7001");
env.put(Context.SECURITY_PRINCIPAL, user);
env.put(Context.SECURITY_CREDENTIALS,password);
return new InitialContext( env );
}

 Stand alone server deployment errors

When I tried the application on my integrated WLS, it worked fine. However, the standalone misbehaved:



Weblogic Server Exception: weblogic.application.ModuleException: Failed to load webapp: '...'
Caused by: java.lang.ClassNotFoundException: javax.faces.webapp.ConverterELTag
Solution: add jsf 1.2 library

java.faces.webapp.facesservletNotfound  Exception, 






SOLUTION:
It is raised when migrating an application to newer or older, versions of JDeveloper,
check the viewController project for the proper jsf version library. Is it jsf 1.2, or is it not?


Caused by: java.lang.ClassNotFoundException: oracle.adfinternal.controller.util.LogUtils
Solution: add adf controller runtime library



When I added some more ADF faces run time related jars in JDev I got a new one:
Caused by: java.lang.ClassNotFoundException: org.apache.myfaces.trinidad.webapp.UIXComponentELTag



SOLUTION: In my particular case, ADF & EJB 3, I managed to get away with only:

glassfish.jsf_1.0.0.0_1-2-15
glassfish.jstl_1.2.0.1
javax.jsf_1.1.0.0_1-2
log4j-1.2.15 in META-INF/lib
wls.jsf.di



On the other hand the CAT Conflicts Summary:
There are potential conflicts detected and they do not seem to have been resolved. Please review the potential solutions below.
  • 121 classes are in conflict
  • Those classes are found in the following main packages:
    • oracle.adf.model.*
    • oracle.jbo.client.*
    • oracle.xml.xsql.*
Suggested Solution:
<prefer-application-packages>
   <package-name>oracle.adf.model.*</package-name>
   <package-name>oracle.jbo.client.*</package-name>
   <package-name>oracle.xml.xsql.*</package-name>
</prefer-application-packages>











"DataBindings.cpx" descriptor appears in the application classpath more than once:
SOLUTION: You might do a clean build if you face this error, or delete the remains of the application from
JDeveloper\system11.1.1.\o.j2ee\drs folder for the integrated server.



oracle.jbo.NoDefException: JBO-25002: Definition actionbazaar.DataControls of type null is not found.
Caused by: oracle.mds.core.MetadataNotFoundException: MDS-00013: no metadata found for metadata object "/.../DataControls.dcx"
SOLUTION: restore DataControls.dcx if deleted.



Next the worst of all, might force one to redevelop the application from scratch:
java.lang.NullPointerException
at oracle.adf.model.binding.DCIteratorBinding.getSortCriteria(DCIteratorBinding.java:3758)
at oracle.adf.model.binding.DCInvokeMethod.setAssociatedIteratorBinding(DCInvokeMethod.java:936)
at oracle.adf.model.binding.DCIteratorBinding.cacheRefOnOperation(DCIteratorBinding.java:5274)
at oracle.jbo.uicli.binding.JUMethodIteratorDef$JUMethodIteratorBinding.getActionBinding(JUMethodIteratorDef.java:283)
at oracle.jbo.uicli.binding.JUMethodIteratorDef.isRefreshable(JUMethodIteratorDef.java:59)
at oracle.adf.model.binding.DCExecutableBindingDef.isRefreshable(DCExecutableBindingDef.java:274)
at oracle.adf.model.binding.DCBindingContainer.refreshExecutables(DCBindingContainer.java:3491)
at oracle.adf.model.binding.DCBindingContainer.internalRefreshControl(DCBindingContainer.java:3332)
at oracle.adf.model.binding.DCBindingContainer.refresh(DCBindingContainer.java:2871)
at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.prepareModel(PageLifecycleImpl.java:112)
at oracle.adf.controller.v2.lifecycle.Lifecycle$2.execute(Lifecycle.java:137)
at oracle.adfinternal.controller.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:192)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.access$400(ADFPhaseListener.java:21)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$PhaseInvokerImpl.startPageLifecycle(ADFPhaseListener.java:231)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener$1.after(ADFPhaseListener.java:267)
at oracle.adfinternal.controller.faces.lifecycle.ADFPhaseListener.afterPhase(ADFPhaseListener.java:71)
at oracle.adfinternal.controller.faces.lifecycle.ADFLifecyclePhaseListener.afterPhase(ADFLifecyclePhaseListener.java:53)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:398)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:185)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
at java.security.AccessController.doPrivileged(Native Method)
at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:176)



An experienced eye would notice the missing “Caused by...” clause due to log truncation. One must dig the full domain log to investigate further. This one is related to missing or corrupted pageDef files. Especially for EJB 3 model projects it might relate to failure of loading beans via jndi or perhaps a malfunctioning Datasource, not created correctly or strangely losing the password. Using local EJB 3 interfaces rather than remote, is recommended for web applications. Some reported that building the application from scratch had been their only workaround. So much for Rapid Application Development (RAD); some others only edited the problematic pages:

1) In the Overview Tab of the page definition file for the problematic page, remove all items (method actions, iterators, trees, etc) in Bindings and Executables, except for the variables entry.

2) In the Application Navigator, rebuild the EJB Session Beans used for this page definition file. Then select these EJB Session Beans (right click) and choose Create Data Control.

3) In the Data Controls window, make sure to click the refresh button.

4) Delete the forms/ tables on the problematic page.

5) Recreate (Click and drag) the forms and/ or tables from the Data Controls for the page in question. And also redefine the method action and other items on your page definition file.

Conclusion

One only hopes when the time comes for deployment to the production application server, it won't be necessary to start development from the beginning. This rarely has been the case for good, old OC4J stand alone server deployments. Perhaps avoiding use of the integrated server and deploying from the early stages of development to the stand alone one is preferable. So much for increasing developer productivity! Finally, one could consult for more tips the resources below.


 References

http://middlewaremagic.com/weblogic by René van Wijk
https://forums.oracle.com/forums/thread.jspa?threadID=931462
http://www.oracle.com/webfolder/technetwork/jdeveloper/howto/11114/managedserver/wlsadfms.html
http://stackoverflow.com/questions/5274693/weblogic-cant-get-roles-for-user-in-ejb3

http://code.google.com/p/nickaiva-blogspot/downloads/detail?name=WebLogic1034DeploymentGuide.pdf&can=2&q=