Bug 439 : IllegalAccessException if @XmlRootElement does not have public default constructor
Priority 
High
Reported Version 
 
Logged By 
thSoft
Status 
Fixed
Fixed Version 
3.x
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
27/12/2012
Updated 
27/12/2012
Type 
Bug
 
Attachments 
No attachments

If Ebean encounters has a JAXB @XmlRootElement class which does not have a public no-arg constructor, e.g.:

@XmlRootElement
public class Foo {
protected Foo() {
}
}

...then the following exception is thrown when calling Ebean.getServer():

java.lang.ExceptionInInitializerError
at TestFoo.test(TestFoo.java:9)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: javax.persistence.PersistenceException: java.lang.IllegalAccessException: Class com.avaje.ebeaninternal.server.reflect.EnhanceBeanReflect can not access a member of class Foo with modifiers "protected"
at com.avaje.ebeaninternal.server.reflect.EnhanceBeanReflect.(EnhanceBeanReflect.java:60)
at com.avaje.ebeaninternal.server.reflect.EnhanceBeanReflectFactory.create(EnhanceBeanReflectFactory.java:10)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.setBeanReflect(BeanDescriptorManager.java:1359)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.createByteCode(BeanDescriptorManager.java:1161)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readDeployAssociations(BeanDescriptorManager.java:1077)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.readEntityDeploymentAssociations(BeanDescriptorManager.java:584)
at com.avaje.ebeaninternal.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:271)
at com.avaje.ebeaninternal.server.core.InternalConfiguration.(InternalConfiguration.java:143)
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:209)
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:123)
at com.avaje.ebeaninternal.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:63)
at com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:64)
at com.avaje.ebean.Ebean$ServerManager.getWithCreate(Ebean.java:225)
at com.avaje.ebean.Ebean$ServerManager.(Ebean.java:181)
at com.avaje.ebean.Ebean$ServerManager.(Ebean.java:147)
at com.avaje.ebean.Ebean.(Ebean.java:141)
... 25 more
Caused by: java.lang.IllegalAccessException: Class com.avaje.ebeaninternal.server.reflect.EnhanceBeanReflect can not access a member of class Foo with modifiers "protected"
at sun.reflect.Reflection.ensureMemberAccess(Reflection.java:95)
at java.lang.Class.newInstance0(Class.java:366)
at java.lang.Class.newInstance(Class.java:325)
at com.avaje.ebeaninternal.server.reflect.EnhanceBeanReflect.(EnhanceBeanReflect.java:45)
... 40 more

 
woResponse

Upload a file