Hi All,

I've written a sample EJB which takes two ints and returns an int. Its a
stateless Session Bean. Everything works out well. I deploy it using
j2ee.My client can contact the bean and could get the result.

Now, I modified the code and put a method which creates a sample Cloudscape
db. And when i run the client I get this exception in the client window.

Caught an unexpected exception!
java.rmi.ServerException: RemoteException occurred in server thread; nested
exception is:
        java.rmi.RemoteException: Unknown Exception/Error thrown by EJB
method.;
 nested exception is:
        java.lang.NoClassDefFoundError
java.rmi.RemoteException: Unknown Exception/Error thrown by EJB method.;
nested
exception is:
        java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError
        <>

And the error log says:

java.rmi.RemoteException: Unknown Exception/Error thrown by EJB method.;
nested exception is:
        java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError:
java.security.AccessControlException: access denied
(java.lang.RuntimePermission modifyThreadGroup)
        at
java.security.AccessControlContext.checkPermission(AccessControlContext.java
:272)
        at
java.security.AccessController.checkPermission(AccessController.java:399)
        at
java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
        at
com.sun.enterprise.J2EESecurityManager.checkAccess(J2EESecurityManager.java:
53)
        at java.lang.ThreadGroup.checkAccess(ThreadGroup.java:279)
        at java.lang.Thread.init(Thread.java:265)
        at java.lang.Thread.(Thread.java:449)
        at COM.jbms._44._1076.run(Unknown Source)
        at COM.cloudscape.core.MonitorBoot.start(Unknown Source)
        at COM.cloudscape.core.JDBCBoot.boot(Unknown Source)
        at COM.cloudscape.core.JDBCDriver.boot(Unknown Source)
        at COM.cloudscape.core.JDBCDriver.(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:120)
        at MyBeanEJB.writeData(MyBeanEJB.java:15)
        at MyBeanEJB.add(MyBeanEJB.java:9)
        at MyBeanEJB_EJBObjectImpl.add(MyBeanEJB_EJBObjectImpl.java:19)
        at _MyBeanEJB_EJBObjectImpl_Tie._invoke(Unknown Source)
        at
com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPO
AServerSC.java:423)
        at
com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOA
ServerSC.java:137)
        at
com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC
.java:98)
        at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:227)
        at
com.sun.corba.ee.internal.iiop.CachedWorkerThread.doWork(IIOPConnection.java
:262)
        at
com.sun.corba.ee.internal.iiop.CachedWorkerThread.run(IIOPConnection.java:23
0)

javax.naming.NameNotFoundException: Subcontext: MyBean_MyBeanEJB_MyBeanJNDI
not found
        <>

javax.naming.NameNotFoundException: Subcontext: MyBean_MyBeanEJB_MyBeanJNDI
not found
        <>

java.lang.NoClassDefFoundError
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:120)
        at MyBeanEJB.writeData(MyBeanEJB.java:15)
        at MyBeanEJB.add(MyBeanEJB.java:9)
        at MyBeanEJB_EJBObjectImpl.add(MyBeanEJB_EJBObjectImpl.java:19)
        at _MyBeanEJB_EJBObjectImpl_Tie._invoke(Unknown Source)
        at
com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPO
AServerSC.java:423)
        at
com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOA
ServerSC.java:137)
        at
com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC
.java:98)
        at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:227)
        at
com.sun.corba.ee.internal.iiop.CachedWorkerThread.doWork(IIOPConnection.java
:262)
        at
com.sun.corba.ee.internal.iiop.CachedWorkerThread.run(IIOPConnection.java:23
0)

java.rmi.RemoteException: Unknown Exception/Error thrown by EJB method.;
nested exception is:
        java.lang.NoClassDefFoundError
java.lang.NoClassDefFoundError
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:120)
        at MyBeanEJB.writeData(MyBeanEJB.java:15)
        at MyBeanEJB.add(MyBeanEJB.java:9)
        at MyBeanEJB_EJBObjectImpl.add(MyBeanEJB_EJBObjectImpl.java:19)
        at _MyBeanEJB_EJBObjectImpl_Tie._invoke(Unknown Source)
        at
com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatchToServant(GenericPO
AServerSC.java:423)
        at
com.sun.corba.ee.internal.POA.GenericPOAServerSC.internalDispatch(GenericPOA
ServerSC.java:137)
        at
com.sun.corba.ee.internal.POA.GenericPOAServerSC.dispatch(GenericPOAServerSC
.java:98)
        at com.sun.corba.ee.internal.iiop.ORB.process(ORB.java:227)
        at
com.sun.corba.ee.internal.iiop.CachedWorkerThread.doWork(IIOPConnection.java
:262)
        at
com.sun.corba.ee.internal.iiop.CachedWorkerThread.run(IIOPConnection.java:23
0)

And my code is (MyBeanEJB.java):

import java.sql.*;
import java.rmi.RemoteException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;

public class MyBeanEJB implements SessionBean{

        public int add(int a,int b) throws RemoteException{
                 writeData();
                return a+b;
        }

        public void writeData(){
                try{
                        Class.forName("COM.cloudscape.core.JDBCDriver");
                        Connection con =
DriverManager.getConnection("jdbc:cloudscape:RajitDB;create=true");
                        con.setAutoCommit(false);
                        Statement s = con.createStatement();
                        s.execute("create table SampleTable(name
varchar(40),num data)");
                        s.execute("Insert into SampleTable
values('Rajit',20)");
                        s.execute("Insert into SampleTable
values('Mr.Guy',20)");
                        con.commit();
                        s.close();
                        con.close();
                }
                catch(Exception ex){
                        ex.printStackTrace();
                }
        }

        public MyBeanEJB() {}
        public void ejbCreate() {}
        public void ejbRemove() {}
        public void ejbActivate() {}
        public void ejbPassivate() {}
        public void setSessionContext(SessionContext sc) {}
}

I could as well have written an entity bean for handling the database
transaction. But can I not do the same thing in a stateless SessionBean?

I have all the required jars and classes in my CLASSPATH.

Please help me with this,

regards,
Rajit.


_____________________________________________
Free email with personality! Over 200 domains!
http://www.MyOwnEmail.com

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to