hai everyone, I set connection pool & deploy the bean in weblogic perfectly... My connection pool look like this.. weblogic.jdbc.connectionPool.demoPool=\ url=jdbc dbc:sample,\ driver=sun.jdbc.odbc.JdbcOdbcDriver,\ initialCapacity=1,\ maxCapacity=2,\ capacityIncrement=1,\ props=user=scott;password=tiger;server=none # Add a TXDataSource for the connection pool: weblogic.jdbc.TXDataSource.weblogic.jdbc.jts.demoPool=demoPool # # Add an ACL for the connection pool: weblogic.allow.reserve.weblogic.jdbc.connectionPool.demoPool=everyone
But i have a problem while running a client it through an exception As given below javax.ejb.EJBException at weblogic.rmi.extensions.AbstractRequest.sendReceive(AbstractRequest.java:76) at ProductBeanHomeImpl_WLStub.create(ProductBeanHomeImpl_WLStub.java:184) at ProductBeanHomeImpl_ServiceStub.create(Compiled Code) at Client.main(Compiled Code) Destroying products.. please help me in the problem what i have to do next.....
My code is given below Product.java ------------- import javax.ejb.*; import java.rmi.RemoteException; public interface Product extends EJBObject { // Getter/setter methods for Entity Bean fields public String getName() throws RemoteException; public void setName(String name) throws RemoteException;
public String getDescription() throws RemoteException; public void setDescription(String description) throws RemoteException; public double getBasePrice() throws RemoteException; public void setBasePrice(double price) throws RemoteException;
public class ProductBean implements EntityBean { protected EntityContext ctx; // Container-managed state fields. Note that they must // be public. public String productID;// PK public String name; public String description; public double basePrice; public ProductBean() { System.out.println("New Product Entity Bean Java Object created by EJB Container."); } // // Business Logic Methods // // Simple getter/setter methods of Entity Bean fields. public String getName() throws RemoteException { System.out.println("getName() called."); return name; }
public String productID; public ProductPK(String productID) { this.productID = productID; } public ProductPK() { } public String toString() { return productID.toString(); } } Client.java ============= //package com.wiley.compBooks.roman.entity.product; import javax.ejb.*; import javax.naming.*; import java.rmi.*; import java.io.*; import java.util.Enumeration; import java.util.*; /** * Client test application on a Container-Managed Entity Bean, Product. */ public class Client { public static void main(String[] args) { ProductHome home = null; try { Properties props= new Properties(); props.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory"); Context ctx=new InitialContext(props); home = (ProductHome) ctx.lookup("ProductHome"); home.create("123-456-7890", "P5-350", "350MhzPentium", 200); home.create("123-456-7891", "P5-400", "400MhzPentium", 300); home.create("123-456-7892", "P5-450", "450MhzPentium", 400); home.create("123-456-7893", "SD-64", "64MBSDRAM", 50); home.create("123-456-7894", "SD-128", "128MBSDRAM", 100); home.create("123-456-7895", "SD-256", "256MBSDRAM", 200); /* * Find a Product, and print out it's description */ Enumeration enum = home.findByName("SD-64"); System.out.println("The following product descriptions match the product name SD-64:"); while (enum.hasMoreElements()) { Product prod = (Product) enum.nextElement(); System.out.println(prod.getDescription()); } System.out.println("Calling finder to find all products that cost $200"); enum = home.findByBasePrice(200); while (enum.hasMoreElements()) { Product prod = (Product) enum.nextElement(); System.out.println(prod.getDescription()); } } catch (Exception e) { e.printStackTrace(); } finally { if (home != null) { try { System.out.println("Destroying products..");
/* * Find all the products */ Enumeration enum = home.findAllProducts(); while (enum.hasMoreElements()) { try { Product prod = (Product) enum.nextElement(); if (prod.getProductID().startsWith("123")) { prod.remove(); } } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } } } } Finder script syntax look like this... (=name $name) (=description $description) (=basePrice $basePrice) (>basePrice $minPrice) (<basePrice $minPrice)> i set it in weblogic server... Deploy bean in weblogic5.1 is perfect... there is no problem in this... I have a problem while running client...