vikram veera

Ranch Hand
+ Follow
since Dec 26, 2000
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by vikram veera

Hi ,

You can go to the below URL to find more info on EJBs.This will details you what is ejb and its lifecycle.

EJB information in developerparadise

Thanks
Vikram
www.developerparadise.com
You can find the code with example in the below URL.It will be more useful.
Using the Comparable and Comparator interfaces to sort data in Java

Thanks
Vikram
www.developerparadise.com
16 years ago
Hi,
Can you copy the code you are trying to Compile.In my code you may miss some semicolon in the code.

Thanks
Vikram
16 years ago
Hi,
You need to use the string tokenizer class to split the string into tokens.
Please find below link which has the code ,which will help solve your problem.In the code it split the string from the file using
string tokenizer class .You need to add those string in Arraylist.

http://www.developerparadise.com/devworld/code/Java/1001JavaIO/JavaIO-1-2-Integerate.php

Thanks
Vikram
www.developerparadise.com
16 years ago
I have changed the code in such a way .what you intend to see the output.See the below Code which will help you

import java.io.*;


// @author Vanessa

public class buyingLunch {

public void showValues()
{
//Display prices of items
System.out.println("Apples cost $.50 each " +
"\n Cheese cost $2.05 per pound " +
"\n Bread cost $1.00 per loaf");
}
public static float getValues()
throws IOException
{
//set input stream
BufferedReader stdin = new BufferedReader(
new InputStreamReader(System.in));
//get numbers from user input
System.out.print("How many apples do you want? ");
float x = Integer.parseInt(stdin.readLine()) * .50f;

//asks user for 2nd number, than converts it to an integer
System.out.print("How many pounds of cheese do you want? ");
float y = Integer.parseInt(stdin.readLine()) * 2.05f;

//asks user for 2nd number, than converts it to an integer
System.out.print("How many loaves of bread do you want? ");
float z = Integer.parseInt(stdin.readLine()) * 1.00f;
}
public static float calculateTotal()
{
//add x,y,z
float sum = x + y + z;

//Display sum of x,y
System.out.println("Your total is $" + sum);
}
}

Thanks
Vikram
www.developerparadise.com
16 years ago
a) String objects are constants and immutable whereas StringBuffer objects are not.
b) String class supports constant strings whereas StringBuffer class supports growable and modifiable strings.

Thanks
Vikram
For more details see the below URL
developerparadise.com
16 years ago
Please find the code in the below URL
http://developerparadise.com/devworld/Faqs/2007/Java/3Collection/JavaCollectionFaqs_3_Integerate.php#q0

[ February 22, 2008: Message edited by: vikram veera ]
[ February 22, 2008: Message edited by: vikram veera ]
16 years ago
We have recently started a new Website named www.developerparadise.com .please have a look and let me know your comments. Going forward if you have any quires related to java, dotnet and oracle technology you can post it in our discussion forum. Our forum URL is
http://www.developerparadise.com/forum/index.php

If you are interested in writing articles to our site you are most welcome
Our website URL is http://www.developerparadise.com
Please have a look @ our URL.
[ September 13, 2007: Message edited by: vikram veera ]
17 years ago
Hi All,

I am trying connect to webserver using https from apche HttpClient.
I created keystore and placed in server. The same configured in server.xml too. If I am invoking through browser its working fine. but if i try to invoke through HttpClient its throwing following exception. Pls help me in this regards.


at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(DashoA12275)
at com.sun.net.ssl.internal.ssl.Handshaker.process_record(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA12275)
at com.sun.net.ssl.internal.ssl.AppOutputStream.write(DashoA12275)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:67)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:125)
at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:827)
at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:1975)
at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:993)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324)
at test.SSLTest.main(SSLTest.java:36)

My Client code snipet is

HttpClient httpclient = new HttpClient();
java.security.Security.addProvider( new com.sun.net.ssl.internal.ssl.Provider());


PostMethod httpget = new PostMethod("myurl"); //servlet url
try {
httpclient.executeMethod(httpget);
System.out.println(httpget.getStatusLine());
} catch(Exception e){
System.out.println(" Exception "+e);
e.printStackTrace();
}finally {
httpget.releaseConnection();
}
}
I am using Weblogic Server 8.1 SP3.
My Action class is calling a stateless session bean which is deployed in WLS.
In weblogic-ejb-jar.xml we have set max bean instance in the pool for the stateless session bean as follow

