Ejb 3 in Jboss 5 Beta 3
ragavgomatam Dec 23, 2007 10:11 AMHi,
I have ejb3 deployed & working in jboss 4.2.1. The same EAR when dropped into jboss 5 Beta 3\default\deploy has problems. Let me elaborate.
I have ejb's . (1) SayHelloBean & (2) Calculator Bean. BOTH WORK IN jboss 4.2.1 and BOTH ARE EJB 3's.
Code
package com.ejb3.interfaces; import java.sql.SQLException; import javax.ejb.Local; @Local public interface SayHello { public String sayHelloWithEjb3DI() throws SQLException;
}
Bean
package com.ejb3.beans; import static javax.ejb.TransactionAttributeType.REQUIRED; import javax.ejb.Stateful; import javax.ejb.TransactionAttribute; import javax.ejb.EJB; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.interceptor.ExcludeDefaultInterceptors; import javax.sql.DataSource; import javax.annotation.PreDestroy; import org.springframework.jdbc.core.simple.SimpleJdbcDaoSupport; import org.jboss.annotation.spring.Spring; import com.ejb3.domain.IPerson; import com.ejb3.interfaces.Calculator; import com.ejb3.interfaces.SayHello; @Stateful @TransactionAttribute(REQUIRED) @ExcludeDefaultInterceptors public class SayHelloBean extends SimpleJdbcDaoSupport implements SayHello { @Resource(name = "jdbc/TestDs", type = DataSource.class, shareable = true, mappedName = "java:jdbc/OracleDS") private DataSource ds; @EJB(beanName = "CalculatorBean") private Calculator calculator; @Resource(name = "sqlForEjb") private String sql; public String sayHelloWithEjb3DI() { return "Testing ejb3 DI & your age is " + getSimpleJdbcTemplate().queryForInt(sql); } public double calulate() { return calculator.calculate(2, 3); } @PostConstruct public void init() { setDataSource(ds); } @PreDestroy public void callThis() { System.out.println("Invoking method: preDestroy()"); } }
BEAN 2
package com.ejb3.interfaces; import javax.ejb.Local; @Local public interface Calculator { public double calculate(int i, int j); }
package com.ejb3.beans; import static javax.ejb.TransactionAttributeType.REQUIRED; import javax.ejb.Stateless; import javax.ejb.TransactionAttribute; import javax.interceptor.ExcludeDefaultInterceptors; import com.ejb3.interfaces.Calculator; @Stateless @TransactionAttribute(REQUIRED) @ExcludeDefaultInterceptors public class CalculatorBean implements Calculator { public double calculate(int i, int j) { return i + j; } }
This was deployed in an EAR file with spring looking up the ejb as follows :-
<bean name="/home" class="com.ejb3.action.SpringEjb3Action" autowire="byName"> <property name="sayhello" ref="ejbLocalIntf"></property> </bean> <!-- Jboss 4.2 look up of ejb3 --> <jee:jndi-lookup id="ejbLocalIntf" jndi-name="Ejb3/SayHelloBean/local" /> </beans>
This works perfectly in jboss 4.2.1 but in jboss 5 beta 3 I get the following deployment error :-
org.jboss.deployers.spi.DeploymentException: Error deploying Ejb3.jar: Error creating ejb container CalculatorBean: java.lang.RuntimeException: Unable to load class for annotation org.jboss.annotation.ejb.PoolClass using class loader org.jboss.mx.loading.UnifiedClassLoader3@b8ec9b{ url=vfsfile:/C:/jboss-5.0.0.Beta3/server/default/deploy/Ejb3.ear ,addedOrder=21}
Also in the jmx-console under jndiView, I see the ejb's not bound.
java:comp namespace of the component jboss.j2ee:ear=Ejb3.ear,jar=Ejb3.jar,name=CalculatorBean,service=EJB3 : +- ORB[link -> java:/JBossCorbaORB] (class: javax.naming.LinkRef) +- EJBContext (class: javax.ejb.EJBContext) +- env (class: org.jnp.interfaces.NamingContext)
I don't see the ejb's bound under GLOBAL JNDI Namespace either.
Any suggestions/ideas ?