I concur.  You would need to say something like:

Context blah = context.lookup("java:/comp/env"):

then

creation=PortableRemoteObject.narrow(context.lookup("createCalcSQL"), etc., etc.)


Aaron Mulder wrote:

>         The problem is in your setEntityContext method.  java:comp/env is
> a JNDI Context, not a Properties.  Can you take it from here?
>
> Aaron
>
> On Thu, 21 Sep 2000, Andrew wrote:
> > First, thank you very much for attention. I really need it.
> >
> > And :
> > ejb-jart.xml:
> > <?xml version="1.0" encoding="Cp1251"?>
> >
> > <ejb-jar>
> >     <description>Calculation test</description>
> >     <display-name>Calculation</display-name>
> >     <enterprise-beans>
> >     <entity>
> >         <description>Models calculation</description>
> >       <ejb-name>CalculationBean</ejb-name>
> >       <home>Calc.CalcHome</home>
> >       <remote>Calc.Calc</remote>
> >       <ejb-class>Calc.CalcBean</ejb-class>
> >       <persistence-type>Bean</persistence-type>
> >         <prim-key-class>java.lang.String</prim-key-class>
> >       <reentrant>False</reentrant>
> >             <primkey-field>zaka</primkey-field>
> >             <resource-ref>
> >                 <description>A jdbc connection for the BMP
> > bean</description>
> >                 <res-ref-name>jdbc/SC1</res-ref-name>
> >                 <resource-name>SCTest</resource-name>
> >                 <res-type>javax.sql.DataSource</res-type>
> >                 <res-auth>Container</res-auth>
> >             </resource-ref>
> >             <env-entry>
> >                 <env-entry-name>createCalcSQL</env-entry-name>
> >                 <env-entry-type>java.lang.String</env-entry-type>
> >                 <env-entry-value>insert into calc values ( ?,
> > kf(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))</env-entry-value>
> >             </env-entry>
> >             <env-entry>
> >                 <env-entry-name>deleteCalcSQL</env-entry-name>
> >                 <env-entry-type>java.lang.String</env-entry-type>
> >                 <env-entry-value>delete from calc where
> > zaka=?</env-entry-value>
> >             </env-entry>
> >
> >  </entity>
> >     </enterprise-beans>
> >     <assembly-descriptor>
> >         <container-transaction>
> >             <method>
> >                 <ejb-name>CalculationBean</ejb-name>
> >                 <method-name>*</method-name>
> >             </method>
> >             <trans-attribute>Required</trans-attribute>
> >         </container-transaction>
> >     </assembly-descriptor>
> > </ejb-jar>
> > CalcBean.java:
> >
> > package Calc;
> >
> > import javax.ejb.*;
> > import javax.naming.*;
> > import javax.sql.*;
> > import java.sql.*;
> > import java.math.*;
> > import java.util.*;
> >
> > //EJBException- no specific sys level exception
> > public class CalcBean implements EntityBean{
> >  private EntityContext ctx;
> >  private InitialContext context;
> >
> >  private final static double[] kf_0= new double[15];
> >  static{
> >   Arrays.fill( kf_0, 0);
> >  }
> >  private String creation, deletion;
> >
> > //persistance fields
> >  public String zaka;
> >  double[] kf_a= new double[kf_0.length];
> >
> >  //primary key zaka is upsent- unmodifable
> >  public double[] getKf_a(){
> >   return kf_a;
> >  }
> >  public void setKf_a( double[] kf_a){
> >   this.kf_a= kf_a;
> >  }
> >
> >
> >  Connection getConnection() throws NamingException,SQLException{
> >   DataSource ds= (DataSource)context.lookup( "java:comp/env/jdbc/SC1");
> >   return ds.getConnection();
> >  }
> >
> >  //life cycle map
> >  public void setEntityContext( EntityContext ctx){
> >   this.ctx= ctx;
> >   try{
> >    context= new InitialContext();
> >    Properties env= (Properties)context.lookup( "java:comp/env");
> >    creation= env.getProperty( "createCalcSQL");
> >    deletion= env.getProperty( "deleteCalcSQL");
> >   }catch( NamingException ne){ throw new EJBException( ne.getMessage());}
> >  }
> >  public void unsetEntityContext(){ ctx= null;}
> >
> >  public String ejbCreate( String zaka) throws CreateException{
> >   try{
> >    Connection conn= getConnection();
> >    //"insert into calc values(?, kf(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))"
> >    PreparedStatement pstmt= conn.prepareStatement( creation);
> >    pstmt.setString( 1, zaka);
> >    for( int i= 0; i<= kf_0.length; i++) pstmt.setDouble( i+2, kf_0[i]);
> >    pstmt.executeUpdate();
> >    conn.close();
> >   }catch( Exception e){ throw new CreateException( e.getMessage());}
> >   this.zaka= zaka;
> >   kf_a= (double[])kf_0.clone();
> >   return zaka;
> >  }
> >  public void ejbPostCreate( String zaka){}
> >  public void ejbRemove() throws RemoveException{
> >   try{
> >    Connection conn= getConnection();
> >    PreparedStatement pstmt= conn.prepareStatement( deletion);
> >    pstmt.setString( 1, zaka);
> >    pstmt.executeUpdate();
> >    conn.close();
> >   }catch( Exception e){ throw new RemoveException( e.getMessage());}
> >  }
> >  public String ejbFindByPrimaryKey( String zaka) throws
> > FinderException{//a'la create
> >   try{
> >    Connection conn= getConnection();
> >    PreparedStatement pstmt= conn.prepareStatement( "select kf_a from calc
> > where zaka=?");
> >    pstmt.setString( 1, zaka);
> >    ResultSet rs= pstmt.executeQuery();
> >    if( !rs.next()) throw new ObjectNotFoundException( "Calculation not found
> > "+ zaka);
> >
> >    this.zaka= zaka;
> >    Array kfs= rs.getArray( 1);
> >    BigDecimal[] val= (BigDecimal[])kfs.getArray();
> >    for( int i= 0; i< val.length; i++) kf_a[i]= val[i].doubleValue();
> >    conn.close();
> >   }catch( SQLException e){ throw new EJBException( e.getMessage());
> >   }catch( NamingException e){ throw new EJBException( e.getMessage());}
> >   return zaka;
> >  }
> >
> >  //in transactions
> >  public void ejbLoad(){
> >   try{
> >    Connection conn= getConnection();
> >
> >    PreparedStatement pstmt= conn.prepareStatement( "select kf_a from calc
> > where zaka=?");
> >    pstmt.setString( 1, zaka);
> >    ResultSet rs= pstmt.executeQuery();
> >    if( !rs.next()) throw new NoSuchEntityException( "No rows found");
> >    Array kfs= rs.getArray( 1);
> >    BigDecimal[] val= (BigDecimal[])kfs.getArray();
> >    for( int i= 0; i< val.length; i++) kf_a[i]= val[i].doubleValue();
> >    conn.close();
> >   }catch( SQLException e){ throw new EJBException( "ejbLoad:
> > "+e.getMessage());
> >   }catch( NamingException e){ throw new EJBException( "ejbLoad:
> > "+e.getMessage());}
> >  }
> >  public void ejbStore(){
> >   try{
> >    Connection conn= getConnection();
> >    PreparedStatement pstmt= conn.prepareStatement( "update calc (kf_a)
> > et( kf(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)) where zaka=?");
> >    int i= 0;
> >    for(; i< kf_a.length; i++) pstmt.setDouble( i+1, kf_a[i]);
> >    pstmt.setString( i+1, zaka);
> >   }catch( Exception e){ throw new EJBException( "ejbStore:
> > "+e.getMessage());}
> >  }
> >
> >  //vmemory management-release connections etc. internal resource management
> >  public void ejbActivate(){}
> >  public void ejbPassivate(){}
> > }
> > CalcHome.java:
> > package Calc;
> > import javax.ejb.*;
> > import java.rmi.*;
> >
> > public interface CalcHome extends EJBHome{
> >  Calc create( String zaka) throws RemoteException, CreateException;//public
> > abstract by default
> >  Calc findByPrimaryKey( String zaka) throws RemoteException,
> > FinderException;//RemoteException not declared in bean...
> > }
> > ----------------------------------------------------------------------------
> > ----------------------------
> > Not only find method has this effect but create too.And
> > CalcHome
> > lc=(CalcHome)PortableRemoteObject.narrow( context.lookup( "CalculationBean")
> > works fine but calc.create/find throws exception.
> >
> >
> > ----- Original Message -----
> > From: "Aaron Mulder" <[EMAIL PROTECTED]>
> > To: "jBoss" <[EMAIL PROTECTED]>
> > Sent: Thursday, September 21, 2000 7:57 PM
> > Subject: Re: [jBoss-User] JNP/ClassNotFound source
> >
> >
> > > Can you send your ejb-jar.xml, and the contents of your bean
> > > implementation's ejbFindByPrimaryKey method?
> > >
> > > Aaron
> > >
> > > On Thu, 21 Sep 2000, Andrew wrote:
> > > > import Calc.*;
> > > > import javax.rmi.*;
> > > > import javax.naming.*;
> > > > import java.util.*;
> > > >
> > > > class a{
> > > >  public static void main( String[] arg) throws Exception{
> > > >   Hashtable prop= new Hashtable();
> > > >   prop.put( InitialContext.PROVIDER_URL, "localhost");
> > > >   prop.put( InitialContext.INITIAL_CONTEXT_FACTORY,
> > > > "org.jnp.interfaces.NamingContextFactory");
> > > >
> > > >   InitialContext context= new InitialContext( prop);
> > > >   CalcHome calc=
> > > > alcHome)PortableRemoteObject.narrow( context.lookup( "CalculationBean"),
> > > > CalcHome.class);
> > > >   calc.findByPrimaryKey( "test1");//Error
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >  }
> > > > }
> > > >
> > > > In jboss.xml
> > > >     <enterprise-beans>
> > > >        <entity>
> > > >   <ejb-name>CalculationBean</ejb-name>
> > > >   <jndi-name>CalculationBean</jndi-name>
> > > >   <configuration-name>Default BMP EntityBean</configuration-name>
> > > >        </entity>
> > > >      </enterprise-beans>
> > > >
> > > > ----- Original Message -----
> > > > From: "Aaron Mulder" <[EMAIL PROTECTED]>
> > > > To: "jBoss" <[EMAIL PROTECTED]>
> > > > Sent: Tuesday, September 19, 2000 9:05 PM
> > > > Subject: Re: [jBoss-User] JNP/ClassNotFound
> > > >
> > > >
> > > > > As Ole indicated in a parallel message, the ClassNotFoundException
> > > > > is cosmetic and does not cause problems.
> > > > > The JNP exception you see looks like a problem in your EJB
> > > > > implementation class - a typo in a JNDI name or something.  Can you
> > > > > double-check all statements where you look up something in JNDI?  You
> > can
> > > > > post the bean implementation code here, if you like.  But it looks
> > like
> > > > > you're trying to do something like:
> > > > >
> > > > > Foo foo = (Foo)context.lookup("java:comp/env");
> > > > >
> > > > > Where you don't actually get the type of object you're expecting
> > > > > (because java:comp/env is a sub-context not a Foo).
> > > > >
> > > > > Aaron
> > > > >
> > > > > On Tue, 19 Sep 2000, Andrew wrote:
> > > > > > Hello, win2000+jdk1.3+(jboss 2.0 beta prod 01) config has the
> > following
> > > > > > problems:
> > > > > > 1)After deploying BMP bean in \deploy dir and running the server I
> > find
> > > > out
> > > > > > this error message on console:
> > > > > > [Container factory] java.lang.ClassNotFoundException: class
> > > > > > org.jboss.security.EJBSecurityManagerDefaultImpl
> > > > > > -class located in jboss.jar.
> > > > > > but bean was deployed:
> > > > > >  [Container factory] Deployed application: file:/C:/jboss/deploy/
> > > > > > After that I wrote some tiny client calling
> > indByPrimaryKey( String) on
> > > > > > home iface .All is ok while no
> > > > > > home.findByPrimaryKey() or other method invocation- result is
> > > > > >
> > > > > > java.rmi.ServerException: RemoteException occurred in server thread;
> > > > nested
> > > > > > exception is:
> > > > > > java.rmi.ServerException: Exception occurred; nested exception is:
> > > > > > java.lang.ClassCastException: org.jnp.interfaces.NamingContext
> > > > > > java.rmi.ServerException: Exception occurred; nested exception is:
> > > > > > java.lang.ClassCastException: org.jnp.interfaces.NamingContext
> > > > > > java.lang.ClassCastException: org.jnp.interfaces.NamingContext
> > > > > > at
> > > > > >
> > > >
> > sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteC
> > > > > > all.java:245)- strange... this class is in jdk jar file
> > > > > > at
> > > >
> > sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:220)
> > > > > > at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:122)
> > > > > > at
> > > > > >
> > > >
> > org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker_Stub.invokeHome(Unkno
> > > > > > wn Source)
> > > > > > at
> > > > > >
> > > >
> > org.jboss.ejb.plugins.jrmp.interfaces.HomeProxy.invoke(HomeProxy.java:221)
> > > > > > at $Proxy0.findByPrimaryKey(Unknown Source)
> > > > > > at a.main(a.java:14)
> > > > > > Exception in thread "main"
> > > > > >
> > > > > > What's the problem?
> > > > > > Thank you.
> > > > > >
> > > > > >
> > > > > >
> > > > > > --
> > > > > > --------------------------------------------------------------
> > > > > > To subscribe:        [EMAIL PROTECTED]
> > > > > > To unsubscribe:      [EMAIL PROTECTED]
> > > > > > Problems?:           [EMAIL PROTECTED]
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > --------------------------------------------------------------
> > > > > To subscribe:        [EMAIL PROTECTED]
> > > > > To unsubscribe:      [EMAIL PROTECTED]
> > > > > Problems?:           [EMAIL PROTECTED]
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > --------------------------------------------------------------
> > > > To subscribe:        [EMAIL PROTECTED]
> > > > To unsubscribe:      [EMAIL PROTECTED]
> > > > Problems?:           [EMAIL PROTECTED]
> > > >
> > >
> > >
> > >
> > > --
> > > --------------------------------------------------------------
> > > To subscribe:        [EMAIL PROTECTED]
> > > To unsubscribe:      [EMAIL PROTECTED]
> > > Problems?:           [EMAIL PROTECTED]
> > >
> > >
> >
> >
> >
> > --
> > --------------------------------------------------------------
> > To subscribe:        [EMAIL PROTECTED]
> > To unsubscribe:      [EMAIL PROTECTED]
> > Problems?:           [EMAIL PROTECTED]
> >
>
> --
> --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> Problems?:           [EMAIL PROTECTED]



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to