Hi,
I am trying to inject instance of class "SaveCardInfoDAO" into ejb method "insertCardInfo". Following are the code snippets.
Controller (Stateless session bean) in Project 1
Code:
/**
* Exposed Message to insert the Credit Card Info into the database. 
*/
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void insertCardInfo(CreditCardDO ccdo){
SaveCardInfoDAO saveCardInfo = (SaveCardInfoDAO) ApplicationUtil.getSpringContext().getBean("saveCardInfo");
//SaveCardInfoDAO saveCardInfo = new SaveCardInfoDAO(ccsDataSource);
try{
saveCardInfo.openConnection(false);
saveCardInfo.insertCardInfo(ccdo);
System.out.println("Insert Success !!!");
}
catch(SQLException e){
ejbContext.setRollbackOnly();
System.out.println("Insert Failure !!!");
}
finally{
saveCardInfo.closeConnection();
}
}
ApplicationUtil class (that initializes the Application context) required in above code is in Project 2.

Code:
public class ApplicationUtil {
private static final ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
static{
init();
}

public static void init(){
DOMConfigurator.configure("resource/ccslogger.xml");
}
public static ApplicationContext getSpringContext(){
return context;
}
}
applicationContext.xml is in Project2

Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

<aop:aspectj-autoproxy />
<bean id="creditCardAdvice" class="com.fedex.ccs.advice.CCSCreditCardInfoAdvice" />
<bean id="saveCardInfo" class="com.fedex.ccs.dao.SaveCardInfoDAO" /> 
<bean id="creditCardDO" class="com.fedex.ccs.domain.CreditCardDO" />

</beans>
SaveCardInfoDAO class whose instance is to be inserted in the first code snippet is in Project 3.

Code:
public class SaveCardInfoDAO extends CCSBaseDAO {
private PreparedStatement stmt;
public void setPreparedStatement() throws SQLException{
stmt=getConnection().prepareStatement(SQLQueriesBase.CCS_Credit_Card_Info.INSERT_CREDIT_CARD_INFO);
}
public PreparedStatement getPreparedStatement(){
return stmt;
}
public SaveCardInfoDAO(){
}
public SaveCardInfoDAO(DataSource ccsDataSource){
super(ccsDataSource);
}
/**
* Insert credit card information into the database table.
* @param ccdo
* @throws SQLException
*/
public int insertCardInfo(CreditCardDO ccdo)throws SQLException{
setPreparedStatement();
stmt.setObject(1, ccdo.getCreditCardType(), Types.VARCHAR);
stmt.setObject(2, ccdo.getCreditCardID(), Types.VARCHAR);
stmt.setObject(3, ccdo.getCreditCardBIN(), Types.VARCHAR);
stmt.setObject(4, ccdo.getCreditCardExpDt(), Types.VARCHAR);
stmt.setObject(5, ccdo.getAccountNumber(), Types.VARCHAR);
int result = stmt.executeUpdate();
stmt.close();
return result;
}
}
Project 1 has dependency on project 2 and project 3.
Project 3 has dendency on Project 2.
I am using Eclipse and all these projects are eclipse projects.

When I run my client this gives me following error.
javax.ejb.EJBTransactionRolledbackException: EJB Exception: : java.lang.NoClassDefFoundError: com/fedex/ccs/util/ApplicationUtil
at com.fedex.ccs.ejb.session.Controller.insertCardInf o(Controller.java:44)

Please help me resolve this issue. Let me know if you need something else.

Regards
Damodar