• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems with ejb reference.....  RSS feed

 
Paulo Fernandes de Rezende
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in my servlet i can locate my session with :
(public static final String JNDI_NAME = "ejb/Funcionario_Session"

FuncionarioHome funcionarioHome = (FuncionarioHome)ServiceLocator.getLocator().getHome(FuncionarioHome.JNDI_NAME, FuncionarioHome.class);


but in my entity ,,,, when i try to find :
(public static final String JNDI_NAME = "ejb/Funcionario_Entity"
FuncionarioHome funcionarioHome = (FuncionarioHome) ServiceLocator.getLocator().getLocalHome(FuncionarioHome.JNDI_NAME);

this don't work !! in my console says::: Funcionario_Entity not bound.....
somebody help!!!
thanks a lot to everybody!!!

------------------------ejb - jar-------------------------

<ejb-jar>
<enterprise-beans>

<session>
<ejb-name>Funcionario_Session</ejb-name>
<home>br.com.funcionario.session.FuncionarioHome</home>
<remote>br.com.funcionario.session.Funcionario</remote>
<ejb-class>br.com.funcionario.session.FuncionarioBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
<ejb-local-ref>
<ejb-ref-name>ejb/Funcionario_Entity</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>br.com.funcionario.entity.FuncionarioHome</local-home>
<local>br.com.funcionario.entity.Funcionario</local>
<ejb-link>Funcionario_Entity</ejb-link>
</ejb-local-ref>
</session>

<entity>
<ejb-name>Funcionario_Entity</ejb-name>
<local-home>br.com.funcionario.entity.FuncionarioHome</local-home>
<local>br.com.funcionario.entity.Funcionario</local>
<ejb-class>br.com.funcionario.entity.FuncionarioEntity</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>Funcionario_Schema</abstract-schema-name>
<cmp-field>
<field-name>salario</field-name>
</cmp-field>
<cmp-field>
<field-name>nome</field-name>
</cmp-field>
<cmp-field>
<field-name>pk</field-name>
</cmp-field>
<primkey-field>pk</primkey-field>

</entity>

</enterprise-beans>
</ejb-jar>

------------------jboss.xml---------------------------

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd">

<jboss>

<enterprise-beans>

<session>
<ejb-name>Funcionario_Session</ejb-name>
<jndi-name>ejb/Funcionario_Session</jndi-name>
</session>


<entity>
<ejb-name>Funcionario_Entity</ejb-name>
<jndi-name>ejb/Funcionario_Entity</jndi-name>
</entity>

</enterprise-beans>
<resource-managers>
</resource-managers>

</jboss>

----------------------------servicelocator-------------------
public class ServiceLocator {

private static ServiceLocator locator = new ServiceLocator();

public static ServiceLocator getLocator() {
return locator;
}


public EJBHome getHome(String jndi, Class c) throws Exception {
Context context = new InitialContext();
EJBHome home = (EJBHome)PortableRemoteObject.narrow(context.lookup(jndi), c);
return home;
}


public EJBLocalHome getLocalHome(String jndi) throws Exception {Context context = new InitialContext();
EJBLocalHome localHome = (EJBLocalHome)context.lookup(jndi);
return localHome;
}

}
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!