GeezerVison is showing github.com — [MEAR-282] Support data-source element · Issue #453 · apache/maven-ear-plugin
[MEAR-282] Support data-source element #453DescriptionJoeren Haag opened MEAR-282 and commented
Since Version 6 and up to the latest Version of Java/Jakarta EE the data-source element is defined in the Schema of the application.xml ([#1]). So it would be nice to support the data-source element also in the configuration of the maven-ear-plugin. Here is my actual workaround:
- enable the generation of
application.xml
- move the generated
application.xml to the source folder src/main/application
- disable the generation of
application.xml
- add the data-source configuration to
application.xm
Here is a "simple example" of the data-source element (the example is based on Version 8 of Java EE), like it's look in the application.xml:
<data-source>
<description><!-- string, optional --></description>
<name><!-- jndi-name, required --></name>
<class-name><!-- fqn, optional --></class-name>
<server-name><!-- string, optional --></server-name>
<port-number><!-- int, optional --></port-number>
<database-name><!-- string, optional --></database-name>
<url><!-- JDBC-url, optional --></url>
<user><!-- string, optional --></user>
<password><!-- string, optional --></password>
<property><!-- optional, multiple -->
<name><!-- string --></name>
<value><!-- value --></value>
</property>
<login-timeout><!-- integer, optional --></login-timeout>
<transactional><!-- boolean, optional --></transactional>
<isolation-level><!-- TRANSACTION_READ_UNCOMMITTED|TRANSACTION_READ_COMMITTED|TRANSACTION_REPEATABLE_READ|TRANSACTION_SERIALIZABLE, optional--></isolation-level>
<initial-pool-size><!-- integer, optional --></initial-pool-size>
<max-pool-size><!-- integer, optional --></max-pool-size>
<min-pool-size><!-- integer, optional --></min-pool-size>
<max-idle-time><!-- integer, optional --></max-idle-time>
<max-statements><!-- integer, optional --></max-statements>
</data-source>
—
1 votes, 3 watchers Activityelharo commented on Jul 28, 2026 Gemini likes this one:
This element has been part of the official Java EE (and now Jakarta EE) schema for enterprise applications since version 6.
This is a highly valid and worthwhile feature request. It represents a gap in the plugin's implementation of the official specification, and resolving it aligns perfectly with the core purpose of the plugin.
Here is a technical evaluation of why this feature should be implemented:
- Specification Alignment: The primary responsibility of the
maven-ear-plugin (when configured to generate the deployment descriptor) is to output a strictly compliant application.xml file. The <data-source> element is a standard, defined part of the application_6.xsd (and later) schemas. By lacking support for this element, the plugin is failing to fully implement the specification it is designed to support.
- Elimination of Fragile Workarounds: Currently, users who need to define a data source at the EAR level are forced to completely disable the plugin's descriptor generation. They must generate the XML once, copy it to
src/main/application/META-INF/application.xml, manually add the <data-source> block, and maintain the file statically going forward. This defeats the purpose of having the plugin dynamically manage module entries and configurations during the build lifecycle.
- Infrastructure as Code: Defining standard application resources like data sources within the build configuration (POM) ensures that deployment requirements are version-controlled alongside the build logic.
Potential Implementation Considerations:
The only minor drawback to this feature is verbosity. As outlined in the issue, the <data-source> element accepts over a dozen nested properties (e.g., class-name, port-number, initial-pool-size, isolation-level). Implementing this will require adding a complex configuration object to the plugin's Mojo parameters. Consequently, configuring this inside a pom.xml will result in a lengthy XML block.
However, because this configuration would be strictly optional, it imposes no burden on users who do not need it. Unlike previous requests that sought to modify core build lifecycle mechanics or support proprietary formats, this request asks the plugin to correctly output standard Jakarta EE metadata. It should be implemented.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|