Estou quebrando a cabeça com este problema e nao consigo fazer isso funcionar:
Abaixo o session bean miserável responsável pelo erro:
package br.com.toyota.dss.sessions;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.List;
import javax.ejb.EJBException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Session;
import net.sf.hibernate.SessionFactory;
import org.apache.commons.beanutils.PropertyUtils;
import br.com.toyota.dss.hibernate.SvdCartaIcm;
import br.com.toyota.dss.interfaces.CartaIcmsInterface;
/**
*
* @author Rodrigo di Lorenzo Lopes
*
* @ejb.bean description = "Sessao de persistencia da carta de icensao de icms"
* display-name = "SessionBean para Carta de icensao de Icms"
* jndi-name = "ejb/production/CartaIcmSession"
* local-jndi-name = "ejb/production/CartaIcmSession"
* type = "Stateless"
* generate = "true"
* transaction-type = "Container"
* view-type = "both"
*
* @ejb.transaction type = "Required"
* @ejb.util generate = "physical"
*
*/
public class CartaIcmSessionBean implements SessionBean {
public SessionContext sessionContext;
private static SessionFactory factory;
public void ejbCreate() {}
public void ejbActivate() throws EJBException, RemoteException {}
public void ejbPassivate() throws EJBException, RemoteException {}
public void ejbRemove() throws EJBException, RemoteException {}
public void setSessionContext(SessionContext arg0) throws EJBException, RemoteException {
sessionContext = arg0;
}
/**
* Abre uma nova sessao com lookup do contexto inicial
* @return uma nova sessão aberta
* @throws NamingException a excessao lancada pela definicao
* errada no jndi
* @throws HibernateException a excessao do hibernate em abrir
* uma sessao
*/
private Session openSession() throws HibernateException, NamingException {
if (factory== null){
Context context = new InitialContext();
factory = (SessionFactory) context.lookup("java:/hibernate/HibernateFactory");
}
return factory.openSession();
}
public void setSessionFactory (SessionFactory factory){
CartaIcmSessionBean.factory = factory;
}
/**
*
* @param icmsInterface
* @throws IllegalAccessException
* @throws InvocationTargetException
* @throws NoSuchMethodException
* @throws HibernateException if the action of open session fail
* @throws NamingException if jndi name is wrong
*
* @ejb.interface-method view-type = "remote"
*/
public void addCartaIcm(CartaIcmsInterface icmsInterface) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException, HibernateException, NamingException{
SvdCartaIcm cartaIcm = new SvdCartaIcm();
PropertyUtils.copyProperties(cartaIcm, icmsInterface);
Session session = this.openSession();
session.save(cartaIcm);
session.refresh(cartaIcm);
session.close();
}
/**
*
* @param id primary key to find this object
* @throws HibernateException
* @throws NamingException
*
* @ejb.interface-method view-type = "remote"
*/
public void removeCartaIcm(Long id) throws HibernateException, NamingException{
SvdCartaIcm cartaIcm = findCartaIcmbyPK(id);
if (cartaIcm != null){
Session session = this.openSession();
session.delete(cartaIcm);
session.close();
}
}
/**
*
* @param cartaIcmsInterface
* @throws HibernateException
* @throws NamingException
*
* @ejb.interface-method view-type = "remote"
*/
public void removeCartaIcm(CartaIcmsInterface cartaIcmsInterface) throws HibernateException, NamingException{
Session session = this.openSession();
session.delete(cartaIcmsInterface);
session.close();
}
/**
* Atualiza informações deste Objeto
* @param cartaIcmsInterface interface deste objeto
* @throws HibernateException
* @throws NamingException
*
* @ejb.interface-method view-type = "remote"
*/
public void updateCartaicms(CartaIcmsInterface cartaIcmsInterface) throws HibernateException, NamingException{
Session session = this.openSession();
session.save(cartaIcmsInterface);
session.close();
}
/**
* Carrega o ValueObject da Sessão usando primary-key
* @param id primary key deste elemento
* @return elemento encontrado
* @throws HibernateException
* @throws NamingException
*
* @ejb.interface-method view-type = "remote"
*/
public SvdCartaIcm findCartaIcmbyPK (Long id) throws HibernateException, NamingException{
Session session = this.openSession();
SvdCartaIcm returns = (SvdCartaIcm) session.load(SvdCartaIcm.class, id);
session.close();
return returns;
}
/**
* Procura objeto atráves de chave e valor
* @param chave nome da coluna
* @param value valor que o objeto assume nesta coluna
* @return Objeto procurado caso encontre, null caso contrário
* @throws HibernateException
* @throws NamingException
*
* @ejb.interface-method view-type = "remote"
*/
public List findCartaIcm (String chave, String value) throws HibernateException, NamingException{
Session session = this.openSession();
String find = "find PUB.SVD_CARTA_ICMS where" + chave + "=" + value;
List list = session.find(find);
session.close();
return list;
}
}
Agora o mapping de configuraçao:
<SvdCartaIcm.hbm.xml>
<server>
<mbean code="net.sf.hibernate.jmx.HibernateService" name="jboss.jca:service=HibernateFactory,
name=HibernateFactory">
<depends>jboss.jca:service=RARDeployer</depends>
<depends>jboss.jca:service=LocalTxCM,name=ProgressDS</depends>
<!-- Make it deploy ONLY after DataSource had been started -->
<attribute name="MapResources">mapping/SvdCartaIcm.hbm.xml</attribute>
<attribute name="JndiName">java:/hibernate/HibernateFactory</attribute>
<attribute name="Datasource">java:/ProgressDS</attribute>
<attribute name="Dialect">net.sf.hibernate.dialect.ProgressDialect</attribute>
<attribute name="TransactionStrategy">net.sf.hibernate.transaction.JTATransactionFactory</attribute>
<attribute name="TransactionManagerLookupStrategy">net.sf.hibernate.transaction.JBossTransactionManagerLookup</attribute>
<attribute name="UseOuterJoin">false</attribute>
<attribute name="ShowSql">false</attribute>
<attribute name="UserTransactionName">java:/actuate</attribute>
</mbean>
</server>
<jndi.properties>
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost
Se alguém encarecidamente puder me ajudar (e salvar a pouca sanidade que me resta) eu ficarei muito grato.
[]´s