JNDI e EJB

4 respostas
robson_vs

alguem sabe q erro é este e o q devo fazer para corrigi-lo?

Executando o metodo incluirFuncionario da classe class br.com.greenline.falegreen.managedbean.FuncionarioBean resultado: 06/09/2006 12:08:37 org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet Faces Servlet threw exception javax.faces.FacesException: Error calling action method of component with id _idJsp3:gravarFuncionario at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74) at javax.faces.component.UICommand.broadcast(UICommand.java:106) at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168) at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343) at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684) at java.lang.Thread.run(Thread.java:595) Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{FuncionarioBean.incluirFuncionarios} at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153) at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63) ... 23 more Caused by: java.lang.SecurityException: Unable to locate a login configuration at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:97) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) at java.lang.reflect.Constructor.newInstance(Constructor.java:494) at java.lang.Class.newInstance0(Class.java:350) at java.lang.Class.newInstance(Class.java:303) at javax.security.auth.login.Configuration$3.run(Configuration.java:216) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.Configuration.getConfiguration(Configuration.java:210) at javax.security.auth.login.LoginContext$1.run(LoginContext.java:237) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.login.LoginContext.init(LoginContext.java:234) at javax.security.auth.login.LoginContext.<init>(LoginContext.java:403) at org.jboss.security.jndi.LoginInitialContextFactory.getInitialContext(LoginInitialContextFactory.java:84) at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) at javax.naming.InitialContext.init(InitialContext.java:223) at javax.naming.InitialContext.<init>(InitialContext.java:197) at br.com.greenline.falegreen.interfaces.FuncionarioUtil.lookupHome(FuncionarioUtil.java:18) at br.com.greenline.falegreen.interfaces.FuncionarioUtil.getHome(FuncionarioUtil.java:49) at br.com.greenline.falegreen.delegate.FuncionarioDelegate.<init>(FuncionarioDelegate.java:23) at br.com.greenline.falegreen.managedbean.FuncionarioBean.incluirFuncionarios(FuncionarioBean.java:23) 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.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129) ... 24 more Caused by: java.io.IOException: Unable to locate a login configuration at com.sun.security.auth.login.ConfigFile.init(ConfigFile.java:206) at com.sun.security.auth.login.ConfigFile.<init>(ConfigFile.java:95) ... 51 more

4 Respostas

A

Cara, mostra o que você está fazendo aí… pode ajudar a descobrir o erro…

Abraço,

Armando

robson_vs

então cara eu estou acionando um evento de gravar na minha aplicação estou usando tomcat p/ a parte de jsf, jboss p/ ejb tenho minhas classes de teste no junit ta rolando mais quando vou chamalas pelo delegate dá este erro.

anexo segue o meu código funcionario 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.util.servicelocator.ICParams;
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);
		}
	}

	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);
		}
	}
}
cadastro jsf
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
		<title></title>
	</head>
	<body>
		<div style="position: absolute;left: 10;top: 10;width: 800;height: 40;">
			<jsp:include page="header.jspf"/>
		</div>

		<f:view>
			<f:loadBundle basename="messages" var="msgs"/>
			
			<t:panelTabbedPane style="position: absolute; left:10;top:100;width: 800;height:300;">
			
				<t:panelTab label="#{msgs.tituloCadastroFuncionario}">
					<t:panelGrid cellpadding="50" cellspacing="50">
						<h:form>
							<h:outputText style="position: absolute;left: 100;top: 200;width: 200;height: 20;color:#557755;font-size:12px;padding-left:4px;padding-top:4px;" value="#{msgs.textoFuncionario}"/>
							<h:inputText style="position: absolute;left: 200;top: 200;width: 200;height: 20;" required="true" tabindex="1" styleClass="inputText" id="funcionario" value="#{FuncionarioBean.funcionarioVO.nome}" />	
							<h:message style="position: absolute;left: 400;top: 200;width: 300;height: 20;color: #EDAA9B;font-size: 12px;padding-left: 4px;padding-top: 4px;" for="funcionario" styleClass="error"/>
							
							<h:outputText style="position: absolute;left: 100;top: 230;width: 200;height: 20;color:#557755;font-size:12px;padding-left:4px;padding-top:4px;" value="#{msgs.textoEmail}"/>
							<h:inputText style="position: absolute;left: 200;top: 230;width: 200;height: 20;" required="true" tabindex="2" styleClass="inputText" id="email" value="#{FuncionarioBean.funcionarioVO.email}" />
							<h:message style="position: absolute;left: 400;top: 230;width: 300;height: 20;color: #EDAA9B;font-size: 12px;padding-left: 4px;padding-top: 4px;" for="email" styleClass="error"/>
							
							<h:commandButton style="position: absolute;left: 200;top: 260;width: 150;height: 20;" tabindex="3" id="gravarFuncionario" value="#{msgs.botaoSalvar}" action="#{FuncionarioBean.incluirFuncionarios}" />
							<h:message style="position: absolute;left: 400;top: 260;width: 200;height: 20;color: #EDAA9B;font-size: 12px;padding-left: 4px;padding-top: 4px;" for="gravarFuncionario" styleClass="error"/>
						</h:form>
					</t:panelGrid>
				</t:panelTab>
				
				<t:panelTab label="#{msgs.tituloCadastroDepartamento}">
					<t:panelGrid cellpadding="50" cellspacing="50">
					<h:form>
						<h:outputText style="position: absolute;left: 100;top: 200;width: 200;height: 20;color:#557755;font-size: 12px;padding-left: 4px;padding-top: 4px;" value="#{msgs.textoDepartamento}"/>
						<h:inputText style="position: absolute;left: 200;top: 200;width: 200;height: 20;" required="true" tabindex="1" id="departamento" value="#{DepartamentoBean.departamento.nome}" />
						<h:message style="position: absolute;left: 400;top: 200;width: 200;height: 20;color:#EDAA9B;font-size: 12px;padding-left: 4px;padding-top: 4px;" for="departamento"/>
						
						<h:outputText style="position: absolute;left: 100;top: 230;width: 150;height: 20;color: #557755;font-size: 12px;padding-left: 4px;padding-top: 4px;" value="#{msgs.textoFuncionario}"/>

						<t:selectOneMenu style="position: absolute;left: 200;top: 230;width: 200;height: 20;" required="true" tabindex="2" id="funcionario" >
