NoSuchFieldError: __odbTracker on NetBeans 7.3 + JBoss 7.1.1

#1

When using inheritance throw exception java.lang.NoSuchFieldError: __odbTracker on NetBeans 7.3 + Jboss 7.1.1

@Entity
public class Person extends AbstractObject {
    private static final long serialVersionUID = 1L;
  
    @ManyToOne @Index
    private City city;
   
     @OneToMany(mappedBy = "owner")
    private List<City> cities;
    
    private String name;

    public String getName() {
        return name;
    }

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

    public City getCity() {
        return city;
    }

    public void setCity(City city) {
        this.city = city;
    }

    public List<City> getCitys() {
        return cities;
    }

    public void setCitys(List<City> citys) {
        this.cities = citys;
    } 
}


@Entity
public class City extends AbstractObject {
    private static final long serialVersionUID = 33L;
   
    @OneToMany(mappedBy = "city")
    private List<Person> persons;
   
    @ManyToOne @Index
    private Person owner;
   
    private String name;

    public String getName() {
        return name;
    }

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

    public List<Person> getPersons() {
        return persons;
    }

    public void setPersons(List<Person> persons) {
        this.persons = persons;
    }

    public Person getOwner() {
        return owner;
    }

    public void setOwner(Person owner) {
        this.owner = owner;
    }
}

@Entity
public abstract class AbstractObject implements IAbstractObject {
    //private static final long serialVersionUID = 1L;
    @Id
    private String id = UUID.randomUUID().toString();

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof AbstractObject)) {
            return false;
        }
        AbstractObject other = (AbstractObject) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "test.AbstractObject[ id=" + id + " ]";
    }
}

This code throw exception:

        Person person = new Person();
        person.setName(name);
        City city = new City();
        city.setName("Москва");
        person.setCity(city);
        entityManager.persist(city);
        entityManager.persist(person);

The exception:

java.lang.NoSuchFieldError: __odbTracker
test.City.__odbSet_name(City.java:1)
test.City.setName(City.java:39)
ejb.PersonBean.create(PersonBean.java:32)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374)
org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127)
org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135)
org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)
org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)
ejb.PersonBeanLocal$$$view66.create(Unknown Source)
servlet.TestServlet.processRequest(TestServlet.java:68)
servlet.TestServlet.doGet(TestServlet.java:107)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)

if remove the inheritance works fine. On GlassFish 3.1 with inheritance also works fine.

Why "person.setName(name);" works fine? But "city.setName("Москва");" throw exception

Thanks for your help.

#2

This exception indicates a missing enhancement, i.e. City is enhanced but its super class AbstractMethod is not enhanced.

It is indeed weird that the problem is only with City and Person works well, because inherit from the same super class.

Please check if rebuilding the project and then redeployment solve the problem.

You may also try using build time enhancement, which should guarantee that the project is fully enhanced when deployed.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#3

I rebuilt the project and redeployment several times, but the exception is still there.

I added a call to enhance directly into the code as it is written here http://www.objectdb.com/java/jpa/tool/enhancer#Enhancement_API_

 

file PersonBean:

import test.AbstractObject;
import test.City;
import test.Person;

......

other code

......

        com.objectdb.Enhancer.enhance("test.*");

        Person person = new Person();
       
        person.setName(name);

        entityManager.persist(person);
       
        City city = new City();
      
        city.setName("Москва");
       
        person.setCity(city);
    
        entityManager.persist(city);
       
        entityManager.persist(person);

 

but JBoss throw exception:

