How to fix the dependencies of a Maven JavaFX project ? (VsCode) - json

I have tried several ways to make the UI of a board game and JavaFX seems to be easiest option. So I created a new Java project using Maven in VsCode with a JavaFX archetype. But now that I copied my java files and Maven dependencies, it seems that there are conflicts with some libraries. I get errors like :
"The package javax.swing is not accessibleJava(268436910)", or
"The type com.fasterxml.jackson.databind.ObjectMapper is not accessibleJava(16778666)"
Here is my pom.xml :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.monopoly</groupId>
<artifactId>monopoly</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>19</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>19</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.11.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.11.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.monopoly.App</mainClass>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I haven't modified my files to use javafx yet, so some libraries will be replaced, but others won't, such as Json libraries. In any case, I hope it can help someone in the same situation.
I looked for version conflicts, but mvn dependency:tree is successful :
[INFO] -----------------------< com.monopoly:monopoly >------------------------
[INFO] Building monopoly 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # monopoly ---
[INFO] com.monopoly:monopoly:jar:1.0
[INFO] +- org.openjfx:javafx-controls:jar:19:compile
[INFO] | +- org.openjfx:javafx-controls:jar:win:19:compile
[INFO] | \- org.openjfx:javafx-graphics:jar:19:compile
[INFO] | +- org.openjfx:javafx-graphics:jar:win:19:compile
[INFO] | \- org.openjfx:javafx-base:jar:19:compile
[INFO] | \- org.openjfx:javafx-base:jar:win:19:compile
[INFO] +- org.openjfx:javafx-fxml:jar:19:compile
[INFO] | \- org.openjfx:javafx-fxml:jar:win:19:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.11.3:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-core:jar:2.11.3:compile
[INFO] \- com.fasterxml.jackson.core:jackson-annotations:jar:2.11.3:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
I also looked for answers on the net but that's a very specific topic, so haven't found anything yet. That's why I'm asking you guys. I'm not very experienced so I hope I gave enough information

Sorry if I'm late to answer, I forgot to post this. I found the answer with the help of #jewelsea. I was missing these lines in my module-info.java :
requires com.fasterxml.jackson.databind;
opens com.monopoly to javafx.fxml, com.fasterxml.jackson.databind;

Related

Cannot connect to database with flyway through Maven

I am trying to setup flyway for a project with maven and i am unable to make it work. I have the correct configuration (db url, username, password) and i tried connecting to the DB with MySQL Workbench, PhPMyAdmin and also used the flyway command line tool and everything works except maven.
This is the error i am getting:
[ERROR] Failed to execute goal org.flywaydb:flyway-maven-plugin:8.5.5:migrate (default-cli) on project flyway-fitinpulse: org.flywaydb.core.api.FlywayException: No database found to handle jdbc:mariadb://placeholderip:3306/db_name -> [Help 1]
And my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.fitinpulse</groupId>
<artifactId>flyway-fitinpulse</artifactId>
<version>1.0.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<configuration>
<url>jdbc:mariadb://placeholderip:3306/db_name</url>
<user>user</user>
<password>password</password>
</configuration>
</plugin>
</plugins>
</build>
Does anyone has any insight?
Have you tried adding <driver> </driver>
inside <configuration>?
Because otherwise the driver is auto-detected based on the url and this might lead to a connection problem I guess.
I finally found the problem. In newer version of the flyway for mysql you need to provide another flyway dependency along with the connection driver:
<dependencies>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-mysql</artifactId>
<version>8.5.5</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.0.4</version>
</dependency>
</dependencies>

Maven Web Application not deploying when Primefaces library is added [duplicate]