<%--						
							<f:selectItems value="#{DepartamentoBean.departamento.funcionario}" />
--%>
	 					</t:selectOneMenu>
						<h:message style="position: absolute;left: 400;top: 230;width: 230;height: 20;color: #EDAA9B;font-size: 12px;padding-left: 4px;padding-top: 4px;" for="funcionario"/>

						<h:commandButton style="position: absolute;left: 200;top: 260;width: 150;height: 20;" id="gravarDepartamento" value="#{msgs.botaoSalvar}" action="valor" tabindex="3" />
						<h:message style="position: absolute;left: 400;top: 260;width: 230;height: 20;color: #EDAA9B;font-size: 12px;padding-left: 4px;padding-top: 4px;" for="gravarDepartamento" styleClass="error"/>
					</h:form>
					</t:panelGrid>
				</t:panelTab>
				
			</t:panelTabbedPane>
		</f:view>
		
		<div align="center" style="position: absolute;left: 10;top: 400;width: 800;height: 55;">
			<jsp:include page="footer.jspf"/>
		</div>		
	</body>
</html>
funcionario bean
package br.com.greenline.falegreen.managedbean;

import java.util.List;

import javax.faces.component.UIParameter;
import javax.faces.event.ActionEvent;

import br.com.greenline.falegreen.delegate.FuncionarioDelegate;
import br.com.greenline.falegreen.model.Funcionario;

public class FuncionarioBean {

	private Funcionario funcionarioVO = new Funcionario();

	public void incluirFuncionarios() {

		String action = null;
		System.out.println("Executando o metodo incluirFuncionario da classe "
				+ FuncionarioBean.class + " resultado: ");

		if (action == null) {

			FuncionarioDelegate funcionarioDelegate = new FuncionarioDelegate();
			funcionarioDelegate.salvar(funcionarioVO);

			action = "success";

			System.out.print("OK - " + funcionarioVO.getNome());
			System.out.println(action);

			funcionarioVO = new Funcionario();

			action = "success";
		} else {
			action = "failure";
			System.out.println("Error");
			System.out.println(action);
		}
	}

	@SuppressWarnings("unchecked")
	public List<Funcionario> getFuncionarios() {

		FuncionarioDelegate funcionarioDelegate = new FuncionarioDelegate();
		return funcionarioDelegate.listar();
	}

	public void escolheFuncionario(ActionEvent event) {
		UIParameter valor = (UIParameter) event.getComponent().findComponent(
				"editId");
		Long id = Long.valueOf(valor.getValue().toString());

		FuncionarioDelegate funcionarioDelegate = new FuncionarioDelegate();
		// this.funcionarioVO = funcionarioDelegate.listar(id);
	}

	public Funcionario getFuncionarioVO() {
		return funcionarioVO;
	}

	public void setFuncionarioVO(Funcionario funcionarioVO) {
		this.funcionarioVO = funcionarioVO;
	}
}

e o arquivo auth.confg mais onde eu coloco ele se ja coloquei no web.xml no lib no web-inf no src e nada que devo fazer???

A

O erro está na FuncionarioUtil…
na hora de fazer o lookup… aparentemente você está tentando obter um DataSource para alguma coisa que requer autenticação, mas os parâmetros de autenticação não estão configurados. Verifique.

Abraço,

Armando

robson_vs

mais pq funciona com junit?

Criado 6 de setembro de 2006
Ultima resposta 8 de set. de 2006
Respostas 4
Participantes 2