Problems while trying to get Home interface
alexandre_correa Jul 26, 2005 6:14 PMHi guys,
I'm trying to make my first EJB work. I have no problems to deploy the ear file, and I'm able to put my web application working. But when I try to make my EJB work, it gets the following error:
18:43:04,902 INFO [STDOUT] java.lang.ClassCastException 18:43:04,903 INFO [STDOUT] at com.sun.corba.se.impl.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:229) 18:43:04,903 INFO [STDOUT] at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137) 18:43:04,904 INFO [STDOUT] at alellyx.clustering.deploy.impl.OrganismClient.<init>(OrganismClient.java:36) 18:43:04,904 INFO [STDOUT] at alellyx.clustering.presentation.impl.OrganismModel.saveOrganism(OrganismModel.java:33) 18:43:04,905 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
My configuration files are the following:
application.xml
<?xml version="1.0" encoding="UTF-8"?> <application version="1.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/application_1_4.xsd"> <description> Configuracao do novo sistema de clustering </description> <display-name>clusteringSystem</display-name> <module> <ejb>newClustering.jar</ejb> </module> <module> <web> <web-uri>newClustering.war</web-uri> <context-root>/newClustering</context-root> </web> </module> </application>
ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?> <ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"> <enterprise-beans> <session> <ejb-name>Organism</ejb-name> <home>alellyx.clustering.deploy.impl.OrganismHome</home> <remote>alellyx.clustering.deploy.impl.Organism</remote> <ejb-class>alellyx.clustering.deploy.impl.OrganismBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> </ejb-jar>
web.xml
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" version="2.4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>Sistema de Clustering da Alellyx</display-name> <!-- Recurso a ser procurado quando acessando um diretorio --> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <!-- Configurando uso de Java Server Faces --> <servlet> <display-name>FacesServlet</display-name> <servlet-name>FacesServlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>FacesServlet</servlet-name> <url-pattern>/newClustering/*</url-pattern> </servlet-mapping> <!-- Adicionando listeners --> <listener> <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> <!-- Mapeando taglibs --> <taglib> <taglib-uri>http://java.sun.com/jsf/html</taglib-uri> <taglib-location>/WEB-INF/lib/tld/html_basic.tld</taglib-location> </taglib> <taglib> <taglib-uri>http://java.sun.com/jsf/core</taglib-uri> <taglib-location>/WEB-INF/lib/tld/jsf_core.tld</taglib-location> </taglib> </web-app>
And the way I'm trying to get the home interface is:
Context initial = new InitialContext(); Object objRef = initial.lookup("Organism"); objRef = PortableRemoteObject.narrow(objRef, OrganismHome.class); OrganismHome home = (OrganismHome) objRef; organismController = home.create();
Someone have some idea of why this is happening? I appreciate any help.
I'm using JBoss 4.0.2.
Thanks,
Alexandre