12:25:10,223 ERROR [stderr] (http--127.0.0.1-8080-1)
12:25:10,223 ERROR [stderr] (http--127.0.0.1-8080-1) [ObjectDB 2.5.1_05] Package test is not found by the enhancer (error 108)
12:25:10,224 ERROR [stderr] (http--127.0.0.1-8080-1) com.objectdb.o.UserException: Package test is not found by the enhancer
12:25:10,224 ERROR [stderr] (http--127.0.0.1-8080-1)  at com.objectdb.o.MSG.d(MSG.java:61)
12:25:10,224 ERROR [stderr] (http--127.0.0.1-8080-1)  at com.objectdb.o.JEL.z(JEL.java:414)
12:25:10,225 ERROR [stderr] (http--127.0.0.1-8080-1)  at com.objectdb.o.JEN.k(JEN.java:91)
12:25:10,225 ERROR [stderr] (http--127.0.0.1-8080-1)  at com.objectdb.Enhancer.enhance(Enhancer.java:66)
12:25:10,226 ERROR [stderr] (http--127.0.0.1-8080-1)  at ejb.PersonBean.create(PersonBean.java:28)
12:25:10,226 ERROR [stderr] (http--127.0.0.1-8080-1)  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:25:10,226 ERROR [stderr] (http--127.0.0.1-8080-1)  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
12:25:10,227 ERROR [stderr] (http--127.0.0.1-8080-1)  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
12:25:10,228 ERROR [stderr] (http--127.0.0.1-8080-1)  at java.lang.reflect.Method.invoke(Method.java:601)
12:25:10,228 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72)
12:25:10,229 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,229 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext$Invocation.proceed(InterceptorContext.java:374)
12:25:10,230 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.doMethodInterception(Jsr299BindingsInterceptor.java:127)
12:25:10,230 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.weld.ejb.Jsr299BindingsInterceptor.processInvocation(Jsr299BindingsInterceptor.java:135)
12:25:10,231 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
12:25:10,232 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,232 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53)
12:25:10,233 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:36)
12:25:10,233 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,234 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47)
12:25:10,234 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,235 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.weld.ejb.EjbRequestScopeActivationInterceptor.processInvocation(EjbRequestScopeActivationInterceptor.java:82)
12:25:10,235 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,236 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21)
12:25:10,236 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,237 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
12:25:10,238 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53)
12:25:10,441 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,441 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51)
12:25:10,442 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,443 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:228)
12:25:10,445 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:304)
12:25:10,445 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:190)
12:25:10,446 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,446 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41)
12:25:10,447 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,447 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59)
12:25:10,448 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,449 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50)
12:25:10,450 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,451 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:32)
12:25:10,451 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,452 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45)
12:25:10,452 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,453 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
12:25:10,453 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165)
12:25:10,454 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ee.component.ViewDescription$1.processInvocation(ViewDescription.java:173)
12:25:10,454 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288)
12:25:10,455 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
12:25:10,455 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.ee.component.ProxyInvocationHandler.invoke(ProxyInvocationHandler.java:72)
12:25:10,456 ERROR [stderr] (http--127.0.0.1-8080-1)  at ejb.PersonBeanLocal$$$view63.create(Unknown Source)
12:25:10,456 ERROR [stderr] (http--127.0.0.1-8080-1)  at servlet.TestServlet.processRequest(TestServlet.java:67)
12:25:10,457 ERROR [stderr] (http--127.0.0.1-8080-1)  at servlet.TestServlet.doGet(TestServlet.java:106)
12:25:10,457 ERROR [stderr] (http--127.0.0.1-8080-1)  at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
12:25:10,458 ERROR [stderr] (http--127.0.0.1-8080-1)  at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
12:25:10,458 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
12:25:10,459 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
12:25:10,494 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)
12:25:10,495 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)
12:25:10,495 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
12:25:10,496 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
12:25:10,497 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
12:25:10,498 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50)
12:25:10,498 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)
12:25:10,499 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)
12:25:10,500 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
12:25:10,500 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
12:25:10,501 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)
12:25:10,501 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
12:25:10,502 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)
12:25:10,502 ERROR [stderr] (http--127.0.0.1-8080-1)  at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)
12:25:10,503 ERROR [stderr] (http--127.0.0.1-8080-1)  at java.lang.Thread.run(Thread.java:722)

 

All objects is in the package "test". Please tell me what am I doing wrong?

Thanks for your help.

#4

> I added a call to enhance directly into the code as it is written here
> http://www.objectdb.com/java/jpa/tool/enhancer#Enhancement_API_

This must be invoked before the application server loads any relevant class. The error message may indicate that it was invoked after loading the base class, so a non enhanced base class was used.

What happens if you do not run the Enhancer at all?

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
#5

Thank you very much for your help, the project works fine.

I added this code in build.xml. 

    <target name="-post-compile">
        <java classname="com.objectdb.Enhancer" fork="true" classpath="C:/projects/test/lib/objectdb.jar">
            <arg line="-s ./build/classes/test/*.class"/>
        </java>
    </target>
#6

Thank you for the update.

Build time enhancement is always preferred when possible.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)

Post Reply

To post a reply and/or subscribe to update notifications - please login