Amit Jaipaul

Greenhorn
+ Follow
since Jul 17, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Amit Jaipaul

Hi,

There is no harm in calling finder method from a servlet. We can very well call them from servlet.

It is better to call Entity Bean finder methods from Session Bean and put the corresponding values of the business object into a value object and pass it to the client.
confusing problem. i agree both with parthiban and PNS. This exception comes only when stuff within a Hashtable does implement Serializable.

However this is not a solution, Arnold just try recreating the Jar(with EJB calling another EJB) and redeploying ur EJB's.
Hi Vikas,

Whether we call our EJBs from JSP client or Swing based client, the process of same. Just write the code for looking up ur Home and Remote stubs in ur swing classes and populate GUI's fields.

1. Create Initial Context.
2. Lookup Home.
3. Get remote class from home.
4.
Hi,

Value Objects need to be serializable, otherwise how do we pass them on to the client thro network? Because we can write only serializable objects to the stream.
I think u dont have to worry about rollback if app. server crashes. In that case DB server will rollback the transaction.
Hi Sandy,

Please use the following for gettting the child nodes

instead of

as Element is used only for getting the Root.
Hi Douglas,

Please try to create your Context Object as follows:
// Set initial context and URL properties
Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://<host_name>:<port>");

// Create initial context and lookup
Context initial = new InitialContext(env);
Object obj = initial.lookup("java:comp/env/ejb/MySessionEJBHome"); (If you are accessing ur bean from within the app server)
Object obj = initial.lookup("MySessionEJBHome"); (If you are trying to access your bean from outside ur app server)
MySessionEJBHome home = (MySessionEJBHome)
PortableRemoteObject.narrow(obj,MySessionEJBHome.class);

I hope the above should solve ur problem.
Hi Chuck,

I think you/generator have not called the create() on the Home stub. I am unable to see <home stub>.create() anywhere in the code. Please check if there is some method in your client code where you might be getting home thro' some service locator.
Hi Kishore,

Can u post code for JSP and SP, as it is difficult to say as to why this problem might be coming. However one thing is sure, that some operation you are trying to do after starting the transaction which is illegal. Perhaps that is the reason for IllegalStateException and failure of the transaction.
Hi Chris,

Try giving ur appserver IP in /etc/hosts file of ur webserver linux box. As ur webserver is tyring lookup in the localhost itself even though u have commented out that mapping, it might be possible that by default ur webserver is looking up in the localhost only as it does not have any mapping to look up to.
Hi,

Each call from the client will start a new transaction and will be committed before returning to the client.
Hi Roger,

u can go to search at the top of page and give 'Interview Questions' as the search criteria. Select 'Job Discussion' as the forum. You will be able to find lots of interview questions related to Java and EJB.
Use of ejbSelectXXX() or findXXX() methods depends wholly on the decision of the developer.

One requirement could be that, If our requirements demands that client should be able to use the result of the query, then we should go for findXXX() method.

However if we need the result for processing within the bean and we do not want to expose the result directly to the client, then, we should go for ejbSelectXXX() method.

Decision can be made also on how we want the Transaction Context to be handled. ejbSelectXXX() methods are run in the same transaction context as the called method, whereas findXXX() execute as the attributes defind by the bean provider.
Just check if this app server supports hot deployment. If it supports hot deployment then, simply putting the .jar file again in the deploy directory will redeploy all the beans.

This saves a lot of deployment time.

If ur app server does not support hot deployment (not part of EJB2.0 specs), u can go for JBoss 3.2.4, which is absolutely free and supports hot deployment too.
Try using following code for getting initial context:

public static Context getInitialContext()
throws javax.naming.NamingException
{
context initialized by jndi.properties file
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES, "jboss.naming rg.jnp.interfaces");
p.put(Context.PROVIDER_URL, "localhost:1099");
return new javax.naming.InitialContext(p);
}