So I am in the process of testing out MyEclipse IDE 5.1, and thus far I like it a lot. One thing that is messing me up though is the fact that I cannot connect to an EJB anymore. I copied the code from my IDE workspace 4.1 to my workspace in 5.1. Everything works in 4.1 when I deploy it, but does not in 5.1.
The error I am getting is “java.lang.ClassCastException: $Proxy51”. I have the following method returning a connection to the EJB.
public ApplicationSecurity getApplicaitonSecurityEJBConnection() {
try {
InitialContext jndiContext1 = new InitialContext();
Object ref1 = jndiContext1.lookup("ApplicationSecurity");
ApplicationSecurityHome asHome = (ApplicationSecurityHome) javax.rmi.PortableRemoteObject.narrow(ref1, ApplicationSecurityHome.class);
ApplicationSecurity asEJB = asHome.create();
return asEJB;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
I have an ejb-jar.xml in the EJB Meta-INF workspace as well as a Jboss.xml. They are as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar id="ejb-jar_ID">
<display-name>ApplicationSecurityEJB</display-name>
<enterprise-beans>
<session id="ApplicationSecurity">
<ejb-name>ApplicationSecurity</ejb-name>
<home>com.bozzutos.common.security.ejb.ApplicationSecurityHome</home>
<remote>com.bozzutos.common.security.ejb.ApplicationSecurity</remote>
<ejb-class>com.bozzutos.common.security.ejb.ApplicationSecurityBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 3.2//EN"
"http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
<jboss>
<enterprise-beans>
<message-driven>
<ejb-name>ApplicationSecurity</ejb-name>
<destination-jndi-name>ejb/ApplicationSecurity</destination-jndi-name>
</message-driven>
</enterprise-beans>
</jboss>
Any thoughts?