Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UCP integration needs native image configuration #8436

Open
ljnelson opened this issue Feb 28, 2024 · 0 comments
Open

UCP integration needs native image configuration #8436

ljnelson opened this issue Feb 28, 2024 · 0 comments
Assignees

Comments

@ljnelson
Copy link
Member

ljnelson commented Feb 28, 2024

The UCP integration needs native image configuration.

Specifically, it needs (in src/main/resources/META-INF/native-image/com.oracle.database.jdbc/ucp/native-image.properties (following the documented resource layout convention):

# (Ideally the ucp stuff would be in the UCP codebase itself.)
# The reflection configuration is just to indicate the need; Helidon seems to have
# varying ways of including this information and I'm not sure which is preferred. The 
# following certainly works following native image's documentation and involves no
# special Helidon sauce or magic.
Args=--initialize-at-build-time=oracle.ucp.logging.annotations \
     -H:ReflectionConfigurationResources=${.}/reflect-config.json

# Works around a native image builder bug that causes the Feature present in the required
# Oracle database driver (required even if you don't use it, because UCP is tightly coupled
# to it) to crash in certain cases with an IllegalAccessError. Ideally the Feature would
# be fixed, or this option would be present in the Oracle database driver jar.
JavaArgs=--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.configure=ALL-UNNAMED

And therefore it also needs, at a minimum (in src/main/resources/META-INF/native-image/com.oracle.database.jdbc/ucp/reflect-config.json or similar depending on Helidon convention):

[
    {
        "name" : "oracle.ucp.jdbc.PoolDataSourceImpl",
        "allPublicMethods" : true
    },
    {
        "name" : "oracle.ucp.jdbc.PoolXADataSourceImpl",
        "allPublicMethods" : true
    }
]

This is because the JDBC specification mandates Java Beans-style reflective configuration for DataSource implementations.

Then it needs src/main/resources/META-INF/helidon/native-image/weld-proxies.json, apparently, with exactly these contents (i.e. even though, for example, PoolDataSourceImpl.class is among the bean types of PoolDataSourceImpl.class, for some reason it must not appear in the ifaces array, and because the beans are added synthetically the bean class is the class of the portable extension adding them):

[
    {
        "bean-class": "io.helidon.integrations.datasource.ucp.cdi.UCPBackedDataSourceExtension",
        "ifaces": [
            "java.io.Serializable",
            "java.sql.Wrapper",
            "javax.naming.Referenceable",
            "javax.naming.spi.ObjectFactory",
            "javax.sql.CommonDataSource",
            "javax.sql.DataSource",
            "oracle.ucp.jdbc.PoolDataSource",
            "oracle.ucp.UniversalConnectionPoolAdapter"
        ]
    },
    {
        "bean-class": "io.helidon.integrations.datasource.ucp.cdi.UCPBackedDataSourceExtension",
        "ifaces": [
            "java.io.Serializable",
            "java.sql.Wrapper",
            "javax.naming.Referenceable",
            "javax.naming.spi.ObjectFactory",
            "javax.sql.CommonDataSource",
            "javax.sql.DataSource",
            "javax.sql.XADataSource",
            "oracle.ucp.jdbc.PoolDataSource",
            "oracle.ucp.jdbc.PoolXADataSource",
            "oracle.ucp.UniversalConnectionPoolAdapter"
        ]
    }
]

Any given application, of course, must also configure their preferred driver for reflection as well but that kind of information does not belong here, I don't think, even though we could guard some of it with the conditional reachability constructs offered by the schema.

See also #8199.

@ljnelson ljnelson added enhancement New feature or request MP P2 jpa/jta native-image integration java Pull requests that update Java code 4.x Version 4.x labels Feb 28, 2024
@ljnelson ljnelson self-assigned this Feb 28, 2024
@ljnelson ljnelson removed the java Pull requests that update Java code label Feb 28, 2024
@m0mus m0mus added this to Backlog Aug 12, 2024
@m0mus m0mus moved this to In Progress in Backlog Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

1 participant