All,

Velocity v1.7
openjdk version "16.0.2" 2021-07-20
OpenJDK Runtime Environment (build 16.0.2+7-67)
OpenJDK 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)

(Yes, I realize Velocity 1.7 is old but we haven't had time to evaluate 500+ templates for compatibility with later versions.)

I'm getting an error evaluating a template in a Java 16 VM. This template shows information about X.509 certificates.

This is the error:

Exception: org.apache.velocity.exception.VelocityException: ASTMethod.execute() : exception invoking method 'getSubjectAlternativeNames' in class sun.security.x509.X509CertImpl
Stack Trace:
org.apache.velocity.exception.VelocityException: ASTMethod.execute() : exception invoking method "getSubjectAlternativeNames" in class sun.security.x509.X509CertImpl
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:208)
at org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
[...]
Caused by:
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl cannot access class sun.security.x509.X509CertImpl (in module java.base) because module java.base does not export sun.security.x509 to unnamed module @ff8c08
jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:385)
[...]

My velocity code is just doing this:

#if($cert.subjectAlternativeNames)
.. print information about the SANs...
#end

I looked at my Java code and I'm getting all objects through standard interfaces; I'm not mucking-around in the sun.* namespaces or anything like that. The sun.security.x509.X509CertImpl class implements java.security.cert.X509Certificate which is a standard interface and the method java.security.cert.X509Certificate.getSubjectAlternativeNames is defined on that interface.

Is it possible that UberspectImpl is choosing the "class-defined method" over the "interface-defined method" when calling it, which is causing this problem?

Is there any way around this issue?

Thanks,
-chris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@velocity.apache.org
For additional commands, e-mail: user-h...@velocity.apache.org

Reply via email to