Glassfish 7 support

232 views
Skip to first unread message

Hantsy Bai

unread,
May 1, 2022, 1:52:53 AM5/1/22
to Codehaus Cargo
Glassfish have released 7.0.0.M4 (beta stage), is there any plan to start a  new module for a Glassfish 7?

When I run `mvn clean  pacakge cargo:run` using the existing Glassfish 6 adapter to run Glassfish v7, and  got the following error.

Failed to execute goal org.codehaus.cargo:cargo-maven3-plugin:1.9.10:run (default-cli) on project jpa-examples: Failed resolving artifact: Failed to read artifact descriptor fo
r org.glassfish.main.distributions:glassfish:zip:7.0.0-M4: org.glassfish.tyrus:tyrus-bom:pom:2.1.0-M3 ...


Thanks.

Regards,
Hantsy

S. Ali Tokmen

unread,
May 1, 2022, 3:31:36 AM5/1/22
to codehau...@googlegroups.com

Hi Hantsy

Thanks for raising this!

The error you mention doesn't seem to be related to Codehaus Cargo, but rather to a missing dependency for the org.glassfish.main.distributions:glassfish artifact.

Could you perhaps try with a ZipUrlInstaller and point it to https://repo.maven.apache.org/maven2/org/glassfish/main/distributions/glassfish/7.0.0-M4/glassfish-7.0.0-M4.zip?

Regards

S. Ali Tokmen
https://ali.tokmen.com/
https://contact.ali.tokmen.com/
--
You received this message because you are subscribed to the Google Groups "Codehaus Cargo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codehaus-carg...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codehaus-cargo/93df5e69-8898-469e-a961-102547c10033n%40googlegroups.com.

Hantsy Bai

unread,
Jul 18, 2022, 10:27:42 PM7/18/22
to Codehaus Cargo
Hi Ali, this approach works well with M4, M6(only tried these two versions), but when upgrading to M7, I got the following error,

[INFO] [talledLocalContainer] remote failure: The jdbc resource [ jdbc/__default ] cannot be deleted as it is required to be configured in the system.
[INFO] [talledLocalContainer] Command delete-jdbc-resource failed.
[INFO] [talledLocalContainer] JDBC Connection pool DerbyPool deleted successfully
[INFO] [talledLocalContainer] Command delete-jdbc-connection-pool executed successfully.
[INFO] [talledLocalContainer] Command deploy failed.
[INFO] [talledLocalContainer] remote failure: Error occurred during deployment: Exception while preparing the app : Invalid resource : java:comp/DefaultDataSource__pm. Please see serve
r.log for more details.

[INFO] [talledLocalContainer] GlassFish 7.0.0.M7 is stopping...
[INFO] [talledLocalContainer] Waiting for the domain to stop .
[INFO] [talledLocalContainer] Command stop-domain executed successfully.
[INFO] [talledLocalContainer] GlassFish 7.0.0.M7 is stopped

And the the server is being stopped with no server log.

Regards,
Hantsy

S. Ali Tokmen

unread,
Jul 20, 2022, 5:04:42 AM7/20/22
to codehau...@googlegroups.com

Hi Hantsy

Thanks for this - I believe a dedicated GlassFish 7.x container is becoming a necessity, so I created https://codehaus-cargo.atlassian.net/browse/CARGO-1589 and pushed a first commit, which our continous Integration seems to be (mostly) happy with.

Would you mind following the instructions on https://codehaus-cargo.github.io/cargo/Maven+3+Plugin+Installation.html#Maven3PluginInstallation-snapshots (or building Codehaus Cargo 1.9.14-SNAPSHOT yourself) and trying out the new glassfish7x container?

hantsy bai

unread,
Jul 20, 2022, 9:33:09 AM7/20/22
to codehau...@googlegroups.com
Hi Ali,

Thanks for your work on adding support for Glassfish 7.0.

After added the repositories setting in my maven pom file, ran the following command

mvn clean package cargo:run -Dmaven.test.skip=true

and got the exception info.

