Exception Handling for JDK 21
With JDK21, to control a set of object factory classes, the properties jdk.jndi.object.factoriesFilter and jdk.jndi.ldap.object.factoriesFilter are introduced for javax.naming package. These object factory classes are allowed to instantiate objects from the object references. After JDK21 update, during context look-up, you may see an exception as below:
Exception in thread "main" java.lang.ClassCastException: class javax.naming.Reference cannot be cast to class jakarta.resource.cci.ConnectionFactory (javax.naming.Reference is in module java.naming of loader 'bootstrap'; jakarta.resource.cci.ConnectionFactory is in unnamed module of loader 'app')
To handle this exception, set appropriate factory in the jdk.jndi.object.factoriesFilter and jdk.jndi.ldap.object.factoriesFilter properties. For example, System.setProperty("jdk.jndi.ldap.object.factoriesFilter", "com.infoengine.connector.IeConnectionFactoryFactory"). For reference, see Example Standalone Java SOAP Client.
War dies hilfreich?