I am adopting Jakarta EE 9 and developing an EE application with EJB and WEB modules. EJB is already done and deployed on Glassfish 6 (RI implementation for Jakarta EE 9 ).
Now I want to develop web app with Primefaces as part of the same EAR and deploy the EAR on GF 6.
First Question :
Then I supposed the unique Primefaces version I can use is 10.0.RC2 because this is the first release supporting JSF 3.0 ( part of Jakarta EE 9 ) , I am right ?
Second Question :
If I'm not right , can I use Primefaces 8.0 for example ? I think no ,because this version need JSF 2.3 implementation .
Anyway , I am using the firs solution PF 10 as reported in the pom ,below but got the error :
java.lang.IllegalArgumentException: java.lang.NoClassDefFoundError: javax/servlet/ServletRequestListener
Question 3 :
Then, why PF 10 request for javax packages ?
THe web pom is :
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>HB</artifactId>
<groupId>savino.hb</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>savino.hb</groupId>
<artifactId>HB-Web</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>HB-Web-1.0</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.platform</groupId>
<artifactId>jakarta.jakartaee-api</artifactId>
<version>9.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>10.0.0-RC2</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
UPDATE : seeing inside PF10 jar I see :
package org.primefaces.application.resource;
import java.util.List;
import javax.faces.context.FacesContext;
import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
import org.primefaces.util.Lazy;
import org.primefaces.util.ResourceUtils;
public class DynamicResourcesPhaseListener implements PhaseListener {
Then PF 10 using still JSF 2.0 ? PF site decalre compatibility with JSF 3.0 !
You are using the wrong JAR try this Jakarta version of PF 11.
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>11.0.0</version>
<classifier>jakarta</classifier>
</dependency>

SQLException: no suitable driver found for jdbc:mysql between two maven projects

I've 2 maven projects in my Eclipse (v4.7.0) workspace.
The first project contains some utility stuffs and holds the connection to my MySQL database through JDBC driver.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>dbtools</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DBTools</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- JDBC for MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.3</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
</dependencies>
</project>
This first project is built as a jar and it is included in the second project (that contains the main application) as a maven dependency as shown in the pom.xml below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>mainapp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>MainApp</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jersey2.version>2.25.1</jersey2.version>
<jaxrs.version>2.0.1</jaxrs.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6.1</version>
<configuration>
<filesets>
<fileset>
<directory>C:/apps/tomcat/webapps/mainapp</directory>
<includes>
<include>**</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-appCtx</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>C:/apps/tomcat/webapps/</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>../mainapp/target</directory>
<includes>
<include>mainapp-0.0.1-SNAPSHOT.war</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- JAX-RS -->
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>${jaxrs.version}</version>
</dependency>
<!-- Jersey 2.25.1 -->
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey2.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey2.version}</version>
</dependency>
<!-- Local DBTool -->
<dependency>
<groupId>com.example</groupId>
<artifactId>dbtools</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
The 2nd project that is the main application is deployed as a war file.
When I start the Tomcat (with 2nd app's war) I got a SQLException at runtime:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/mydb?autoReconnect=true&useSSL=false
at java.sql.DriverManager.getConnection(DriverManager.java:689)
I've read several question here in StackOverflow about this exception but I still haven't found a working solution :(
Inside the lib folder of my Tomcat installation folder I've placed the mysql-connector-java-6.0.6.jar.
I've also noticed that in the JAR file of the first project (opening it as an archive) there isn't the JDBC connector inside. Is it normal?
Inside the first project, I make the connection this way:
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/torre?autoReconnect=true&useSSL=false", "dbuser", "dbpass");
conn has type java.sql.Connection.
I've also tried to put:
Class.forName("com.mysql.jdbc.Driver");
before che "conn = ..." line but I got the same result :(
I'm using Tomcat 8.5 and JDK 1.8.
Any ideas how I can get rid of this problem?
Am I missing something in the Maven or Eclipse build configuration?
Thanks in advance for your help! :)
First of all get familiar with auto-class loading for JDBC 4.0 here.
Now, see contents of META-INF/services/java.sql.Driver which is com.mysql.cj.jdbc.Driver. Thus you are getting the exception.
Please update the mysql connector dependency of project1 to below
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.41</version>
</dependency>
This will be automatically included in WEB-INF/lib of project2 thro' transitive dependency. Thus you do not need to include it in tomcat lib.
Remove the 6.0.6 mysql connector from the tomcat lib.
If still the issue persist, please try to register it explicitly before acquiring the connection
Class.forName("com.mysql.jdbc.Driver");
Providing input as per my understanding
you mentioned that
I've also noticed that in the JAR file of the first project (opening
it as an archive) there isn't the JDBC connector inside. Is it normal?
when you are building jar unlike war you will not find the dependencies[only one jar without maven-shade-plugin where it will not have its dependencies]
so use maven-shaded-plugin
https://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.yourpackage.YourClass</Main-Class>
<X-Compile-Source-JDK>${maven.compile.source}</X-Compile-Source-JDK>
<X-Compile-Target-JDK>${maven.compile.target}</X-Compile-Target-JDK>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
...
</project>
in your pom.xml [of project-1 for generating jar]
Now if you see u will be having two jars after maven build (one the original and the other jar with dependencies in pom)
if you extract the one which is having more size[the one with dependencies]
u can find the jdbc jar here
now for project 2
when you include project-1 as a dependency [make sure the one which is bigger is included instead of smaller one(without dependencies) ]
If you are using remote repository when u are pushing , the bigger one will get pushed
so when u mention it in pom [project-1] then the bigger jar will be downloaded
once after building it check the project-1 jar whether it is having its own dependencies
And finally build the war and deploy
Source : Worked on the same kind of Scenario, and it looks similar to the one I worked before
Let me know the result [Mostly it will work, if not mycontact :es12b1005#iith.ac.in will try to help]
Thanks :)

Error when pushing changes to openshift project

when I tried to push some changes in open shift project I got this error when trying to build the project:
remote: Found pom.xml... attempting to build with 'mvn --global-settings /var/lib/openshift/531f20d5500446fb69000112/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml clean package -Popenshift -DskipTests'
remote: [INFO] Scanning for projects...
remote: [INFO]
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Building radwan02 1.0
remote: [INFO] ------------------------------------------------------------------------
remote: [WARNING] The POM for org.apache.maven.plugins:maven-clean-plugin:jar:2.4.1 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] BUILD FAILURE
remote: [INFO] ------------------------------------------------------------------------
remote: [INFO] Total time: 0.292s
remote: [INFO] Finished at: Sat May 03 09:58:48 EDT 2014
remote: [INFO] Final Memory: 3M/78M
remote: [INFO] ------------------------------------------------------------------------
remote: [ERROR] Failed to parse plugin descriptor for org.apache.maven.plugins:maven-clean-plugin:2.4.1 (/var/lib/openshift/531f20d5500446fb69000112/.m2/repository/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar): zip file is empty -> [Help 1]
remote: [ERROR]
remote: [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
remote: [ERROR] Re-run Maven using the -X switch to enable full debug logging.
remote: [ERROR]
remote: [ERROR] For more information about the errors and possible solutions, please read the following articles:
remote: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginDescriptorParsingException
remote: An error occurred executing 'gear postreceive' (exit code: 1)
remote: Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/531f20d5500446fb69000112/jbossews
after that the project status is "Building" and after I restart the project manually the changes I made didn't apply on the server.
Here's the pom file (I didn't change anything):
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>radwan02</groupId>
<artifactId>radwan02</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>radwan02</name>
<repositories>
<repository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
</dependencies>
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'webapps'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<finalName>radwan02</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<outputDirectory>webapps</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
I use jBoss Developer Studo under windows 7, and JDK 1.7 64 bit
I just created a new Tomcat 7 application and the build finished without any error. There are couple of solutions:
Create a new application and push the changes again. Just in case there was some issue with that gear.
Create an empty file called force_clean_build inside your existing application .openshift/markers directory. Commit the file and push the changes. This will remove the .m2 repository and download all the dependencies and plugins again.

