• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error in accessing EJB from Client...

 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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



Add the above class(or the jar file containing this class) to the classpath.
 
Pras Tiwari
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 186
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't worked with Entity Beans, so i dont have an answer for your question.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic