aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Error in accessing EJB from Client... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Error in accessing EJB from Client..." Watch "Error in accessing EJB from Client..." New topic
Author

Error in accessing EJB from Client...

Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi ,

I am developing a EJB Applicaion using EJB CMP 2.0 spec. I am using JBOSS 4,0,3 as an appln server. My all ejb's are working fine when i am accessing them through my client file using remmote interface. But problem comes When i access one of my ben using same client that i ve used to access other EJB's.(ofcourse JNDI name will be differnt for each EJB in client). It gives me error like:-
==================
java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.lang.ClassNotFoundException: org.postgresql.util.PSQLException (no security manager: RMI class loader disabled)
===================

& my client code is:-
===========================
import java.sql.Timestamp;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import javax.transaction.UserTransaction;

//all import classes related to EJB's interfaces here//
public class Client {
private static UserTransaction utx = null;

public static void main(String[] args) throws Exception {
Context initialContext = null;
try {
Hashtable h = new Hashtable();
h.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
h.put(Context.PROVIDER_URL, "localhost:1099");
initialContext = new InitialContext(h);
} catch (Exception e) {
System.err.println("Cannot get initial context for JNDI: " + e);
System.exit(2);
}
System.out.println("Getting a UserTransaction object from JNDI");
try {
utx = (UserTransaction) initialContext.lookup("UserTransaction");
} catch (Exception e) {
System.err.println("Cannot lookup UserTransaction: " + e);
System.exit(2);
}
// Connecting to Home thru JNDI
System.out.println("Connecting to the CDBeanHome");
EnquiryMasterHome home = null;
try {
home = (EnquiryMasterHome)PortableRemoteObject.narrow(
initialContext.lookup("ejb/EnquiryMaster"),
EnquiryMasterHome.class);
} catch (Exception e) {
System.err.println("Cannot lookup :" + e);
System.exit(2);
}
System.out.println("Creating a new CDBean in database");
EnquiryMaster a1 = null;
try {
a1 = home.create("E000023","23",new Timestamp(System.currentTimeMillis()),"C000230","no comments","no terns","Prashant","Pending",true);
} catch (Exception e) {
System.err.println("Cannot create CDBean: " + e);
System.exit(2);
}
}
}
===========================

I don't know what is problem. The same code of above client is working fine for my all other beans. But its only not working with my single bean whose JNDI name is:-"ejb/EnquiryMaster"

What is problem here. Please help me. Thanx in advance..

Prash


********Deserve Before You Desire********
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10268
    
169

java.lang.ClassNotFoundException: org.postgresql.util.PSQLException


Add the above class(or the jar file containing this class) to the classpath.


[My Blog] [JavaRanch Journal]
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi jaikiran,

Thanx for your immediate reply. As u told me dat i should add "org.postgresql.util.PSQLException" class into my class path. But the same client file is working fine for my all other EJB's. Why this is happening???

Please tell me.

Thanx in advance.

Prash.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10268
    
169

home.create("E000023","23",new Timestamp(System.currentTimeMillis()),"C000230","no comments","no terns","Prashant","Pending",true);


This specific bean might have thrown the org.postgresql.util.PSQLException. Other beans might have successfully executed.
[ February 21, 2006: Message edited by: jaikiran pai ]
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi jaikiran,

I ve added "org.postgresql.util.PSQLException" this class into my claspath. Now when i m executing my client i m getting error like:-
=========
java.rmi.UnmarshalException: Error unmarshaling return; nested exception is:
java.io.InvalidClassException: org.postgresql.util.PSQLException; local class incompatible: stream classdesc serialVersionUID = -1744279245513986945, local class serialVersionUID = -3369378126076749340
==========

Please tell me where is problem??

Thanx in advance.

Prash
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10268
    
169

The version of the jar file containing the org.postgresql.util.PSQLException class is different on the server and the client. Maintain the same jar file in both the server and client classpath
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
And also one more point is that the only difference between this bean & my other beans in my Application is that this bean contains a CMP fiels of type "boolean". & other beans not containing bolean fields as parameter for creating bean.
I Think here there will be problem in passing boolean value as parameter and it might b throwing above "org.postgresql.util.PSQLException" exception.

Is it right???/

If yes/no then how to solve this problem???

Thanx,
Prash
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi jaikiran,

I have 2 versions of jar file containing class "org.postgresql.util.PSQLException" . I have tried the other jar file in my classpath. Now After executing client its giving me error like.:-
============
16:28:27,953 INFO [STDOUT] MAXENQID=6
16:28:28,000 ERROR [LogInterceptor] EJBException in method: public abstract econify.enqmaster.interfaces.EnquiryMaster econify.enqmaster.interfaces.EnquiryMasterHome.create(java.lang.String,java.lang.String,java.sql.Timestamp,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.Boolean) throws javax.ejb.CreateException,java.rmi.RemoteException, causedBy:
org.postgresql.util.PSQLException: Unsupported Types value: 16
at org.postgresql.jdbc2.AbstractJdbc2Statement.setObject(AbstractJdbc2Statement.java:1626)
============


Where i m going wrong???
Also can u please tell me what is meaning of "Unsupported Types value: 16" in above error?
Please tell me.

Thanx
Prash
Pras Tiwari
Ranch Hand

Joined: Nov 07, 2005
Posts: 186
Hi,

And alos in my above bean when i am removing fields with boolean datatype from EJBCreate method, my bean works fine. So its sure that the problem is due to fileds with boolean types. So how to deal with boolean fields in EJB???
I want to set n get values of boolean fields in My database through EJB. How should i do that???

Please help me.
Thanx,
Prash
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10268
    
169

I haven't worked with Entity Beans, so i dont have an answer for your question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in accessing EJB from Client...