[WARNING] The POM for org.codehaus.cargo:cargo-core-container-glassfish:jar:1.9.14-SNAPSHOT is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  30.317 s
[INFO] Finished at: 2022-07-20T21:27:12+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven3-plugin:1.9.14-SNAPSHOT:run (default-cli) on project rest-examples: Execution default-cli of goal org.codehaus.cargo:cargo-maven3-plugin:1.9.14-SNAPSHOT:run failed: Cannot create configuration. There's no registered configuration for the parameters (container [id = [glassfish7x], type = [installed]], configuration type [standalone]). Actually there are no valid types registered for this configuration. Maybe you've made a mistake spelling it? -> [Help 1]

But I checked the jars in the repository, it exists, not sure why it is not resolved by Maven.

---

Regards,

Hantsy Bai

Self-employed consultant, fullstack developer, agile coach, freelancer/remote worker

GitHub: https://github.com/hantsy

Twitter: https://twitter.com/@hantsy

Medium: https://medium.com/@hantsy


You received this message because you are subscribed to a topic in the Google Groups "Codehaus Cargo" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codehaus-cargo/43arWo7NyzQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codehaus-carg...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codehaus-cargo/6d39ff75-5ffe-a5c8-83f6-2c1187d79356%40alishomepage.com.

S. Ali Tokmen

unread,
Jul 20, 2022, 12:16:06 PM7/20/22
to codehau...@googlegroups.com

Hi Hantsy

Indeed, as explained on https://codehaus-cargo.github.io/cargo/Maven+3+Plugin+Installation.html#Maven3PluginInstallation-snapshots you should also execute:

mvn dependency:get -Dartifact=org.codehaus.cargo:cargo-core-container-glassfish:1.9.14-SNAPSHOT -DremoteRepositories=https://oss.sonatype.org/content/repositories/snapshots/

That'll ensure the GlassFish container's SNAPSHOT artifact is in your local repository.

hantsy bai

unread,
Jul 20, 2022, 9:59:00 PM7/20/22
to codehau...@googlegroups.com
Hi, Ali, thanks for your help.
But I got the same exception when switching to use glassfish7x, check config in my sample project: https://github.com/hantsy/jakartaee10-sandbox/blob/master/rest/pom.xml#L216

[INFO] --- cargo-maven3-plugin:1.9.14-SNAPSHOT:run (default-cli) @ rest-examples ---
[INFO] [en3.ContainerRunMojo] Resolved container artifact org.codehaus.cargo:cargo-core-container-glassfish:jar:1.9.14-SNAPSHOT for container glassfish7x
[INFO] [talledLocalContainer] Parsed GlassFish version = [7.0.0.M7]
[INFO] [talledLocalContainer] GlassFish 7.0.0.M7 starting...
[INFO] [talledLocalContainer] Using port 4848 for Admin.
[INFO] [talledLocalContainer] Using port 8080 for HTTP Instance.
[INFO] [talledLocalContainer] Using port 7676 for JMS.
[INFO] [talledLocalContainer] Using port 3700 for IIOP.
[INFO] [talledLocalContainer] Using port 8181 for HTTP_SSL.
[INFO] [talledLocalContainer] Using port 3820 for IIOP_SSL.
[INFO] [talledLocalContainer] Using port 3920 for IIOP_MUTUALAUTH.
[INFO] [talledLocalContainer] Using port 8686 for JMX_ADMIN.
[INFO] [talledLocalContainer] Using port 6666 for OSGI_SHELL.
[INFO] [talledLocalContainer] Using port 9009 for JAVA_DEBUGGER.
[INFO] [talledLocalContainer] Distinguished Name of the self-signed X.509 Server Certificate is:
[INFO] [talledLocalContainer] [CN=hantsy-t540p,OU=GlassFish,O=Eclipse.org Foundation Inc,L=Ottawa,ST=Ontario,C=CA]
[INFO] [talledLocalContainer] Distinguished Name of the self-signed X.509 Server Certificate is:
[INFO] [talledLocalContainer] [CN=hantsy-t540p-instance,OU=GlassFish,O=Eclipse.org Foundation Inc,L=Ottawa,ST=Ontario,C=CA]
[INFO] [talledLocalContainer] Domain cargo-domain created.
[INFO] [talledLocalContainer] Domain cargo-domain admin port is 4848.
[INFO] [talledLocalContainer] Domain cargo-domain allows admin login as user "admin" with no password.
[INFO] [talledLocalContainer] Command create-domain executed successfully.
[INFO] [talledLocalContainer] Attempting to start cargo-domain.... Please look at the server log for more details.....

