You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@beehive.apache.org by Timothy Brown <tb...@earthlink.net> on 2005/01/30 02:31:49 UTC

Control initialization failure

I am getting the following error when I execute the test:

 

EmployeeManagerImpl: Attemping to call employeeDB.selectEmployee( 100 ) 

ControlException caught: Control initialization failure[Contextual service
org.apache.beehive.controls.api.context.ResourceContext is not available]

 

Any ideas?

 

Thanks,

 

Tim

 

EmployeeTest.java

 

package test;

 

import controls.employee.EmployeeManagerBean;

 

public class EmployeeTest

{

 

     public void selectEmployee()

     {

          try

          {

               EmployeeManagerBean empMgrBean = (EmployeeManagerBean)

               java.beans.Beans.instantiate(
this.getClass().getClassLoader(),"controls.employee.EmployeeManagerBean");

 

               String sRetVal = empMgrBean.selectEmployee();

               System.out.println( sRetVal );

          } 

          catch( ClassNotFoundException cnfe ) 

          {  System.out.println("Error: " +cnfe.toString());

          }

          catch( Exception e ) 

          {  System.out.println("Error: " +e.toString());

          }

          

     }     

}

 

EmployeeManagerImpl.jcs

 

package controls.employee; 

 

import org.apache.beehive.controls.api.bean.*;

import java.sql.SQLException;

import java.rmi.RemoteException;

 

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.Statement;

import java.sql.ResultSet;

 

import javax.sql.DataSource;

import javax.naming.InitialContext;

import javax.naming.Context;

 

import org.apache.beehive.controls.api.ControlException;

 

@ControlImplementation

public class EmployeeManagerImpl implements EmployeeManager

{ 

 

    @Control EmployeeDBControl employeeDB;

   

    Employee emp = null;

    Employee[] empArray = null;

 

            // default no-arg constructor

            public EmployeeManagerImpl(){}

 

   

    

            public String selectEmployee()

            {

                        

                        String sRetVal = "Something is wrong -- Returned
from selectEmployee in EmployeeManagerImpl";

                

                try

                {

             System.out.println("EmployeeManagerImpl: Attemping to call
employeeDB.selectEmployee( 100 ) ");

                    emp = employeeDB.selectEmployee( 100 );

             System.out.println("EmployeeManagerImpl: Fininshed calling
employeeDB.selectEmployee( 100 ) ");

                }

                catch( SQLException sqle )

                {

                    sRetVal = "SQLException caught: " + sqle.getMessage();

                }

                catch(ControlException ce )

         {

              sRetVal = "ControlException caught: " + ce.getMessage();

         }

                catch( Exception e )

                {

                    sRetVal = "Exception caught: " + e.getMessage();

                }

                        

                        if ( null != emp )

                        {

                            sRetVal = emp.toString();

                        System.out.println("sRetVal contains data: " +
sRetVal );                  

                        }

                        

                        return sRetVal;

            }

}

 

EmployeeDBControl.jcx

 

package controls.employee;

 

import java.sql.SQLException;

import java.sql.ResultSet;

 

import java.io.Serializable;

 

import java.util.Iterator;

import java.util.HashMap;

 

import org.apache.beehive.controls.api.bean.ControlExtension;

 

import org.controlhaus.jdbc.*;

 

 

//public interface EmployeeDBControl extends DatabaseControl

 

@org.apache.beehive.controls.api.bean.ControlExtension

@JdbcControl.ConnectionDataSource(jndiName="java:comp/env/jdbc/EventTracker"
)

public interface EmployeeDBControl extends JdbcControl

{

     

    @SQL(statement="SELECT employee_id, first_name, last_name FROM EMPLOYEE
WHERE employee_id={i}")

    public Employee selectEmployee( int i ) throws SQLException;

    

    //

    // get all rows from the EMPLOYEE table, returned as a
java.sql.ResultSet 

    //

    @SQL(statement="SELECT * FROM EMPLOYEE")

    public Employee[] getAllEmployees() throws SQLException;    

    

}