geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purdticker <core...@rocketmail.com>
Subject Error when using EJB / persistence
Date Fri, 27 Jun 2008 19:11:02 GMT

I'm getting the following exception thrown when I call findByPrimaryKey():
javax.ejb.EJBException: The bean encountered a non-application exception.;
nested exception is: 
	<openjpa-1.0.2-r420667:627158 nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: For input string: "13
02:22:28"

I've been following this tutorial as much as possible, although some things
in my environment are a little different:
http://cwiki.apache.org/GMOxDOC21/myphonebook-very-simple-entity-ejb-example.html

My Code:

Action.java: Entity Bean
package com.accentureebs.ejb.ControlMSchedule;

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

@Entity
@Table(name = "CTM_SCH_ACTION")
public class Action {
	private int id;
	private String desc;
	private String updatedLogon;
	private java.sql.Date timeStamp;
	
	public Action() {}
	
	public Action(int id) {
		this.id = id;
	}
	
	/*************************/
	/** GETTERS AND SETTERS **/
	/*************************/
	
	@Id
	@Column(name="SCH_ACTION_ID")
	public int getId() { return id; }
	public void setId (int id) { this.id = id; }
	
	@Column(name="SCH_ACTION_DESC", nullable=false, length=32)
	public String getDesc() { return desc; }
	public void setDesc (String desc) { this.desc = desc; }
	
	@Column(name="UPDT_LOGON", nullable=false, length=9)
	public String getUpdatedLogon() { return updatedLogon; }
	public void setUpdatedLogon(String updatedLogon) { this.updatedLogon =
updatedLogon; }
	
	@Column(name="TIME_STAMP")
	public java.sql.Date getTimeStamp() { return timeStamp; }
	public void setTimeStamp(java.sql.Date timeStamp) { this.timeStamp =
timeStamp; }

}

ActionLocal.java -> Interface
package com.accentureebs.ejb.ControlMSchedule;

public interface ActionLocal {
	public Action findByPrimaryKey(String key);
}

ActionBean.java -> Implementation of interface
package com.accentureebs.ejb.ControlMSchedule;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;

@Stateless
public class ActionBean implements ActionLocal {
	@PersistenceUnit(unitName="CTMSchedulePU")
	protected EntityManagerFactory emf;
	
	public ActionBean() {}
	
	public Action findByPrimaryKey(String key) {
		EntityManager em = emf.createEntityManager();
		
		Action action = (Action)em.find(Action.class, key);
		
		em.close();
		
		return action;
	}
}

openejb-jar.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ejb:openejb-jar
xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2"
xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2"
xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2"
xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2"
xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1"
xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0"
xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0"
xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1"
xmlns:pers="http://java.sun.com/xml/ns/persistence"
xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0">
    <dep:environment>
        <dep:moduleId>
            <dep:groupId>default</dep:groupId>
            <dep:artifactId>EBSPortalEJB</dep:artifactId>
            <dep:version>1.0</dep:version>
            <dep:type>car</dep:type>
        </dep:moduleId>
    </dep:environment>
</ejb:openejb-jar>

persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence	xmlns="http://java.sun.com/xml/ns/persistence"
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"
		xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
	<persistence-unit name="CTMSchedulePU">
		<description>Control-M Schedule Persistence Unit</description>
	
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
		<jta-data-source>EBSPool</jta-data-source>
		<non-jta-data-source>EBSPool</non-jta-data-source>
		<class>com.accentureebs.ejb.ControlMSchedule.Action</class>
	</persistence-unit>
</persistence>
-- 
View this message in context: http://www.nabble.com/Error-when-using-EJB---persistence-tp18161971s134p18161971.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message