[INFO] [talledLocalContainer] Command delete-jdbc-resource failed.
[INFO] [talledLocalContainer] remote failure: The jdbc resource [ jdbc/__default ] cannot be deleted as it is required to be configured in the system.
[INFO] [talledLocalContainer] JDBC Connection pool DerbyPool deleted successfully
[INFO] [talledLocalContainer] Command delete-jdbc-connection-pool executed successfully.
[INFO] [talledLocalContainer] Command deploy failed.
[INFO] [talledLocalContainer] remote failure: Error occurred during deployment: Exception while preparing the app : Invalid resource : java:comp/DefaultDataSource__pm. Please see server.log for more details.

[INFO] [talledLocalContainer] GlassFish 7.0.0.M7 is stopping...
[INFO] [talledLocalContainer] Waiting for the domain to stop .
[INFO] [talledLocalContainer] Command stop-domain executed successfully.
[INFO] [talledLocalContainer] GlassFish 7.0.0.M7 is stopped
[WARNING] [talledLocalContainer] org.codehaus.cargo.util.CargoException: At least one GlassFish deployment has failed: org.codehaus.cargo.util.CargoException: GlassFish admin command with args (--interactive=false --host localhost --port 4848 --user admin --passwordfile D:\hantsylabs\jakartaee10-sandbox\rest\target\glassfish7x-home\password.properties deploy --force --contextroot rest-examples D:\hantsylabs\jakartaee10-sandbox\rest\target\rest-examples.war) failed: asadmin exited 1
[ERROR] Starting container [org.codehaus.cargo.container.glassfish.GlassFish7xInstalledLocalContainer@55e5415d] failed
org.codehaus.cargo.util.CargoException: At least one GlassFish deployment has failed: org.codehaus.cargo.util.CargoException: GlassFish admin command with args (--interactive=false --host localhost --port 4848 --user admin --passwordfile D:\hantsylabs\jakartaee10-sandbox\rest\target\glassfish7x-home\password.properties deploy --force --contextroot rest-examples D:\hantsylabs\jakartaee10-sandbox\rest\target\rest-examples.war) failed: asadmin exited 1
    at org.codehaus.cargo.container.glassfish.internal.AbstractGlassFishInstalledLocalContainer.doStart (AbstractGlassFishInstalledLocalContainer.java:278)
    at org.codehaus.cargo.container.glassfish.GlassFish5xInstalledLocalContainer.doStart (GlassFish5xInstalledLocalContainer.java:62)
    at org.codehaus.cargo.container.spi.AbstractInstalledLocalContainer.startInternal (AbstractInstalledLocalContainer.java:320)
    at org.codehaus.cargo.container.glassfish.internal.AbstractGlassFishInstalledLocalContainer.startInternal (AbstractGlassFishInstalledLocalContainer.java:120)
    at org.codehaus.cargo.container.spi.AbstractLocalContainer.start (AbstractLocalContainer.java:229)
    at org.codehaus.cargo.maven3.ContainerStartMojo.executeLocalContainerAction (ContainerStartMojo.java:83)
    at org.codehaus.cargo.maven3.ContainerRunMojo.doExecute (ContainerRunMojo.java:95)
    at org.codehaus.cargo.maven3.AbstractCargoMojo.execute (AbstractCargoMojo.java:437)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
