[jboss-jira] [JBoss JIRA] (WFLY-3527) Improper noargs constructor assumption leads to NullPointerException

Randahl Fink Isaksen (JIRA) issues at jboss.org
Mon Jun 23 12:04:24 EDT 2014


    [ https://issues.jboss.org/browse/WFLY-3527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12978673#comment-12978673 ] 

Randahl Fink Isaksen commented on WFLY-3527:
--------------------------------------------

Hang on, I think I found the cause…

I found this exception in the server log:

11:41:04,948 ERROR [org.jboss.as.ejb3] (EJB default - 6) JBAS014250: Could not write method invocation failure for method public abstract com.intuism.ui.validation.Validation com.wefend.services.install.InstallService.validateVerificationCode(com.wefend.model.principal.person.EmailAddress,java.lang.String) on bean named InstallBean for appname wefend-server modulename wefend-ejb distinctname  due to: java.io.NotSerializableException: com.intuism.core.settings.scope.Parenthood
	at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:894)
	at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1066)
	at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1022)
	at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1001)
	at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:888)
	at org.jboss.marshalling.river.RiverMarshaller.doWriteFields(RiverMarshaller.java:1066)
	at org.jboss.marshalling.river.RiverMarshaller.doWriteSerializableObject(RiverMarshaller.java:1022)
	at org.jboss.marshalling.river.RiverMarshaller.doWriteObject(RiverMarshaller.java:888)
	at org.jboss.marshalling.AbstractObjectOutput.writeObject(AbstractObjectOutput.java:62)
	at org.jboss.marshalling.AbstractMarshaller.writeObject(AbstractMarshaller.java:115)
	at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.writeMethodInvocationResponse(MethodInvocationMessageHandler.java:373)
	at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler.access$600(MethodInvocationMessageHandler.java:70)
	at org.jboss.as.ejb3.remote.protocol.versionone.MethodInvocationMessageHandler$1.run(MethodInvocationMessageHandler.java:246)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [rt.jar:1.8.0]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [rt.jar:1.8.0]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0]
	at java.lang.Thread.run(Thread.java:744) [rt.jar:1.8.0]
	at org.jboss.threads.JBossThread.run(JBossThread.java:122)
Caused by: an exception which occurred:
	in field parenthood
	in field defaultSettings
	in object com.intuism.ui.validation.Validation at 7c17e5c

> Improper noargs constructor assumption leads to NullPointerException
> --------------------------------------------------------------------
>
>                 Key: WFLY-3527
>                 URL: https://issues.jboss.org/browse/WFLY-3527
>             Project: WildFly
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>    Affects Versions: 8.0.0.Final
>            Reporter: Randahl Fink Isaksen
>            Assignee: David Lloyd
>            Priority: Critical
>
> As shown in the stack trace below, I have received a NullPointerException from Wildfly. Looking at the Wildfly code, it seems to me that the class org.jboss.marshalling.reflect.SerializableClass improperly requires serializable classes to have a noargs constructor.
> The NullPointerException occurs in line 514:
> {code}
> 514: return constructor.newInstance(args);
> {code}
> so the reason for the NullPointerException is that the parameter constructor is null.
> Now, if you look at line 488, you see that the constructor parameter stems from the method invokation
> {code}
> 488: return invokeConstructorNoException(nonInitConstructor);
> {code}
> so the question is: When is nonInitConstructor defined, and why is it null?
> The answer can be found in line 160
> {code}
> 160: nonInitConstructor = lookupNonInitConstructor(subject);
> {code}
> and that method starts in line 550
> {code}
> 550 private static <T> Constructor<T> More ...lookupNonInitConstructor(final 
>> 555            topConstructor = current.getDeclaredConstructor();
> 556        } catch (NoSuchMethodException e) {
> 557            return null;
> 558        }
>> 563    }
> {code}
> As you can see here, the method getDeclaredConstructor is invoked with no args, so Wildfly expects to find a noargs constructor. If non such constructor exists the NoSuchMethodException is thrown, caught, and null is returned.
> All in all I conclude, that creating a perfectly valid, serializable class with no noargs constructor makes Wildfly crash, and I believe this is a serious bug.
> CLASS WHICH MAKES WILDFLY FAIL
> {code}
> public enum Validity {
> 	VALID(true),
> 	QUESTIONABLE(true),
> 	INVALID(false);
> 	private boolean valid;
> 	
> 	private Validity(boolean valid) {
> 		this.valid = valid;
> 	}
> 	
> 	public boolean isValid() {
> 		return valid;
> 	}
> }
> {code}
> Note: Any enum is also Serializable
> STACK TRACE
> {noformat}
> java.lang.reflect.InvocationTargetException
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:483)
> 	at com.intuism.ui.validation.validator.ValidationTask.call(ValidationTask.java:49)
> 	at com.intuism.ui.validation.validator.ValidationTask.call(ValidationTask.java:23)
> 	at javafx.concurrent.Task$TaskCallable.call(Task.java:1426)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> 	at java.lang.Thread.run(Thread.java:744)
> Caused by: java.lang.NullPointerException
> 	at org.jboss.marshalling.reflect.SerializableClass.invokeConstructorNoException(SerializableClass.java:514)
> 	at org.jboss.marshalling.reflect.SerializableClass.callNonInitConstructor(SerializableClass.java:488)
> 	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1270)
> 	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
> 	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:213)
> 	at org.jboss.marshalling.river.RiverUnmarshaller.readFields(RiverUnmarshaller.java:1715)
> 	at org.jboss.marshalling.river.RiverUnmarshaller.doInitSerializable(RiverUnmarshaller.java:1631)
> 	at org.jboss.marshalling.river.RiverUnmarshaller.doReadNewObject(RiverUnmarshaller.java:1273)
> 	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:276)
> 	at org.jboss.marshalling.river.RiverUnmarshaller.doReadObject(RiverUnmarshaller.java:213)
> 	at org.jboss.marshalling.AbstractObjectInput.readObject(AbstractObjectInput.java:45)
> 	at org.jboss.ejb.client.remoting.MethodInvocationResponseHandler$MethodInvocationResultProducer.getResult(MethodInvocationResponseHandler.java:103)
> 	at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:272)
> 	at org.jboss.ejb.client.EJBObjectInterceptor.handleInvocationResult(EJBObjectInterceptor.java:64)
> 	at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:274)
> 	at org.jboss.ejb.client.EJBHomeInterceptor.handleInvocationResult(EJBHomeInterceptor.java:88)
> 	at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:274)
> 	at org.jboss.ejb.client.TransactionInterceptor.handleInvocationResult(TransactionInterceptor.java:46)
> 	at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:274)
> 	at org.jboss.ejb.client.ReceiverInterceptor.handleInvocationResult(ReceiverInterceptor.java:129)
> 	at org.jboss.ejb.client.EJBClientInvocationContext.getResult(EJBClientInvocationContext.java:262)
> 	at org.jboss.ejb.client.EJBClientInvocationContext.awaitResponse(EJBClientInvocationContext.java:437)
> 	at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:202)
> 	at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181)
> 	at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144)
> 	at com.sun.proxy.$Proxy4.validateVerificationCode(Unknown Source)
> 	... 13 more
> Caused by: an exception which occurred:
> 	in object of type com.intuism.core.settings.EmbeddedSettings
> 	in field defaultSettings
> 	in object of type com.intuism.ui.validation.Validation
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)



More information about the jboss-jira mailing list