How to deploy mysql datasource using jboss-as-maven-plugin

This question is here to give an answer to once i find a solution, I have found documentation on Postgresql and H2 databases from the jboss website and have seen how it is done manually through this website, however I cannot seem to find much information on how to deploy a mysql datasource using the jboss-as-maven-plugin.
What is the minimum configuration properties required to properly register a mysql datasource with jboss-as 7 server through their maven plugin?
I have this dependency:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
And this configuration for the maven plugin
<build>
<plugins>
...
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<configuration>
<execute-commands/>
<executeCommands/>
<properties>
<enable-welcome-root>false</enable-welcome-root>
</properties>
</configuration>
<executions>
...
<!-- deploy the mysql connectorj -->
<execution>
<id>deploy-mysql-driver</id>
<phase>install</phase>
<goals>
<goal>deploy-artifact</goal>
</goals>
<configuration>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<name>mysql.jar</name>
</configuration>
</execution>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
<execution>
<id>add-datasource</id>
<phase>deploy</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<address>subsystem=datasources</address>
<resources>
<resource>
<address>xa-data-source=java:global/datasources/tncDS</address>
<enable-resource>true</enable-resource>
<properties>
<jndi-name>java:jboss/datasources/tncDS</jndi-name>
<enabled>true</enabled>
<connection-url>jdbc:mysql://localhost:3306/tnc</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-name>mysql.jar</driver-name>
</properties>
</resource>
</resources>
</configuration>
</execution>
</executions>
...
</plugin>
</plugins>
</build>
running the command mvn jboss-as:run causes this error:
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.241s
[INFO] Finished at: Tue Sep 24 21:37:28 EST 2013
[INFO] Final Memory: 16M/308M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jboss.as.plugins:jboss-as-maven-plugin:7.4.Final:deploy-artifact (deploy-mysql-driver) on project ear: Could not execute goal deploy-artifact on null. Reason: I/O Error could not execute operation '{
[ERROR] "address" => [],
[ERROR] "operation" => "read-attribute",
[ERROR] "name" => "launch-type"
[ERROR] }': java.net.ConnectException: JBAS012144: Could not connect to remote://localhost:9999. The connection timed out
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
UPDATE:
I have developed a plugin that injects the required file (META-INF/services/java.sql.Driver) into the jar before deployment:
<plugin>
<groupId>com.thenaglecode</groupId>
<artifactId>mysql-jdbc-compliance-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<configuration>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
</configuration>
<executions>
<execution>
<goals>
<goal>modify-connector</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
However i'm still getting could not connect to remote message. Is there a step that i'm missing or doing in the wrong sequence as i understand that the run command should start up the server.
UPDATE 2:
After some fiddling and reading of the jboss-as plugin website, I realized that the jboss-as:run goal also invokes the package phase. I was mostly receiving this error when I tried to run any of the deploying goals bound to the package phase.
Anything that needs to be deployed should be bound to the install phase.
I am now getting a seperate error regarding my persistence unit not existing
The problem is the MySQL driver is not JDBC 4 compliant. You need to add a META-INF/services/java.sql.Driver file to the JAR with the fully qualified JDBC driver class name or install it as a module. See https://community.jboss.org/wiki/DataSourceConfigurationInAS7 for more details.
solution here:
conf : jboss as7, maven 3.3.3, mysql java connector 5.1.29 28 27 26...,
starting from mysql java connector 5.1.30, the file Meta-INF/serivces/java.sql.driver contain this line "com.mysql.jdbc.Driver
com.mysql.fabric.jdbc.FabricMySQLDriver", if I change it to "com.mysql.jdbc.Driver" the datasource is created and the project deployed fine.
with mysql java connector 5.1.29 28 27 26 ..., that file contain only "com.mysql.jdbc.Driver", the deployement work fine.
check my pom.xml here
https://github.com/anouarattn/GestionAbsence