Caused by: org.codehaus.cargo.util.CargoException: GlassFish admin command with args (--interactive=false --host localhost --port 4848 --user admin --passwordfile D:\hantsylabs\jakartaee10-sandbox\rest\target\glassfish7x-home\password.properties deploy --force --contextroot rest-examples D:\hantsylabs\jakartaee10-sandbox\rest\target\rest-examples.war) failed: asadmin exited 1
    at org.codehaus.cargo.container.glassfish.internal.GlassFish3xAsAdmin.invokeAsAdmin (GlassFish3xAsAdmin.java:98)
    at org.codehaus.cargo.container.glassfish.internal.AbstractGlassFishInstalledLocalContainer.invokeAsAdmin (AbstractGlassFishInstalledLocalContainer.java:96)
    at org.codehaus.cargo.container.glassfish.internal.AbstractGlassFishInstalledLocalContainer.invokeAsAdmin (AbstractGlassFishInstalledLocalContainer.java:69)
    at org.codehaus.cargo.container.glassfish.GlassFish3xInstalledLocalDeployer.doDeploy (GlassFish3xInstalledLocalDeployer.java:122)
    at org.codehaus.cargo.container.glassfish.internal.AbstractGlassFishInstalledLocalDeployer.redeploy (AbstractGlassFishInstalledLocalDeployer.java:99)
    at org.codehaus.cargo.container.glassfish.internal.AbstractGlassFishInstalledLocalContainer.doStart (AbstractGlassFishInstalledLocalContainer.java:259)
    at org.codehaus.cargo.container.glassfish.GlassFish5xInstalledLocalContainer.doStart (GlassFish5xInstalledLocalContainer.java:62)
    at org.codehaus.cargo.container.spi.AbstractInstalledLocalContainer.startInternal (AbstractInstalledLocalContainer.java:320)
    at org.codehaus.cargo.container.glassfish.internal.AbstractGlassFishInstalledLocalContainer.startInternal (AbstractGlassFishInstalledLocalContainer.java:120)
    at org.codehaus.cargo.container.spi.AbstractLocalContainer.start (AbstractLocalContainer.java:229)
    at org.codehaus.cargo.maven3.ContainerStartMojo.executeLocalContainerAction (ContainerStartMojo.java:83)
    at org.codehaus.cargo.maven3.ContainerRunMojo.doExecute (ContainerRunMojo.java:95)
    at org.codehaus.cargo.maven3.AbstractCargoMojo.execute (AbstractCargoMojo.java:437)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:370)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:351)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:171)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:163)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:294)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:960)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:293)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:196)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:568)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
[INFO] Press Ctrl-C to stop the container...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:44 min
[INFO] Finished at: 2022-07-21T09:53:33+08:00
---

Regards,

Hantsy Bai

Self-employed consultant, fullstack developer, agile coach, freelancer/remote worker

GitHub: https://github.com/hantsy

Twitter: https://twitter.com/@hantsy

Medium: https://medium.com/@hantsy

S. Ali Tokmen

unread,
Jul 21, 2022, 7:25:50 AM7/21/22
to codehau...@googlegroups.com

Hi Hantsy

Looking at the error message, Exception while preparing the app : Invalid resource : java:comp/DefaultDataSource__pm, there is perhaps an issue when Codehaus Cargo removes the default datasource. Could you try setting cargo.glassfish.removeDefaultDatasource to false to check?

hantsy bai

unread,
Jul 21, 2022, 10:19:29 AM7/21/22
to codehau...@googlegroups.com
Yeah, it seems to be working. But
1. I think it should be working using the default settings.
2. is there an option to start the built-in derby database, I found there is a connection error on port 1527

 Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: java.net.ConnectException :
 Error connecting to server localhost on port 1,527 with message Connection refused: connect.
[INFO] [talledLocalContainer] Error Code: 0. Please see server.log for more details.
 

---

Regards,

Hantsy Bai

Self-employed consultant, fullstack developer, agile coach, freelancer/remote worker

GitHub: https://github.com/hantsy

Twitter: https://twitter.com/@hantsy

Medium: https://medium.com/@hantsy

S. Ali Tokmen

unread,
Jul 22, 2022, 5:15:16 AM7/22/22
to codehau...@googlegroups.com

Hi Hantsy

It of course should work with the default settings - We have a very special situation here that the Codehaus Cargo GlassFish 7.x container doesn't exist yet, and hence would have the opportunity to create it in a way that it will work with the default settings 😁

