Estou desenvolvendo uma aplicação es estou com o seguinte problema referente a jndi
será q alguem consegue me ajudar :?:
Estou desenvolvendo uma aplicação es estou com o seguinte problema referente a jndi
será q alguem consegue me ajudar :?:
Coloca o código da sua classe aqui.
é o seguinte tenho um ejb
package br.com.greenline.falegreen.ejb;
import java.util.List;
import javax.ejb.SessionBean;
import org.apache.log4j.Logger;
import br.com.greenline.falegreen.dao.DAOFactory;
import br.com.greenline.falegreen.dao.FuncionarioDAO;
import br.com.greenline.falegreen.model.Funcionario;
/**
* @ejb.bean
* name="Funcionario"
* jndi-name="fg/Funcionario"
* type="Stateless"
* view-type="remote"
*
* @ejb.permission role-name = "sys"
*
* @ejb.util generate = "physical"
*
* @jboss.container-configuration name = "SSL Clustered Stateless SessionBean"
*
* @jboss.clustered cluster = "true"
*
* @jboss.cluster-config partition-name = "Greenline" bean-policy =
* "org.jboss.ha.framework.interfaces.RoundRobin"
* home-policy =
* "org.jboss.ha.framework.interfaces.RoundRobin"
*
* @author Robson Vieira da Silva
*/
public abstract class FuncionarioEJB implements SessionBean {
private static Logger log = Logger.getLogger(FuncionarioEJB.class);
// private Funcionario funcionario = new Funcionario();
/**
* @ejb.interface-method
* @return
*/
public List listar() {
if (log.isDebugEnabled()) {
log.debug("FuncionarioEJB.lista()");
}
DAOFactory factory = (DAOFactory) DAOFactory
.getDAOFactory(DAOFactory.HIBERNATE);
FuncionarioDAO dao = (FuncionarioDAO) factory.getFuncionarioDAO();
return dao.listar();
}
/**
* @ejb.interface-method
* @param funcionario
* @return
*/
public void salvar(Funcionario funcionario) {
if (log.isDebugEnabled()) {
log.debug("FuncionarioEJB.salva()");
}
DAOFactory factory = (DAOFactory) DAOFactory
.getDAOFactory(DAOFactory.HIBERNATE);
FuncionarioDAO dao = (FuncionarioDAO) factory.getFuncionarioDAO();
dao.salvar(funcionario);
}
/**
* @ejb.interface-method
* @param funcionario
* @return
*/
public void excluir(Funcionario funcionario) {
if (log.isDebugEnabled()) {
log.debug("Funcionario.detelte()");
}
DAOFactory factory = (DAOFactory) DAOFactory
.getDAOFactory(DAOFactory.HIBERNATE);
FuncionarioDAO dao = (FuncionarioDAO) factory.getFuncionarioDAO();
dao.excluir(funcionario);
}
}
um delegate
package br.com.greenline.falegreen.delegate;
import java.rmi.RemoteException;
import java.util.List;
import javax.ejb.CreateException;
import javax.naming.NamingException;
import br.com.greenline.falegreen.interfaces.Funcionario;
import br.com.greenline.falegreen.interfaces.FuncionarioUtil;
import br.com.greenline.falegreen.servicelocator.ICParams;
/**
* @author Robson Vieira da Silva
*/
public class FuncionarioDelegate {
private Funcionario ejb;
public FuncionarioDelegate() {
try {
ejb = FuncionarioUtil.getHome(ICParams.getParams()).create();
} catch (RemoteException e) {
throw new RuntimeException(e);
} catch (CreateException e) {
throw new RuntimeException(e);
} catch (NamingException e) {
throw new RuntimeException(e);
//e.printStackTrace();
}
}
public void salvar(br.com.greenline.falegreen.model.Funcionario funcionario) {
try {
ejb.salvar(funcionario);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
public List listar() {
try {
return ejb.listar();
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
public void excluir(br.com.greenline.falegreen.model.Funcionario funcionario) {
try {
ejb.excluir(funcionario);
} catch (RemoteException e) {
throw new RuntimeException(e);
}
}
}
e o teste
package br.com.greenline.falegreen.junit;
import java.util.List;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import br.com.greenline.falegreen.delegate.FuncionarioDelegate;
import br.com.greenline.falegreen.model.Funcionario;
/**
* @author Robson Vieira da Silva
*/
public class FuncionarioEJBTest extends TestCase {
// Mensagens gerais
private static final String TESTE_OK = "O TESTE REALIZADO COM SUCESSO!!!";
private static final String TESTE_ERRO = "O TESTE NÃO FOI REALIZADO COM SUCESSO!!!";
private static FuncionarioDelegate funcionarioDelegate;
private Funcionario funcionario;
// Dados para os testes.
private static final Long FUNCIONARIO_IDENTIFICADOR = new Long(1);
public FuncionarioEJBTest() {
super();
}
public FuncionarioEJBTest(String testeName) {
super(testeName);
}
public static Test suite() {
TestSuite suite = new TestSuite("Teste de Funcionario");
suite.addTest(new FuncionarioEJBTest("testeListar"));
return suite;
}
static {
funcionarioDelegate = new FuncionarioDelegate();
}
public void testeListar() {
try {
List funcionarios = funcionarioDelegate.listar();
assertNotNull(TESTE_OK + "Numero de Elementos: "
+ funcionarios.size());
} catch (Exception e) {
//throw new AssertionFailedError(TESTE_ERRO + e.getMessage());
//e.printStackTrace();
System.out.println(TESTE_ERRO);
}
}
}
ja empacotei fiz o deploy e tudo beleza mais na hora de executar o teste da o seguinte erro
log4j:WARN No appenders could be found for logger (org.jboss.security.SecurityAssociation).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.ExceptionInInitializerError
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:403)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: fg not bound
at br.com.greenline.falegreen.delegate.FuncionarioDelegate.<init>(FuncionarioDelegate.java:28)
at br.com.greenline.falegreen.junit.FuncionarioEJBTest.<clinit>(FuncionarioEJBTest.java:43)
... 8 more
Caused by: javax.naming.NameNotFoundException: fg not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
at org.jboss.ha.jndi.TreeHead.lookupLocally(TreeHead.java:296)
at org.jboss.ha.jndi.TreeHead.lookup(TreeHead.java:215)
at org.jboss.ha.jndi.HAJNDI.lookup(HAJNDI.java:155)
at sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.jboss.ha.framework.server.HARMIServerImpl.invoke(HARMIServerImpl.java:209)
at sun.reflect.GeneratedMethodAccessor104.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run(Thread.java:595)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
at org.jboss.ha.framework.server.HARMIServerImpl_Stub.invoke(Unknown Source)
at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClient.java:172)
at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:267)
at $Proxy0.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at br.com.greenline.falegreen.interfaces.FuncionarioUtil.lookupHome(FuncionarioUtil.java:20)
at br.com.greenline.falegreen.interfaces.FuncionarioUtil.getHome(FuncionarioUtil.java:49)
at br.com.greenline.falegreen.delegate.FuncionarioDelegate.<init>(FuncionarioDelegate.java:22)
... 9 more