[jboss-user] [JBoss Seam] - Seam and Hibernate

jjsoft do-not-reply at jboss.com
Mon Aug 7 14:54:02 EDT 2006


Hi, again.

I am trying to clone the register example and make it work with one of my beans that uses hibernate for persistance (mySql). So far without success. I was wondering if anyone has a roadmap on how to do that? I have an up and runing JBoss/EBJ3/Hibernate web application I am trying to see how dificult and what advantages I get by porting to Seam. My appliactions contains hundred of beans and many dozens of actions. I am just trying to get one simple little bean and once fetch action going.

Here is what the table looks like

+-------------------+--------------+------+-----+---------+-------+
| Field             | Type           | Null | Key | Default | Extra |
+-------------------+--------------+------+-----+---------+-------+
| node_id        | varchar(180) |      | PRI  |           |       |
| node_name   | varchar(80)  |      |        |           |       |
| description     | varchar(240)|      |       |           |       |
| vault_id         | int(11)          |      |       | 0         |       |
| security_model_id | int(11)   |    |       | 0         |       |
+-------------------+--------------+------+-----+---------+-------+

Here is my persistance.xml 

( = < and ) = > since I can't turn html off.



(persistence)
  (persistence-unit name="joms")
    (provider>org.hibernate.ejb.HibernatePersistence</provider)
    (jta-data-source>java:/DefaultDS</jta-data-source)
    (properties>
      (property name ="hibernate.show_sql" value="true"/)
      (property name ="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/)
      (property name ="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/)
      (property name ="hibernate.dialect" value="org.hibernate.dialect.MySQLMyISAMDialect"/)
      (property name ="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/)
      (property name ="hibernate.connection.username" value="xxxxxx"/)
      (property name ="hibernate.connection.password" value="xxxxxx"/)
      (property name ="hibernate.connection.url" value="jdbc:mysql:///joms"/);
    (/properties)
  (/persistence-unit)
(/persistence)




Here is what the bean looks like, (clone of user.java in register example.




//$Id: User.java,v 1.9 2005/09/10 19:08:01 gavin Exp $
package org.jboss.seam.example.nodes;

import static org.jboss.seam.ScopeType.SESSION;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

@Entity
@Name("node")
@Scope(SESSION)
@Table(name="nodes")
public class Node implements Serializable
{
   	private static final long serialVersionUID = 1881413500711441951L;
   
   	private String nodeId;
   	private String nodeName;
   
   	public Node(String id, String name)
   	{
      		this.nodeId = id;
      		this.nodeName = name;
   	}
   
   	public Node() 
	{
		//do nothing
	}
   
   	@NotNull
   	public String getNodeName()
   	{
      		return nodeName;
   	}

   	public void setNodeName(String s)
   	{
      		this.nodeName = s;
   	}
   
   	@Id @NotNull @Length(min=2, max=16)
   	public String getNodeId()
   	{
      		return nodeId;
   	}

   	public void setNodeId(String s)
   	{
      		this.nodeId = s;
   	}
   	public String toString() 
   	{
      		return "Node(" + nodeId + ")";
   	}
}


Evedrything else is a clone of registration except I replace register with nodes every where it occured. 



At service startup I get this warning



13:38:54,018 WARN  [ServiceController] Problem starting service persistence.unit
s:ear=jboss-seam-nodes.ear,jar=jboss-seam-nodes.jar,unitName=joms
java.lang.RuntimeException: java.lang.NoSuchMethodError: org.hibernate.cfg.Annot
ationConfiguration.setEntityNotFoundDelegate(Lorg/hibernate/proxy/EntityNotFound
Delegate;)V







At runtime I can get to my data entry page via



http://localhost:8080/seam-nodes/nodes.seam




But on submit I get 


13:43:24,002 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet
 threw exception
javax.faces.FacesException: Error calling action method of component with id _id
0:_id5
        at org.apache.myfaces.application.ActionListenerImpl.processAction(Actio
nListenerImpl.java:74)
        at javax.faces.component.UICommand.broadcast(UICommand.java:106)
        at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:9
0)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1
64)
        at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(Lifecycl
eImpl.java:316)
        at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java
:86)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:96)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:175)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:74)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:869)
        at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:664)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
        at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException: Exception while invoking expressi
on #{nodes.node}
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java
:165)
        at org.apache.myfaces.application.ActionListenerImpl.processAction(Actio
nListenerImpl.java:63)
        ... 24 more
Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam com
ponent: nodes
        at org.jboss.seam.Component.newInstance(Component.java:735)
        at org.jboss.seam.Component.newInstance(Component.java:1308)
        at org.jboss.seam.Component.getInstance(Component.java:1263)
        at org.jboss.seam.Component.getInstance(Component.java:1246)
        at org.jboss.seam.jsf.SeamVariableResolver.resolveVariable(SeamVariableR
esolver.java:44)
        at org.apache.myfaces.el.ValueBindingImpl$ELVariableResolver.resolveVari
able(ValueBindingImpl.java:569)
        at org.apache.commons.el.NamedValue.evaluate(NamedValue.java:124)
        at org.apache.myfaces.el.ValueBindingImpl.resolveToBaseAndProperty(Value
BindingImpl.java:450)
        at org.apache.myfaces.el.MethodBindingImpl.resolveToBaseAndProperty(Meth
odBindingImpl.java:180)
        at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java
:114)
        ... 25 more
Caused by: javax.naming.NameNotFoundException: jboss-seam-nodes 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.jnp.interfaces.NamingContext.lookup(NamingContext.java:625)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
        at javax.naming.InitialContext.lookup(Unknown Source)
        at org.jboss.seam.Component.instantiate(Component.java:774)
        at org.jboss.seam.Component.newInstance(Component.java:731)
        ... 34 more






I am pretty sure I have a configuration problem. Anyone have any pointers, examples, anything that might help me get going? 

thanks

jim s








View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3963654#3963654

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3963654



More information about the jboss-user mailing list