May I know, where did you see the JDNI name java:comp/DefaultDataSource referenced? In previous versions, I thought the name was jdbc/__default, and perhaps to make it work with a different name you simply would need to add the configuration for creating a datasource (you can also check our DataSource Definition Archetype as an example for Maven 3).

S. Ali Tokmen

unread,
Jul 22, 2022, 6:41:15 AM7/22/22
to codehau...@googlegroups.com

Hi Hantsy

It of course should work with the default settings - We have a very special situation here that the Codehaus Cargo GlassFish 7.x container doesn't exist yet, and hence would have the opportunity to create it in a way that it will work with the default settings 😁

May I know, where did you see the JDNI name java:comp/DefaultDataSource referenced? In previous versions, I thought the name was jdbc/__default, and perhaps to make it work with a different name you simply would need to add the configuration for creating a datasource (you can also check our DataSource Definition Archetype as an example for Maven 3).

Regards

hantsy bai

unread,
Jul 22, 2022, 9:41:27 AM7/22/22
to codehau...@googlegroups.com
Hi Ali,


And since Java EE7, every application server should support the default resources, including a datasource( java:comp/DefaultDataSourc ), jms connection factory( java:comp/DefaultJMSConnectionFactory ), executorservice etc. It is defined in the Java EE spec.

When creating a new domain by asadmin, it should create these resources by default. But Glassfish requires a standalone command `asadmin start-database` to start the built-in derby database.

---

Regards,

Hantsy Bai

Self-employed consultant, fullstack developer, agile coach, freelancer/remote worker

GitHub: https://github.com/hantsy

Twitter: https://twitter.com/@hantsy

Medium: https://medium.com/@hantsy

--
You received this message because you are subscribed to a topic in the Google Groups "Codehaus Cargo" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/codehaus-cargo/43arWo7NyzQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to codehaus-carg...@googlegroups.com.

S. Ali Tokmen

unread,
Jul 24, 2022, 4:28:18 AM7/24/22
to codehau...@googlegroups.com

Hi Hantsy

Thanks for the hint - This explains quite some things!

The "problem" with the database GlassFish tries to have by default is that it wants to listen remotely, and hence a port number would be required, and must be made available. It would be very complex to guarantee that in a "generic" environment.

May I suggest, that you add a default embedded datasource instead? Here's what we have in our archetype:

<datasources>
  <datasource>
    <driverClass>org.apache.derby.jdbc.EmbeddedDriver</driverClass>
    <url>jdbc:derby:derbyDB;create=true</url>
    <jndiName>jdbc/CargoDS</jndiName>
    <username>APP</username>
    <password>nonemptypassword</password>
  </datasource>
</datasources>

Once you add such a datasource, as per GlassFish5xInstalledLocalContainer.java#L74 onwards, it will be marked as default. The embedded Derby driver has the advantage that it won't have any port number requirements, as it is purely local.

You received this message because you are subscribed to the Google Groups "Codehaus Cargo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codehaus-carg...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/codehaus-cargo/CAMq3Qk1TQ0A8AQp2bztQj8FZdryfWiGQYdwVp-ZoV8wJZ%3DmPwg%40mail.gmail.com.

hantsy bai

unread,
Jul 24, 2022, 10:27:27 AM7/24/22
to codehau...@googlegroups.com
I understand the solution now, but how to fix the problem when using Glassfish 7.0.0-M7,
in the XXInstalledLocalContainer, create a  `java:comp/DefaultDatasource` instead of the `jdbc/__default` there?

---

Regards,

Hantsy Bai

Self-employed consultant, fullstack developer, agile coach, freelancer/remote worker

GitHub: https://github.com/hantsy

Twitter: https://twitter.com/@hantsy

Medium: https://medium.com/@hantsy


S. Ali Tokmen

unread,
Jul 25, 2022, 2:05:10 AM7/25/22
to codehau...@googlegroups.com

Hi Hantsy

You indeed simply need to:

  1. Leave cargo.glassfish.removeDefaultDatasource as true (the default)
  2. Add a local datasource:


  1. <datasources>
      <datasource>
        <driverClass>org.apache.derby.jdbc.EmbeddedDriver</driverClass>
        <url>jdbc:derby:derbyDB;create=true</url>
        <jndiName>jdbc/CargoDS</jndiName>
        <username>APP</username>
        <password>nonemptypassword</password>
      </datasource>
    </datasources>

