geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: CMP exception: Attempt to cast instance "xxx [java.lang.String]" to PersistenceCapable failed. Ensure that it has been enhanced.
Date Wed, 11 Mar 2009 21:33:37 GMT

On Mar 10, 2009, at 7:55 AM, Phili wrote:
> @Stateless
> @WebService(serviceName = "TestWS",
>             portName = "TestWSPort",
>             endpointInterface = "xxxx",
>             targetNamespace = "xxx")
> public class TestWSBean implements TestWS {
> 	
> 	@PersistenceContext(unitName="TestPU")
> 	private EntityManager em;
>
> 	public String saveName(String value)
> 	{
> 		String result = "ok";
> 		
> 		try {
> 			EntityClass b = new EntityClass();
> 			b.setName(value);
> 			em.persist(value);	
> 		}
> 		catch(Exception ex) {
> 			ex.printStackTrace();
> 			result = ex.getLocalizedMessage() + " " + ex.getClass().getName();	
> 		}
> 		
> 		return result;
> 	}
> }
>
Looks like you have a typo in your code.   s/em.persist(value)/ 
em.persist(b)/

Happens to the best of us :)

-David


Mime
View raw message