7 months ago
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
but there is a var for url 100%
108 Replies
7 months ago
Are you using springboot data jpa or mybatis
datasource:
url: ${DATABASEURL} username: ${DBUSERNAME}
password: ${DB_PASSWORD}
driver-class-name: org.postgresql.Driver
jpa:
show-sql: true
properties:
hibernate:
format_sql: true
hibernate:
ddl-auto: update
7 months ago
I believe you're missing the spring key before datasource
7 months ago
spring:
datasource:
url: ${DATABASE_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
driver-class-name: org.postgresql.DriverI have it, it is working on local, it also worked before on railway until I started a new application, I forgot what I used in the variables
spring:
application:
name: Layers
datasource:
url: ${DATABASEURL} username: ${DBUSERNAME}
password: ${DB_PASSWORD}
driver-class-name: org.postgresql.Driver
jpa:
show-sql: true
properties:
hibernate:
format_sql: true
hibernate:
ddl-auto: update
7 months ago
please use code blocks
7 months ago
You're setting the DATABASE_URL environmental variable?
7 months ago
```
before and after
7 months ago
What you need to do is make an environmental variable in your Springboot app called DATABASE_URL
Assign it to the value ${{Postgres.DATABASE_URL}}
I did and this is what I have now:
DATABASE_URL="${{Postgres.DATABASE_URL}}" DB_PASSWORD="hidden" DB_USERNAME="postgres"
7 months ago
That's your raw variables in your Springboot service, correct?
so the URL is from the private tab and the username and password are from the public tab
7 months ago
No idea what that means
7 months ago
Ah sorry that's not going to work because JDBC
7 months ago
Brb
7 months ago
jdbc:postgresql://${{Postgres.RAILWAY_PRIVATE_DOMAIN}}:${{Postgres.PGPORT}}/${{Postgres.PGDATABASE}}
That should do the job
7 months ago
DATABASE_URL value
7 months ago
Replace what you have for it
7 months ago
Java is stupid
7 months ago
DB_PASSWORD="${{Postgres.PGPASSWORD}}"
DB_USERNAME="${{Postgres.PGUSER}}"so in URL do I put: jdbc:postgresql://${{Postgres.RAILWAYPRIVATEDOMAIN}}:${{Postgres.PGPORT}}/${{Postgres.PGDATABASE}}
or just: ${{Postgres.RAILWAYPRIVATEDOMAIN}}
7 months ago
the first one
7 months ago
the whole thing
7 months ago
DATABASE_URL=jdbc:postgresql://${{Postgres.RAILWAY_PRIVATE_DOMAIN}}:${{Postgres.PGPORT}}/${{Postgres.PGDATABASE}}
java.lang.RuntimeException: Driver org.postgresql.Driver claims to not accept jdbcUrl, jdbc:postgresql://:/
7 months ago
Yeah that error shows that none of the env variables actually resolved
7 months ago
Your Postgres service is still called what it was up there right
7 months ago
Screenshot your architecture page
7 months ago
Oh nos you have to have them in the same project
7 months ago
Won't work unless you do
7 months ago
Why do you have them in different projects?
7 months ago
You can't move it you'll need to make a new one
7 months ago
But once you do it should immediately all work
7 months ago
Looks like they are all in different projects; it should be in one project.
7 months ago
If you connect them using public URL it will cost you egress so it is efficient in one project and use internal URL.
7 months ago
they aren't doing that anyway
7 months ago
no…
DATABASE_URL="jdbc:postgresql://${{Postgres.RAILWAY_PRIVATE_DOMAIN}}:${{Postgres.PGPORT}}/${{Postgres.PGDATABASE}}" DB_PASSWORD="${{Postgres.PGPASSWORD}}" DB_USERNAME="${{Postgres.PGUSER}}" EMAIL_PASSWORD="okfaezxundjhutyf" EMAIL_USERNAME="layers.app1@gmail.com" JWT_SECRET="MyVeryStrongJWTSecretKey_987654321!@" NIXPACKS_JDK_VERSION="21" PORT="8080"
7 months ago
It will work, but in your case you should use one project.
7 months ago
Then use internal variables
7 months ago
As long as you moved your database over to that project you're golden
7 months ago
(and make sure it's still called Postgres)
7 months ago
Yeah the solution here, just move them in your project then it should work.
7 months ago
perfect
7 months ago
what's the error this time
7 months ago
yeah share the error logs
7 months ago
@Loudbook I think the user should delete this? It has secrets and email passwords.
7 months ago
considering it says "MyVeryStrong…" i would assume they're going to change it
2025-06-25T03:15:04.790Z WARN 1 --- [Layers] [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openAIClient': Injection of autowired dependencies failed
7 months ago
That's just an error with your application
7 months ago
Are you sure there isn't more to that
7 months ago
Do you need to provide an open ai key perhaps
7 months ago
Looks like warning only, it would help if you share the actual error that causes to crash.
7 months ago
That error is going to crash the whole thing
7 months ago
Not sure why it says warning
7 months ago
Agree
7 months ago
yerp
7 months ago
click the service, the deploymeny, and then logs?
7 months ago
What port did you give the domain
7 months ago
Set PORT=8080, redeploy your service, and delete the public domain and re-add it
7 months ago
= or colon
7 months ago
Does your public domain in the server settings show it's pointing to it
7 months ago
And does Springboot show it bound to 8080 in deployment logs
the last thing that I see in logs is:
```2025-06-25T03:21:54.511Z DEBUG 1 --- [Layers] [ main] .m.m.a.ExceptionHandlerExceptionResolver : ControllerAdvice beans: 1 @ExceptionHandler, 0 ResponseBodyAdvice
2025-06-25T03:21:54.723Z INFO 1 --- [Layers] [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port 8080 (http) with context path '/'
2025-06-25T03:21:54.732Z INFO 1 --- [Layers] [ main] c.e.ai.chateldadt.ChatEldadTApplication : Started ChatEldadTApplication in 6.564 seconds (process running for 7.117)```
7 months ago
Screenshot your public domain part of settings
7 months ago
great!
7 months ago
from Java…?
7 months ago
you'll need to use the Railway CLI
7 months ago
then use railway connect
7 months ago
You can also use a custom tool like pgadmin
Note that you will need to connect to the DB through it's public URL
Status changed to Solved chandrika • 8 months ago