You can try different jndiName to make it work.

hantsy bai

unread,
Jul 25, 2022, 10:56:48 PM7/25/22
to codehau...@googlegroups.com
Hi Ali,  I have tried to add the datasource config like this.

<datasources>
<datasource>
<driverClass>org.apache.derby.jdbc.EmbeddedDriver</driverClass>
<url>jdbc:derby:derbyDB;create=true</url>
        <jndiName>java:comp/DefaultDataSource</jndiName>
        <username>APP</username>
<password>nonemptypassword</password>
</datasource>
</datasources>

But encountered an exception like this.
[INFO] [talledLocalContainer] Command create-jdbc-resource failed.
[INFO] [talledLocalContainer] remote failure: Command create-jdbc-resource failed. Constraints for this JdbcResource configuration have been violated: on property [  ] violation reason
 [ resource name cannot contain ':' character ]
[INFO] [talledLocalContainer] Constraints for this JdbcResource configuration have been violated: on property [  ] violation reason [ resource name cannot contain ':' character ]

[INFO] [talledLocalContainer] GlassFish 7.0.0.M7 is stopping...

I  am not sure if it is caused by the jdniName here. Glassfish and WildFly use a prefix(namespace) when looking up Jndi, but IBM OpenLiberty always rejects using this.


---

Regards,

Hantsy Bai

Self-employed consultant, fullstack developer, agile coach, freelancer/remote worker

GitHub: https://github.com/hantsy

Twitter: https://twitter.com/@hantsy

Medium: https://medium.com/@hantsy

hantsy bai

unread,
Jul 25, 2022, 11:01:44 PM7/25/22
to codehau...@googlegroups.com
If I chanted the jdniName to DefaultDataSource, the create-jdbc-resource is successful, but I got the previous exception like this.

INFO] [talledLocalContainer] Command create-jdbc-connection-pool executed successfully.
[INFO] [talledLocalContainer] JDBC resource DefaultDataSource created successfully.
[INFO] [talledLocalContainer] Command create-jdbc-resource executed successfully.

[INFO] [talledLocalContainer] Command deploy failed.
[INFO] [talledLocalContainer] remote failure: Error occurred during deployment: Exception while preparing the app : Invalid resource : java:comp/DefaultDataSource__pm. Please see serve
r.log for more details.
[INFO] [talledLocalContainer] GlassFish 7.0.0.M7 is stopping...
---

Regards,

Hantsy Bai

Self-employed consultant, fullstack developer, agile coach, freelancer/remote worker

GitHub: https://github.com/hantsy

Twitter: https://twitter.com/@hantsy

Medium: https://medium.com/@hantsy

S. Ali Tokmen

unread,
Jul 26, 2022, 12:05:22 AM7/26/22
to codehau...@googlegroups.com

Hi Hantsy

As per https://github.com/eclipse-ee4j/glassfish/issues/19187, I believe jndiname should be jdbc/__default, could you try that please?

Hantsy Bai

unread,
Nov 6, 2022, 2:01:43 AM11/6/22
to Codehaus Cargo
Hi Ali,  long time not contacted.

Today I tried to refresh my example projects,  still encountered the issues of DataSource.


Updated to Cargo 1.10.3, Glassfish 7.0.0.M9.  Part of Jakarta EE spec, there is a built-in DataSource can be looked up by JNDI:  java:comp/DefaultDataSource