<pool>
<max-beans-in-free-pool>20</max-beans-in-free-pool>
<initial-beans-in-free-pool>10</initial-beans-in-free-pool>
</pool>
10 beans fully occupied fails before 11th got created.

Problem:
Pool miss ratio is not 00.00 it is 015.8 something.

Error encountered:- A new instance of Bean Creation Failed

I am getting the following Exception saying

Runtime Exception while invoking an EJB Component invocation of EJB timed out while waiting to get an instance from the free pool.

Can any one ,Please share inputs or help in this regards.

Regards
Vikram
[ February 09, 2006: Message edited by: vikram veera ]
what is the difference between ArrayList and Vector?
22 years ago
Hai every one,
Please help me In this problem ...
And also what all the steps is required to execute jsp in weblogic server5.1..
And also how to set the property file for weblogic to run jsp..
where i have to store the jspfile in weblogic...
Please help mein this problem...
Bye from
vikram
23 years ago
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 String getProductID() throws RemoteException;
}

ProductBean.java
==================
import java.sql.*;
import javax.naming.*;
import javax.ejb.*;
import java.util.*;
import java.rmi.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 void setName(String name) throws RemoteException {
System.out.println("getName() called.");
this.name = name;
}

public String getDescription() throws RemoteException {
System.out.println("getDescription() called.");
return description;
}

public void setDescription(String description) throws RemoteException {
System.out.println("setDescription() called.");
this.description = description;
}

public double getBasePrice() throws RemoteException {
System.out.println("getBasePrice() called.");
return basePrice;
}

public void setBasePrice(double price) throws RemoteException {
System.out.println("setBasePrice() called.");
this.basePrice = price;
}

public String getProductID() {
System.out.println("getProductID() called.");
return productID;
}
//
// EJB-required methods
//

public void ejbActivate() throws RemoteException {
System.out.println("ejbActivate() called.");
}

public void ejbRemove() throws RemoteException {
System.out.println("ejbRemove() called.");
}

public void ejbPassivate() throws RemoteException {
System.out.println("ejbPassivate () called.");
}

public void ejbLoad() throws RemoteException {
System.out.println("ejbLoad() called.");
}
public void ejbStore() throws RemoteException {
System.out.println("ejbStore() called.");
}

public void setEntityContext(EntityContext ctx) throws RemoteException {
System.out.println("setEntityContext called");
this.ctx = ctx;
}

public void unsetEntityContext() throws RemoteException {
System.out.println("unsetEntityContext called");
this.ctx = null;
}

public void ejbPostCreate(String productID, String name, String description, double basePrice) throws RemoteException {
System.out.println("ejbPostCreate() called");
}

public String ejbCreate(String productID, String name, String description, double basePrice) throws CreateException, RemoteException {
System.out.println("ejbCreate(" + productID + ", " + name + ", " + description + ", " + basePrice + ") called");
this.productID = productID;
this.name = name;
this.description = description;
this.basePrice = basePrice;
return null;
}
// No finder methods - they are implemented by Container
}
ProductHome
==============

import javax.ejb.*;
import java.rmi.RemoteException;
import java.util.Enumeration;

public interface ProductHome extends EJBHome {

Product create(String productID, String name, String description, double basePrice) throws CreateException, RemoteException;
// Finder methods. These are implemented by the
// container. You can customize the functionality of
// these methods by using the EJB Container tools.
public Product findByPrimaryKey(String key) throws FinderException, RemoteException;
public Enumeration findByName(String name) throws FinderException, RemoteException;
public Enumeration findByDescription(String description) throws FinderException, RemoteException;
public Enumeration findByBasePrice(double basePrice) throws FinderException, RemoteException;
public Enumeration findExpensiveProducts(double minPrice) throws FinderException, RemoteException;
public Enumeration findCheapProducts(double maxPrice) throws FinderException, RemoteException;
public Enumeration findAllProducts() throws FinderException, RemoteException;
}
ProductPk.java
==============
//package com.wiley.compBooks.roman.entity.product;
import java.io.Serializable;

public class ProductPK implements java.io.Serializable {

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...

Please help me in this problem