[EJB 3.0] - Problems with ejb3 EntityManager, find method
by marianokm
Hi, i got the following exception when i run my code
| Hibernate: select rol0_.ROL_ID as ROL1_6_0_, rol0_.ADMINISTRADOR as ADMINIST2_6_0_, rol0_.DESCRIPCION as DESCRIPC3_6_0_, rol0_.HABIL
| ITADO as HABILITADO6_0_, rol0_.NOTAS as NOTAS6_0_ from ROL rol0_ where rol0_.ROL_ID=?
| 17:21:47,640 ERROR [STDERR] java.lang.ClassCastException: ar.com.ebizlink.server.models.Rol
| 17:21:47,640 ERROR [STDERR] at $Proxy97.getRol(Unknown Source)
| 17:21:47,640 ERROR [STDERR] at ar.com.ebizlink.console.controllers.RolController.edit(Unknown Source)
|
My enviroment is:
jboss-4.0.5.GA, jems installer (ejb3 instalation)
j2sdk1.5.0_09
jboss-eclipse 1.5
and the files are listed next ...
Rol.java
| package ar.com.ebizlink.server.models;
|
| import javax.persistence.Column;
| import javax.persistence.Entity;
| import javax.persistence.GeneratedValue;
| import javax.persistence.Id;
| import javax.persistence.Table;
|
| @Entity
| @Table(name = "ROL")
| public class Rol implements java.io.Serializable {
|
| private static final long serialVersionUID = 1L;
|
| // Fields
| private Long rolId;
|
| private String descripcion;
|
| private Boolean habilitado;
|
| private Boolean administrador;
|
| private String notas;
|
| // Constructors
|
| /** default constructor */
| public Rol() {
| }
|
| /** minimal constructor */
| public Rol(Long rolId) {
| this.rolId = rolId;
| }
|
| /** full constructor */
| public Rol(Long rolId, String descripcion, Boolean habilitado,
| Boolean administrador, String notas) {
| this.rolId = rolId;
| this.descripcion = descripcion;
| this.habilitado = habilitado;
| this.administrador = administrador;
| this.notas = notas;
| }
|
| // Property accessors
| @Id
| @GeneratedValue
| @Column(name = "ROL_ID", unique = true, nullable = false, insertable = true, updatable = true)
| public Long getRolId() {
| return this.rolId;
| }
|
| public void setRolId(Long rolId) {
| this.rolId = rolId;
| }
|
| @Column(name = "DESCRIPCION", unique = false, nullable = true, insertable = true, updatable = true, length = 50)
| public String getDescripcion() {
| return this.descripcion;
| }
|
| public void setDescripcion(String descripcion) {
| this.descripcion = descripcion;
| }
|
| @Column(name = "HABILITADO", unique = false, nullable = true, insertable = true, updatable = true)
| public Boolean getHabilitado() {
| return this.habilitado;
| }
|
| public void setHabilitado(Boolean habilitado) {
| this.habilitado = habilitado;
| }
|
| @Column(name = "ADMINISTRADOR", unique = false, nullable = true, insertable = true, updatable = true)
| public Boolean getAdministrador() {
| return this.administrador;
| }
|
| public void setAdministrador(Boolean administrador) {
| this.administrador = administrador;
| }
|
| @Column(name = "NOTAS", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
| public String getNotas() {
| return this.notas;
| }
|
| public void setNotas(String notas) {
| this.notas = notas;
| }
|
| }
|
RolManager.java
| package ar.com.ebizlink.server.interfaces;
|
| import java.util.List;
|
| import javax.ejb.Local;
|
| import ar.com.ebizlink.server.models.Rol;
|
| @Local
| public interface RolManager {
|
| public Rol getRol(Long rolId);
|
| public List<Rol> getRoles();
|
| public void save(Rol detached);
|
| public void delete(Long rolId);
| }
|
The bean instance
| package ar.com.ebizlink.server.beans;
|
| import java.util.List;
|
| import javax.ejb.Stateless;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.TransactionAttributeType;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
|
| import ar.com.ebizlink.server.interfaces.RolManager;
| import ar.com.ebizlink.server.models.Rol;
|
| @Stateless
| public class RolManagerBean implements RolManager {
|
| @PersistenceContext
| private EntityManager em;
|
| public Rol getRol(Long rolId) {
| return em.find(Rol.class, rolId);
| // Query query = em.createQuery("select r from Rol r where r.rolId =
| // :rolId");
| // query.setParameter("rolId", rolId);
| // return (Rol)query.getSingleResult();
| }
|
| @SuppressWarnings("unchecked")
| public List<Rol> getRoles() {
| return em.createQuery("from Rol").getResultList();
| }
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void save(Rol detached) {
| Rol rol = getCurrent(detached.getRolId());
| rol.setAdministrador(detached.getAdministrador());
| rol.setDescripcion(detached.getDescripcion());
| rol.setHabilitado(detached.getHabilitado());
| rol.setNotas(detached.getNotas());
| em.persist(rol);
| }
|
| @TransactionAttribute(TransactionAttributeType.MANDATORY)
| private Rol getCurrent(Long rolId) {
| Rol rol = getRol(rolId);
| if (rol == null) {
| rol = new Rol();
| em.persist(rol);
| }
| return rol;
| }
|
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void delete(Long rolId) {
| Rol rol = getRol(rolId);
| em.remove(rol);
| }
|
| }
|
JSF CODE - RolController.java
| package ar.com.ebizlink.console.controllers;
|
| import java.util.List;
|
| import ar.com.ebizlink.console.forms.RolForm;
| import ar.com.ebizlink.server.interfaces.RolManager;
| import ar.com.ebizlink.server.models.Rol;
| import ar.com.ulink.framework.commons.tokens.CommonsTokens;
| import ar.com.ulink.framework.ejb3.EJB3ServiceLocator;
| import ar.com.ulink.framework.mvc.jsf.JsfUtility;
|
| public class RolController {
|
| private RolForm rolForm;
|
| public final RolForm getRolForm() {
| return rolForm;
| }
|
| public final void setRolForm(RolForm rolForm) {
| this.rolForm = rolForm;
| }
|
| // THIS METHOD WORKS FINE !!
|
| public final List<Rol> getRoles() {
| List<Rol> roles = null;
| try {
| RolManager rolManager = (RolManager) EJB3ServiceLocator
| .getEjbInterface("ebizlink/RolManagerBean/local");
| roles = rolManager.getRoles();
| } catch (Exception e) {
| e.printStackTrace();
| }
| return roles;
| }
|
| // HOWEVER, THIS ONE CRASH !!
| // when execute : Rol rol = rolManager.getRol(rolId);
|
| public final String edit() {
|
| // Status a devolver.
| String actionForward = CommonsTokens.EDIT_SUCCESS;
|
| // Tomo el parametro del rol a modificar.
| Long rolId = Long.valueOf(JsfUtility.getObjectFromContext("rolId")
| .toString());
|
| System.out.println("************* RolId: " + rolId);
|
| try {
| // Obtengo el rol a modificar.
| RolManager rolManager = (RolManager) EJB3ServiceLocator
| .getEjbInterface("ebizlink/RolManagerBean/local");
|
| System.out.println("************* paso 2, RolId: " + rolId);
|
| // Here's the exception
| Rol rol = rolManager.getRol(rolId);
|
| System.out.println("************* paso 3, RolId: " + rolId);
|
| // Asigno los datos al form.
| rolForm.setAdministrador(rol.getAdministrador());
| rolForm.setDescripcion(rol.getDescripcion());
| rolForm.setHabilitado(rol.getHabilitado());
| rolForm.setNotas(rol.getNotas());
| rolForm.setRolId(rol.getRolId());
|
| } catch (Exception e) {
| actionForward = CommonsTokens.EDIT_FAILURE;
| e.printStackTrace();
| }
|
| // Forward del formulario.
| return actionForward;
| }
|
| }
|
i have the exception mentioned earlier and i dont have any clue where the probles is ...
any ideas ??
Regards
Mariano
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992346#3992346
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992346
19 years, 4 months
[Messaging, JMS & JBossMQ] - namenotfound exception in JMS Client
by nsv
I need help very urgent
I have configured the connection factory in jms-ds.xml as below
<tx-connection-factory>
| <jndi-name>AlarmMgrConnectionFactory</jndi-name>
| <xa-transaction/>
| <rar-name>jms-ra.rar</rar-name>
| <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
| <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Queue</config-property>
| <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
| <max-pool-size>20</max-pool-size>
| </tx-connection-factory>
|
|
|
| <tx-connection-factory>
| <jndi-name>EventConnectionFactory</jndi-name>
| <xa-transaction/>
| <rar-name>jms-ra.rar</rar-name>
| <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
| <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
| <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>
| <max-pool-size>20</max-pool-size>
| <security-domain-and-application>JmsXARealm</security-domain-and-application>
| </tx-connection-factory>
|
When i try to lookup for the conection factory from the lookup i get the Namenotbound exception, Below is the lines from JMS Client program
Properties properties = new Properties();
| properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
| properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
| properties.put(Context.PROVIDER_URL, "localhost:3099");
| InitialContext ctx = new InitialContext(properties);
| Object obj = ctx.lookup("java:AlarmMgrConnectionFactory");
Please please help
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992342#3992342
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992342
19 years, 4 months
[Persistence, JBoss/CMP, Hibernate, Database] - Configure JBoss/Hibernate to use JBossCache-TreeCache
by CarstenRudat
Hi all,
I've read some articles about configuring Hibernate to use JBossCache as 2nd level cache (e.g. http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossCacheHibernate).
I use now a JBoss 4.0.5.GA and "I think", I have a TreeCache now deployed as an MBean:
| <server>
| <mbean
| code="org.jboss.invocation.jrmp.server.JRMPProxyFactory"
| name="mydomain:service=proxyFactory,type=jrmp,target=factory">
| <attribute name="InvokerName">jboss:service=invoker,type=jrmp</attribute>
| <attribute name="TargetName">jboss.cache:service=TreeCache</attribute>
| <attribute name="JndiName">SystemCache</attribute>
| <attribute name="InvokeTargetMethod">true</attribute>
| <attribute name="ExportedInterface">org.jboss.cache.TreeCacheMBean</attribute>
| <attribute name="ClientInterceptors">
| <iterceptors>
| <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
| <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
| <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
| </iterceptors>
| </attribute>
| <depends>jboss:service=invoker,type=jrmp</depends>
| <depends>jboss.cache:service=TreeCache</depends>
| </mbean>
| </server>
|
and a configuration like
http://labs.jboss.com/file-access/default/members/jbosscache/freezone/doc...
After all, I tried to set the
hibernate.cache.provider_class=org.jboss.hibernate.cache.DeployedTreeCacheProvider
configuration in persistence.properties file, but this doesn't work?!
Is there any deeper configuraiotn tutorial or a preconfigurated xml-example?
Thanks,
Carsten[/url]
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992340#3992340
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992340
19 years, 4 months
[Management, JMX/JBoss] - LOOKING FOR - Top Notch JBOSS Administrator/Infrastructure A
by delluser
Email directly to hiring manager
javadevelopers(a)yahoo.com
We are a startup (www.nbbc.com ) within a fortune 5 corp - pioneering in digitial video syndication.
Responsibilities:
· Install, configure and administer Apache, Tomcat / Jboss in a mixed Linux/Windows environment.
· Architect & Design the Infrastructure architecture for NBBC.
· Manage 15 plus servers - Win2k and Linux.
· Provide the infrastructure for product management & Software Development teams to develop front end as well as backend software products / services.
· Procure, Configure and deploy new servers.
· Capacity monitoring as well as proactive planning.
· Drive defect resolution for critical technical issues.
Experience:
· Expert in optimizing configuration of clustered web farm utilizing Tomcat, JBOSS and Apache servers.
· Must have 2+ Years JBOSS Application Server Administration experience.
· This position requires 3-5 years of Infrastructure Architecture design and Integration Engineering experience
· Must have 2+ Years of Linux and/or UNIX operating systems.
· Must have experience with Storage solutions ? SAN, NAS.
Skills:
· Candidates must have knowledge of varhious components of technology Infrastructure including Network, Storage, operating systems and Web Servers.
· End-to-End Performance tuning and trouble shooting.
We Offer -
- Great fun and informal environment.
- Exposure to cutting edge technologies.
- Flexible work hours.
- Excellent benefits
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992339#3992339
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992339
19 years, 4 months
[Performance Tuning] - JOBS - JBOSS Administrator/Architect
by delluser
JOBS - JBOSS Administrator/Architect
We are a startup (www.nbbc.com) within a fortune 5 corp - pioneering in digitial video syndication.
Responsibilities:
· Install, configure and administer Apache, Tomcat / Jboss in a mixed Linux/Windows environment.
· Architect & Design the Infrastructure architecture for NBBC.
· Manage 15 plus servers - Win2k and Linux.
· Provide the infrastructure for product management & Software Development teams to develop front end as well as backend software products / services.
· Procure, Configure and deploy new servers.
· Capacity monitoring as well as proactive planning.
· Drive defect resolution for critical technical issues.
Experience:
· Expert in optimizing configuration of clustered web farm utilizing Tomcat, JBOSS and Apache servers.
· Must have 2+ Years JBOSS Application Server Administration experience.
· This position requires 3-5 years of Infrastructure Architecture design and Integration Engineering experience
· Must have 2+ Years of Linux and/or UNIX operating systems.
· Must have experience with Storage solutions ? SAN, NAS.
Skills:
· Candidates must have knowledge of varhious components of technology Infrastructure including Network, Storage, operating systems and Web Servers.
· End-to-End Performance tuning and trouble shooting.
We Offer -
- Great fun and informal environment.
- Exposure to cutting edge technologies.
- Flexible work hours.
- Excellent benefits
Email directly to hiring manager
javadevelopers(a)yahoo.com
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3992338#3992338
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3992338
19 years, 4 months