Page 1 of 1

Error accessing NewEntity from Admin

Posted: Fri Oct 23, 2015 11:11 pm
by ipapachristoudis
SOLVED, ManufacturerImpl should implement Serializable interface
Hello

I followed the tutorials
http://www.broadleafcommerce.com/docs/c ... new-entity for adding a new Entity
and
http://www.broadleafcommerce.com/docs/c ... m-entities

for creating a new Entity called Manufacturer and accessing it from admin panel.

The problem is that at the panel a receive the message

...java.lang.ClassCastException: com.mycompany.sample.domain.ManufacturerImpl cannot be cast to java.io.Serializable...

I have spend hours and hours but i didn't manage to make it work, so any help would be mauch appreciated. My code is
Manufacturer Class

Code: Select all

package com.mycompany.sample.domain;

public interface Manufacturer {
   Long getId();

    void setId(Long id);

    String getName();

    void setName(String name);
}

Manufacturerimpl Class

Code: Select all

package com.mycompany.sample.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.Table;
import javax.persistence.InheritanceType;
import org.broadleafcommerce.common.presentation.AdminPresentation;
import org.broadleafcommerce.common.presentation.AdminPresentationClass;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.CacheConcurrencyStrategy;

@Entity
@Table(name = "EVS_MANUF")
@Inheritance(strategy = InheritanceType.JOINED)
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "blStandardElements")
@AdminPresentationClass(friendlyName = "ManufacturerImpl")
public class ManufacturerImpl implements Manufacturer {

   private static final long serialVersionUID = 1L;

   @Id
   @GeneratedValue(generator = "ManufacturerId")
   @GenericGenerator(name = "ManufacturerId", strategy = "org.broadleafcommerce.common.persistence.IdOverrideTableGenerator", parameters = {
         @Parameter(name = "segment_value", value = "ManufacturerImpl"),
         @Parameter(name = "entity_name", value = "com.mycompany.sample.domain.ManufacturerImpl") })
   @Column(name = "MANUF_ID")
   protected Long id;

   @Column(name = "MANUF_NAME", nullable = false)
   @AdminPresentation(friendlyName = "ManufacturerImpl", order = 1, prominent = true, gridOrder = 1)
   protected String name;

   @Override
   public Long getId() {
      return id;
   }

   @Override
   public void setId(Long id) {
      this.id = id;
   }

   @Override
   public String getName() {
      return name;
   }

   @Override
   public void setName(String name) {
      this.name = name;
   }
}


the db table is EVS_MANUF with 2 columns MANUF_ID and MANUF_NAME.

Also i modified all the files mentioned in the tutorial (persistence.xml, applicationContext.xml)

Am i missing something?

Re: Error accessing NewEntity from Admin

Posted: Tue Apr 05, 2016 9:58 pm
by jammyjaccy
i have the same problem,is any can help?thks.

Re: Error accessing NewEntity from Admin

Posted: Tue Apr 05, 2016 10:53 pm
by jammyjaccy
I have the same problem,is anyone can help?thks

Re: Error accessing NewEntity from Admin

Posted: Wed Jun 08, 2016 10:48 pm
by kunner
you need to implements Serializable when you make open admin entity.

modify your code like below --

Manufacturer.java

Code: Select all

public interface Manufacturer, Serializable {
   ...
}


and you need to describe default serialVersionUID at ManufacturerImpl too.

That's all.