<profile>
<id>glassfish</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<cargo.zipUrlInstaller.downloadDir>${project.basedir}/../installs</cargo.zipUrlInstaller.downloadDir>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven3-plugin</artifactId>
<configuration>
<container>
<containerId>glassfish7x</containerId>
<!-- <artifactInstaller>
<groupId>org.glassfish.main.distributions</groupId>
<artifactId>glassfish</artifactId>
<version>${glassfish.version}</version>
</artifactInstaller> -->
<zipUrlInstaller>
<url>https://github.com/eclipse-ee4j/glassfish/releases/download/${glassfish.version}/glassfish-${glassfish.version}.zip</url>
<downloadDir>${cargo.zipUrlInstaller.downloadDir}</downloadDir>
</zipUrlInstaller>
</container>
<configuration>
<!-- the configuration used to deploy -->
<home>${project.build.directory}/glassfish7x-home</home>
<properties>
<cargo.remote.password></cargo.remote.password>
<cargo.glassfish.removeDefaultDatasource>true</cargo.glassfish.removeDefaultDatasource>
</properties>
<datasources>
<datasource>
<driverClass>org.apache.derby.jdbc.EmbeddedDriver</driverClass>
<url>jdbc:derby:derbyDB;create=true</url>
<jndiName>jdbc/__default</jndiName>
<username>APP</username>
<password>nonemptypassword</password>
</datasource>
</datasources>
</configuration>
</configuration>
</plugin>
</plugins>
</build>
</profile>

If I do not create a DataSource in the above config, it will report resource java:comp/DefaultDataSource__pm is not exited. Here, what I setup is java:comp/DefaultDataSource

As suggested before,  I added the custom DataSource like above, this also failed because an error like this: Caused by: org.codehaus.cargo.util.CargoException: GlassFish admin command with args (--interactive=false --host localhost --port 4848 --user admin --passwordfile D:\hantsylabs\jakarta
ee10-sandbox\jpa\target\glassfish7x-home\password.properties create-jdbc-resource --connectionpoolid cargo-datasource-DummyCargoDefaultDS-__default jdbc/__default) failed: asadmin exit
ed 1: remote failure: A JdbcResource by name jdbc/__default already exists with resource-ref in target server.
Command create-jdbc-resource failed.

But I added  wildfly maven plugin config, deploy to WildFly is working well.
mvn clean wildfly:run -Pwildfly -DskipTests -D"maven.skip.test=true"

And manually deploy to Glassfish 7.0.0 M9 is also working well.
1. Package project  into a war.
2. Start Glassfish and Derby by asadmin command.
3. Copy war file to domain1/autodeploy folder.
4.  Open server.log, there is no exception of the above DataSource.
5. Curl command to get the correct result. curl http://localhost:8080/jpa-examples/rest/persons

I am not sure what is wrong in my configuration of the cargo plugin for Glassfish v7.

S. Ali Tokmen

unread,
Nov 6, 2022, 5:17:57 AM11/6/22
to codehau...@googlegroups.com

Hi Hantsy

Long time indeed! Thanks for checking in.

Indeed, it looks like we do enforce the first datasource to always get deployed as a "new default", hence the error below.

With the current version, the only workaorund would be to change the JNDI name. The Codehaus Cargo Glassfish container will then deploy it twice, once as default and another time with the second name.

I also checked in https://github.com/codehaus-cargo/cargo/commit/df815626549d92b7533e6beedd41008e11a89788 to fix this, once https://semaphoreci.com/codehaus-cargo/cargo/branches/master/builds/1399 completes you can use the latest SNAPSHOT. To do so:

  1. In the pom.xml, change the cargo-maven3-plugin version to 1.10.4-SNAPSHOT
  2. Run the below two commands:
    1. mvn dependency:get -Dartifact=org.codehaus.cargo:cargo-core-container-glassfish:1.10.4-SNAPSHOT -DremoteRepositories=https://oss.sonatype.org/content/repositories/snapshots/
    2. mvn dependency:get -Dartifact=org.codehaus.cargo:cargo-maven3-plugin:1.10.4-SNAPSHOT -DremoteRepositories=https://oss.sonatype.org/content/repositories/snapshots/

hantsy bai

unread,
Nov 6, 2022, 8:15:05 AM11/6/22
to codehau...@googlegroups.com
Great work, it fixes the issue.

---

Regards,

Hantsy Bai

Self-employed consultant, fullstack developer, agile coach, freelancer/remote worker

GitHub: https://github.com/hantsy

Twitter: https://twitter.com/@hantsy

Medium: https://medium.com/@hantsy

Reply all
Reply to author
Forward
0 new messages