Boa tarde Pessoal,
Estou com um problema que não consigo achar o erro de forma alguma, gostaria de pedir a ajuda de voces… Vou tentar explicar mais ou menos o meu cenário…
Tenho três projetos:
- IronmakingWS : nesse projeto estão os meus beans, segue abaixo o CastEventClienteBean. Esse bean faz referencia a um outro projeto chamado IronmakingWS-Base aonde esta a minha interface e as minhas classes de modelo que estão abaixo(CastingEvents, Message, Header, CastEventCliente).
Esses dois projetos estão publicados em uma instancia do jboss, esta carregando os beans direitinho, ate ai tudo bem.
CastEventClienteBean
package br.com.tkcsa.ironmaking.session;
import java.io.FileOutputStream;
import java.io.StringWriter;
import java.util.TimeZone;
import javax.ejb.Remote;
import javax.ejb.Stateful;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.transform.stream.StreamResult;
import com.sap.www.xMII.InputParams;
import com.sap.www.xMII.Row;
import com.sap.www.xMII.XacuteRequest;
import com.sap.www.xMII.XacuteResponse;
import com.sap.www.xMII.XacuteWSSoapStub;
import br.com.tkcsa.ironmaking.modelo.castingevents.Message;
import br.com.tkcsa.ironmaking.session.CastEventCliente;
import br.com.tkcsa.ironmaking.utilidade.SystemEnum;
@Stateful
@Remote(CastEventCliente.class)
public class CastEventClienteBean implements CastEventCliente {
public static final String NOMEARQUIVO = "castevent.xml";
public String enviar(Message message) {
try {
JAXBContext context = JAXBContext.newInstance(Message.class);
Marshaller marshaller = context.createMarshaller();
marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
marshaller.setProperty(Marshaller.JAXB_ENCODING, new String("UTF-8"));
java.util.Calendar calendar = java.util.Calendar.getInstance(TimeZone.getTimeZone("GMT-03:00"));
marshaller.marshal(message, new FileOutputStream("D:/temp/castevent/" + "castevent" + calendar.getTime().getTime() +".xml"));
//converte objeto para string
StringWriter stringWriter = new StringWriter();
StreamResult result = new StreamResult( stringWriter );
marshaller.marshal( message, result );
String content = stringWriter.toString();
InputParams inputParams = new InputParams();
inputParams.setEncapsulatedXML(content);
inputParams.setMessageType(message.getHeader().getMessageName());
inputParams.setIDSenderSystem(message.getHeader().getSourceSystem());
XacuteRequest request = new XacuteRequest();
request.setInputParams(inputParams);
request.setLoginName(SystemEnum.WebServiceEnum.USUARIO);
request.setLoginPassword(SystemEnum.WebServiceEnum.SENHA);
XacuteWSSoapStub soapStub = new XacuteWSSoapStub();
XacuteResponse response = soapStub.xacute(request);
Row[] rows = response.getRowset();
Row row = rows[0];
return row.getReturnMessage();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
CastingEvents
package br.com.tkcsa.ironmaking.modelo;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="CastingEvents")
@XmlAccessorType(XmlAccessType.FIELD)
public class CastingEvents implements Serializable
{
private static final long serialVersionUID = 6622886994422248153L;
@XmlElement(name="Equipment")
private String equipment;
@XmlElement(name="CastNumber")
private String castNumber;
@XmlElement(name="TapHoleNumber")
private int tapHoleNumber;
@XmlElement(name="EventDate")
private String eventDate;
@XmlElement(name="EventType")
private String eventType;
@XmlElement(name="LadleNumber")
private String ladleNumber;
@XmlElement(name="HotMetalTemperature")
private Double hotMetalTemperature;
@XmlElement(name="SlagRetentionTime")
private Double slagRetentionTime;
@XmlElement(name="SlagStartTime")
private String slagStartTime;
@XmlElement(name="SlagEndTime")
private String slagEndTime;
//gets e setters
public String getEquipment()
{
return equipment;
}
public void setEquipment(String equipment)
{
this.equipment = equipment;
}
public String getCastNumber()
{
return castNumber;
}
public void setCastNumber(String castNumber)
{
this.castNumber = castNumber;
}
public int getTapHoleNumber()
{
return tapHoleNumber;
}
public void setTapHoleNumber(int tapHoleNumber)
{
this.tapHoleNumber = tapHoleNumber;
}
public String getEventDate()
{
return eventDate;
}
public void setEventDate(String eventDate)
{
this.eventDate = eventDate;
}
public String getEventType()
{
return eventType;
}
public void setEventType(String eventType)
{
this.eventType = eventType;
}
public String getLadleNumber()
{
return ladleNumber;
}
public void setLadleNumber(String ladleNumber)
{
this.ladleNumber = ladleNumber;
}
public Double getHotMetalTemperature()
{
return hotMetalTemperature;
}
public void setHotMetalTemperature(Double hotMetalTemperature)
{
this.hotMetalTemperature = hotMetalTemperature;
}
public Double getSlagRetentionTime()
{
return slagRetentionTime;
}
public void setSlagRetentionTime(Double slagRetentionTime)
{
this.slagRetentionTime = slagRetentionTime;
}
public String getSlagStartTime()
{
return slagStartTime;
}
public void setSlagStartTime(String slagStartTime)
{
this.slagStartTime = slagStartTime;
}
public String getSlagEndTime()
{
return slagEndTime;
}
public void setSlagEndTime(String slagEndTime)
{
this.slagEndTime = slagEndTime;
}
}
Header
package br.com.tkcsa.ironmaking.modelo;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@Entity(name="Header")
@XmlRootElement(name="Header")
@XmlAccessorType(XmlAccessType.FIELD)
public class Header implements Serializable
{
private static final long serialVersionUID = 6622886994422248153L;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int codigo;
@XmlElement(name="MessageName")
private String messageName;
@XmlElement(name="MessageCounter")
private int messageCounter;
@XmlElement(name="MessageType")
private String messageType;
@XmlElement(name="SourceSystem")
private String sourceSystem;
@XmlElement(name="DestinationSystem")
private String destinationSystem;
@XmlElement(name="NeedsAck")
private String needsAck;
@XmlElement(name="CreationDateTime")
private String creationDateTime;
@XmlElement(name="LifeTime")
private int lifeTime;
@OneToOne(mappedBy="header", fetch=FetchType.LAZY, cascade=CascadeType.REMOVE)
private ProcessOrder processOrder;
@OneToOne(mappedBy="header", fetch=FetchType.LAZY, cascade=CascadeType.REMOVE)
private LabAnalysisResult labAnalysisResult;
@OneToOne(mappedBy="header", fetch=FetchType.LAZY, cascade=CascadeType.REMOVE)
private LadleWeighingReport ladleWeighingReport;
@OneToOne(mappedBy="header", fetch=FetchType.LAZY, cascade=CascadeType.REMOVE)
private InspectionLot inspectionLot;
//gets e setters
public String getMessageName()
{
return messageName;
}
public void setMessageName(String messageName)
{
this.messageName = messageName;
}
public int getMessageCounter()
{
return messageCounter;
}
public void setMessageCounter(int messageCounter)
{
this.messageCounter = messageCounter;
}
public String getMessageType()
{
return messageType;
}
public void setMessageType(String messageType)
{
this.messageType = messageType;
}
public String getSourceSystem()
{
return sourceSystem;
}
public void setSourceSystem(String sourceSystem)
{
this.sourceSystem = sourceSystem;
}
public String getDestinationSystem()
{
return destinationSystem;
}
public void setDestinationSystem(String destinationSystem)
{
this.destinationSystem = destinationSystem;
}
public String getNeedsAck()
{
return needsAck;
}
public void setNeedsAck(String needsAck)
{
this.needsAck = needsAck;
}
public String getCreationDateTime()
{
return creationDateTime;
}
public void setCreationDateTime(String creationDateTime)
{
this.creationDateTime = creationDateTime;
}
public int getLifeTime()
{
return lifeTime;
}
public void setLifeTime(int lifeTime)
{
this.lifeTime = lifeTime;
}
public int getCodigo()
{
return codigo;
}
public void setCodigo(int codigo)
{
this.codigo = codigo;
}
public ProcessOrder getProcessOrder() {
return processOrder;
}
public void setProcessOrder(ProcessOrder processOrder) {
this.processOrder = processOrder;
}
public LabAnalysisResult getLabAnalysisResult() {
return labAnalysisResult;
}
public void setLabAnalysisResult(LabAnalysisResult labAnalysisResult) {
this.labAnalysisResult = labAnalysisResult;
}
public LadleWeighingReport getLadleWeighingReport() {
return ladleWeighingReport;
}
public void setLadleWeighingReport(LadleWeighingReport ladleWeighingReport) {
this.ladleWeighingReport = ladleWeighingReport;
}
public InspectionLot getInspectionLot() {
return inspectionLot;
}
public void setInspectionLot(InspectionLot inspectionLot) {
this.inspectionLot = inspectionLot;
}
}
Message
package br.com.tkcsa.ironmaking.modelo.castingevents;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import br.com.tkcsa.ironmaking.modelo.CastingEvents;
import br.com.tkcsa.ironmaking.modelo.Header;
@XmlRootElement(name = "Message")
@XmlAccessorType(XmlAccessType.FIELD)
public class Message implements Serializable
{
private static final long serialVersionUID = 6622886994422248153L;
@XmlElement(name="Header")
private Header header;
@XmlElement(name = "Data")
private CastingEvents data;
//get e set
public Header getHeader()
{
return header;
}
public void setHeader(Header header)
{
this.header = header;
}
public CastingEvents getData()
{
return data;
}
public void setData(CastingEvents data)
{
this.data = data;
}
}
CastEventClient
package br.com.tkcsa.ironmaking.session;
import br.com.tkcsa.ironmaking.modelo.castingevents.Message;
public interface CastEventCliente {
String enviar(Message message);
}
- Minha aplicação WEB : A minha aplicação web vai enviar mensagens através desses beans criados, ela utiliza como referencia e link ao projeto IronmakingWS-Base. Desse projeto ela utiliza a interface e as classes de modelo, para enxergar os beans eu faço um lookup, segue servlet(CadastrarTratamentoPanela) aonde estou fazendo isso. Quando rodo essa aplicação pela minha maquina, funciona perfeitamente. Na minha maquina eu rodo ela através do tomcat e coloco as libs clients do jboss na pasta web-inf/lib o programa funciona perfeitamente, agora quando gero o war dessa aplicação e tento colocá-lo em uma outra instancia do jboss quando faço isso tiro as libs clients do jbos, ai ele da o seguinte problema:
Servlet CadastrarTratamentoPanela
package servlet;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import br.com.tkcsa.ironmaking.modelo.CastingEvents;
import br.com.tkcsa.ironmaking.modelo.Header;
import br.com.tkcsa.ironmaking.modelo.castingevents.Message;
import br.com.tkcsa.ironmaking.session.CastEventCliente;
import persistencia.Dao;
import persistencia.DaoCorrida;
import persistencia.DaoLogin;
import persistencia.DaoTemperatura;
import persistencia.DaoTurno;
import persistencia.HibernateUtil;
import util.Util;
import modelo.Corrida;
import modelo.CorridaPanela;
import modelo.Equipe;
import modelo.Usuario;
public class CadastrarTratamentoPanela extends HttpServlet {
private static final long serialVersionUID = 1L;
private CastEventCliente castEvent;
public void init()
{
try
{
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.provider.url","jnp://10.110.102.105:1199");
InitialContext initialContext = new InitialContext(props);
castEvent = (CastEventCliente)initialContext.lookup("CastEventClienteBean/remote");
System.out.println("instanciou");
}catch (NamingException ne)
{
throw new RuntimeException(ne);
}
}
public CadastrarTratamentoPanela() {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String codigo = request.getParameter("txtCodigo");
try {
Dao<Corrida> daoCorrida = new Dao<Corrida>(Corrida.class, HibernateUtil.getSession());
Corrida corrida1 = daoCorrida.consultar(Integer.parseInt(request.getParameter("txtCodigo"));
int hora = Integer.parseInt(corrida1.getHoraInicioGusa().substring(0,2));
int minuto = Integer.parseInt(corrida1.getHoraInicioGusa().substring(3,5));
int hora1 = Integer.parseInt(request.getParameter("txtDataHoraInicio".substring(11,13));
int minuto1 = Integer.parseInt(request.getParameter("txtDataHoraInicio".substring(14,16));
if (Util.converter(request.getParameter("txtDataHoraInicio".substring(0,10)).compareTo(corrida1.getDataInicioGusa())>=0) {
if ((Util.converter(request.getParameter("txtDataHoraInicio".substring(0,10)).compareTo(corrida1.getDataInicioGusa())>0) || ((Util.converter(request.getParameter("txtDataHoraInicio".substring(0,10)).compareTo(corrida1.getDataInicioGusa())==0) && (hora1>hora || (hora1==hora && minuto1>=minuto)))){
CorridaPanela corridaPanela = new CorridaPanela();
corridaPanela.setBica(request.getParameter("slcBica");
corridaPanela.setDataInicio(Util.converter(request.getParameter("txtDataHoraInicio".substring(0,10)));
corridaPanela.setHoraInicio(request.getParameter("txtDataHoraInicio".substring(11,16));
//Turno Atual
DaoTurno daoTurno = new DaoTurno(HibernateUtil.getSession());
corridaPanela.setTurno(daoTurno.consultarTurno(request.getParameter("txtTurno"));
//Usuário Logado
DaoLogin daoUsuario = new DaoLogin(HibernateUtil.getSession());
Usuario usuario = daoUsuario.read(request.getParameter("txtUsuario");
corridaPanela.setUsuario(usuario);
Dao<Equipe> daoEquipe = new Dao<Equipe>(Equipe.class, HibernateUtil.getSession());
corridaPanela.setEquipe(daoEquipe.consultar(Integer.parseInt(request.getParameter("slcEquipe"))));
corridaPanela.setPanela(Integer.parseInt(request.getParameter("txtPanela")));
//Corrida
corridaPanela.setCorrida(daoCorrida.consultar(Integer.parseInt(request.getParameter("txtCodigo"))));
Dao<CorridaPanela> daoCorridaPanela = new Dao<CorridaPanela>(CorridaPanela.class, HibernateUtil.getSession());
daoCorridaPanela.cadastrar(corridaPanela);
//Mes
Message message = new Message();
Header header = new Header();
CastingEvents casting = new CastingEvents();
//DataAtual
String dia = request.getParameter("txtDataHoraInicio").substring(0,2);
String mes = request.getParameter("txtDataHoraInicio").substring(3,5);
String ano = request.getParameter("txtDataHoraInicio").substring(6,10);
String horaEscoria = request.getParameter("txtDataHoraInicio").substring(11,16);
String data = ano+"-"+mes+"-"+dia;
//Header
header.setMessageName("INT_fromBF_toMES_CastEvent");
header.setMessageType("DATA");
header.setSourceSystem("BF2");
header.setDestinationSystem("MES");
header.setNeedsAck("N");
String dataAtual=data+"T"+horaEscoria+":00.29-03:00";
header.setCreationDateTime(dataAtual);
header.setLifeTime(0);
//CastingEvents
casting.setEquipment("BF2");
casting.setCastNumber(String.valueOf(corridaPanela.getCorrida().getCodigo()));
casting.setTapHoleNumber(corridaPanela.getCorrida().getFuroGusa());
casting.setEventDate(dataAtual);
casting.setEventType("LADLE_START");
casting.setLadleNumber(String.valueOf(corridaPanela.getPanela()));
//Data
SimpleDateFormat formata4 = new SimpleDateFormat("yyyy-MM-dd");
String dataInicioEscoria = formata4.format(corridaPanela.getCorrida().getDataInicioEscoria());
//String dataTerminoEscoria = formata4.format(corridaPanela.getCorrida().getDataTerminoEscoria());
String SlagStartTime=dataInicioEscoria+"T"+corridaPanela.getCorrida().getHoraInicioEscoria()+":00.29-03:00";
casting.setSlagStartTime(SlagStartTime);
//String SlagEndTime=dataTerminoEscoria+"T"+corridaPanela.getCorrida().getHoraTerminoEscoria()+":00.29-03:00";
casting.setSlagEndTime("");
DaoTemperatura daoTemperatura = new DaoTemperatura(HibernateUtil.getSession());
casting.setHotMetalTemperature(Double.valueOf(daoTemperatura.consultarTemperaturaMedia(corridaPanela.getCorrida())));
DaoCorrida daoCorrida1 = new DaoCorrida(HibernateUtil.getSession());
casting.setSlagRetentionTime(daoCorrida1.retencaoEscoria(corridaPanela.getCorrida()));
//Message
message.setHeader(header);
message.setData(casting);
String resposta = castEvent.enviar(message);
System.out.println(resposta);
//--Fim Mensagem com o MES--
request.getSession().setAttribute("slcBica", null);
request.getSession().setAttribute("slcEquipe", null);
request.getSession().setAttribute("txtPanela", null);
request.getSession().setAttribute("txtDataHoraInicio", null);
response.sendRedirect("Corrida/TratamentoPanela.jsp?msg=Inclusão efetuada com sucesso!&codigo="+codigo+"");
} else {
request.getSession().setAttribute("slcBica", request.getParameter("slcBica"));
request.getSession().setAttribute("slcEquipe", request.getParameter("slcEquipe"));
request.getSession().setAttribute("txtPanela", request.getParameter("txtPanela"));
request.getSession().setAttribute("txtDataHoraInicio", request.getParameter("txtDataHoraInicio"));
response.sendRedirect("Corrida/TratamentoPanela.jsp?msg=Hora Início deve ser maior ou igual a Hora Início Corrida!&codigo="+codigo+"");
}
} else {
request.getSession().setAttribute("slcBica", request.getParameter("slcBica"));
request.getSession().setAttribute("slcEquipe", request.getParameter("slcEquipe"));
request.getSession().setAttribute("txtPanela", request.getParameter("txtPanela"));
request.getSession().setAttribute("txtDataHoraInicio", request.getParameter("txtDataHoraInicio"));
response.sendRedirect("Corrida/TratamentoPanela.jsp?msg=Data Início deve ser maior ou igual a Data Início Corrida!&codigo="+codigo+"");
}
} catch (Exception error) {
request.getSession().setAttribute("slcBica", request.getParameter("slcBica"));
request.getSession().setAttribute("slcEquipe", request.getParameter("slcEquipe"));
request.getSession().setAttribute("txtPanela", request.getParameter("txtPanela"));
request.getSession().setAttribute("txtDataHoraInicio", request.getParameter("txtDataHoraInicio"));
response.sendRedirect("Corrida/TratamentoPanela.jsp?msg=Inclusão não efetuada!&codigo="+codigo+"");
}
}
}
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet CadastrarTratamentoPanela threw exception
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
java.lang.Thread.run(Thread.java:595)
root cause
java.lang.ClassCastException: javax.naming.Reference
servlet.CadastrarTratamentoPanela.init(CadastrarTratamentoPanela.java:47)
javax.servlet.GenericServlet.init(GenericServlet.java:212)
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
java.lang.Thread.run(Thread.java:595)
note The full stack trace of the root cause is available in the JBossWeb/2.0.1.GA logs.
Espero que possam me dar uma luz…
desde ja agradeço a atencao…