I recently setup a java application in my spring-boot. I'm getting this error when i run it:
org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:315)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:51)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:225)
at org.postgresql.Driver.makeConnection(Driver.java:465)
at org.postgresql.Driver.connect(Driver.java:264) ........
Caused by: java.net.UnknownHostException: postgres ........
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-02-03 17:24:15 - Application run failed
My application-dev.properties file in src/main/resources/ has this code:
spring.datasource.url=jdbc:postgresql://localhost:5432/sofra_hybrid_7?useUnicode=yes&characterEncoding=UTF-8
spring.datasource.username=postgres
spring.datasource.password=admin
I have made the database too as well in the postgres server with username "postgres" and pass "admin:
lalarukh=# CREATE DATABASE sofra_hybrid_7;
CREATE DATABASE
lalarukh=# grant all privileges on database sofra_hybrid_7 to postgres ;
GRANT
I have even also used the jdbc postgres jar file inside the application to make the connection but all in vain.
Seeking Help!
I can't run my java application as postgres can't make connection with my app in spring boot.
I also faced the same issue and after a lot of working I finally resolved it this way:
As you're receiving unknown host means that your application can't detect your this file: application-dev.properties
You shall make this application.yml inside your project (yourprojectdirectory/application.yml) and this will automatically detects the DB information and all.
As you're using postgres as DB so, add this code inside this file:
spring:
datasource:
driver-class-name: org.postgresql.Driver
url: jdbc:postgresql:db_name
username: your-postgres-username
password: your-postgres-password
Run this command for application running: mvn spring-boot:run -Dspring-boot.run.profiles
I'm using a following docker-compose file in a java web app project.
version: "3"
services:
product:
image: jboss/wildfly
ports:
- 8080:8080
volumes:
- Product/target/Product.war:/opt/jboss/wildfly/standalone/deployments
The error I'm getting is
ERROR: Named volume "Product/target/Product.war:/opt/jboss/wildfly/standalone/deployments:rw" is used in service "product" but no declaration was found in the volumes section.
Failed to deploy 'Compose: docker-compose.yml': `docker-compose` process finished with exit code 1
Edit OCI runtime create failed:
Following the fix of the path, I'm encountering another error. OCI runtime create failed:
Deploying 'Compose: docker-compose.yml'...
/usr/local/bin/docker-compose -f /Users/username/Desktop/Project/docker-compose.yml up -d
Starting project_product ...
Starting project_product ... error
ERROR: for project_product Cannot start service product: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/username/Desktop/Project/User/target/Product.war\\\" to rootfs \\\"/var/lib/docker/overlay2/e090197e0697ec14446020cf2444dc0d3f39dfb240de9f399017415f6faeb13b/merged\\\" at \\\"/var/lib/docker/overlay2/e090197e0697ec14446020cf2444dc0d3f39dfb240de9f399017415f6faeb13b/merged/opt/jboss/wildfly/standalone/deployments\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for product Cannot start service product: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:424: container init caused \"rootfs_linux.go:58: mounting \\\"/Users/username/Desktop/Project/User/target/Product.war\\\" to rootfs \\\"/var/lib/docker/overlay2/e090197e0697ec14446020cf2444dc0d3f39dfb240de9f399017415f6faeb13b/merged\\\" at \\\"/var/lib/docker/overlay2/e090197e0697ec14446020cf2444dc0d3f39dfb240de9f399017415f6faeb13b/merged/opt/jboss/wildfly/standalone/deployments\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
Failed to deploy 'Compose: docker-compose.yml': `docker-compose` process finished with exit code 1
You must add . at the beginning or use an absolute path when mounting a local file into a container. Otherwise Docker will assume it's a named volume, as the error suggests.
I am trying to move my data (exported from Hive) to a Cassandra table located in some other server
This is sqoop command :
export --connect jdbc:cassandra://server_address:port/KeySpace_name --username "MyUsername"--password "MyPass" --table my_cassandra_table --export-dir /user/xyz/ --columns Column_list
I get this error:
E0501: Could not perform authorization operation, Call From trphada05.hadoop.searshc.com/157.241.81.9 to trphada01:8020 failed on connection exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused
I'm using windows 10 , when I try to compile my project I get the following error :
c.m.s.jdbc.internals.AuthenticationJNI : Failed to load the sqljdbc_auth.dll
2016-05-11 02:18:00.558 ERROR 5424 --- [ost-startStop-1] o.a.tomcat.jdbc.pool.ConnectionPool : Unable to create initial connections of pool.
com.microsoft.sqlserver.jdbc.SQLServerException: This driver is not configured for integrated authentication.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:170) ~[sqljdbc4-2.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.sendLogon(SQLServerConnection.java:2338) ~[sqljdbc4-2.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.logon(SQLServerConnection.java:1929) ~[sqljdbc4-2.0.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.access$000(SQLServerConnection.java:41) ~[sqljdbc4-2.0.jar:na]
What I tried so far :
1. copy the authsql dll in jre of intellij idea => nothing
2. copy the dll to system32 => JVM error ACCESS_VIOLATION
Sring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=MyTest;integratedSecurity=true;
spring.datasource.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
spring.jpa.hibernate.ddl-auto=update
The connection works in Datagrip I can connect to the database without any problem but intellij I get this error is there a way to fix it?
Sring.datasource.url=jdbc:sqlserver://localhost:1433;databaseName=MyTest;integratedSecurity=true
try changing ports to 3306 and see what happens:
Sring.datasource.url=jdbc:sqlserver://localhost:3306;databaseName=MyTest;integratedSecurity=true
I am trying to use postgres in WildFly Full 9.0.1.Final. Unfortunately, for a task that should be simple, we have had 2 people trying for days to figure out how to make this work.
I should add that I am using Docker, and as I build the docker image I am trying various ways to add postgres support to WildFly Full 9.0.1.Final.
We have tried the following:
batch file
batch
connect
#module add --name=org.postgres --resources=/opt/jboss/wildfly/psql-jdbc.jar --dependencies=javax.api,javax.transaction.api
#module add --name=org.postgres --resources=/opt/jboss/wildfly/postgresql-9.3-1101.jdbc41.jar --dependencies=javax.api,javax.transaction.api
module add --name=org.postgresql --slot=main --resources=/opt/jboss/wildfly/postgresql-9.3-1101.jdbc41.jar --dependencies=javax.api,javax.transaction.api
#/subsystem=datasources/jdbc-driver=postgresql:add(driver-name="postgresql",driver-module-name="org.postgresql",driver-class-name=org.postgresql.Driver)
#datasources/jdbc-driver=postgresql:add(driver-name=postgresql,driver-module-name=org.postgresql,driver-xa-datasource-class-name=org.postgresql.xa.PGXADataSource)
/subsystem=datasources/jdbc-driver=postgres:add(driver-name="org.postgresql",driver-module-name="org.postgresql",driver-class-name=org.postgresql.Driver)
#The batch failed with the following error (you are remaining in the batch editing mode to have a chance to correct the error): {"WFLYCTL0062: Composite operation failed and was rolled back. Steps that #failed:" => {"Operation step-1" => "WFLYJCA0041: Failed to load module for driver [org.postgresql]"}}
#/subsystem=datasources/jdbc-driver=postgres:add(driver-name="postgres",driver-module-name="org.postgresql",driver-class-name=org.postgresql.Driver)
# Add the datasource
#data-source add --jndi-name=java:jboss/datasources/ISDS --name=pu-magick --connection-url=jdbc:postgresql://UI_PG_DATABASE:5432/magick --driver-name=postgresql --user-name=magick --password=magick
run-batch
In a Dockerfile
ADD modules /opt/jboss/wildfly/modules/
This attempt resulted in:
Caused by: java.lang.IllegalStateException: No layers directory found at /opt/jboss/wildfly/modules/system/layers
at org.jboss.modules.LayeredModulePathFactory.resolveLayeredModulePath(LayeredModulePathFactory.java:65)
at org.jboss.modules.LocalModuleFinder.getRepoRoots(LocalModuleFinder.java:111)
at org.jboss.modules.LocalModuleFinder.<init>(LocalModuleFinder.java:107)
at org.jboss.modules.LocalModuleFinder.<init>(LocalModuleFinder.java:88)
at org.jboss.modules.LocalModuleLoader.<init>(LocalModuleLoader.java:57)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.jboss.modules.DefaultBootModuleLoaderHolder$1.run(DefaultBootModuleLoaderHolder.java:37)
at org.jboss.modules.DefaultBootModuleLoaderHolder$1.run(DefaultBootModuleLoaderHolder.java:33)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.modules.DefaultBootModuleLoaderHolder.<clinit>(DefaultBootModuleLoaderHolder.java:33)
... 1 more
Adding driver to deployment directory
I have found in the past that a database driver can be added to jboss by adding the jar to the deployment directory. This, in my opinion, is about as complicated as it needs to be.
So, I also tried copying postgresql-9.3-1101.jdbc41.jar to /opt/jboss/wildfly/standalone/deployments/
DockerFile
FROM wildflyext/wildfly-camel
MAINTAINER ah <ah#domain.io>
ENV TMPDIR /tmp/
ENV WFDIR /opt/jboss/wildfly/
RUN /opt/jboss/wildfly/bin/add-user.sh admin admin --silent
## COPY PG MODULE TO SERVER
#ADD module.xml opt/jboss/wildfly/modules/
#ADD standalone.xml $WFDIR/standalone/configuration/
#ADD system /opt/jboss/wildfly/modules/
## COPY PG DRIVER TO SERVER
#ADD postgresql-9.3-1101.jdbc41.jar /opt/jboss/wildfly/standalone/deployments/
#ADD postgresql-9.3-1101.jdbc41.jar /opt/jboss/wildfly/
#ADD psql-jdbc.jar $WFDIR/standalone/deployments/
## COPY STANDALONE TO SERVER
ADD standalone-camel.xml /opt/jboss/wildfly/standalone/configuration/
ADD config.sh $TMPDIR
ADD batch.cli $TMPDIR
RUN $TMPDIR/config.sh
#CMD ["-c", "standalone-camel.xml"] # loads correct standalone, cannot access mgmt console - connection interupted
#CMD ["-b", "0.0.0.0", "-c", "standalone-camel.xml"] # does not load correct standalone, cannot access mgmt console - connection interupted
#CMD ["-c", "standalone-camel.xml"m "-b", "0.0.0.0"] # WFLYSRV0073: Invalid option '/bin/sh'
#CMD ["-c", "standalone-camel.xml", "-b", "0.0.0.0"] # loads correct standalone, cannot access mgmt console - connection interupted
# attempt with two CMDs = loads incorrect standalone - standalone.xml, not standalone-camel.xml, cannot access mgmt console - connection interupted
#CMD ["-c", "standalone-camel.xml"]
#CMD ["-b", "0.0.0.0"]
# attempt with NO CMDs
The solution was the following:
In the cli file, I needed to have the following - the tick was correct naming:
module add --name=org.postgresql --slot=main --resources=/opt/jboss/wildfly/postgresql-9.3-1101.jdbc41.jar --dependencies=javax.api,javax.transaction.api
/subsystem=datasources/jdbc-driver=postgresql:add(driver-name="postgresql",driver-module-name="org.postgresql",driver-class-name=org.postgresql.Driver)
And I needed to remove this driver from the standalone, as it would clash with the above instructions.