'DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples'
I'm following the first cup tutorial, but I'm stuck at the end of chapter 4 with this exception:
java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
In the Projects tab I select the firstcup-war
project, right-click and select Run.
The output tab says:
Deploying on GlassFish Server
profile mode: false
debug mode: false
force redeploy: true
In-place deployment at /home/t/NetBeansProjects/firstcup-war/target/firstcup-war
GlassFish Server, deploy, null, false
The tab Java DB Database Process says
Fri May 08 21:09:39 CEST 2020 : Security manager installed using the Basic server security policy.
Fri May 08 21:09:39 CEST 2020 : Apache Derby Network Server - 10.14.2.0 - (1828579) started and ready to accept connections on port 1527
The tab GlassFish Server has a long trail of exceptions:
...
Info: EclipseLink, version: Eclipse Persistence Services - 2.7.0.v20170811-d680af5
Warning: RAR5038:Unexpected exception while creating resource for pool DerbyPool. Exception : javax.resource.spi.ResourceAllocationException: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Warning: RAR5117 : Failed to obtain/create connection from connection pool [ DerbyPool ]. Reason : com.sun.appserv.connectors.internal.api.PoolingException: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Warning: RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001]
Severe: Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Error Code: 0
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:316)
at org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:147)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:170)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.setOrDetectDatasource(DatabaseSessionImpl.java:228)
[...]
Severe: Exception while deploying the app [firstcup-war]
Severe: Exception during lifecycle processing
org.glassfish.deployment.common.DeploymentException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Error Code: 0
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:844)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getAbstractSession(EntityManagerFactoryDelegate.java:216)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:324)
at
...
Severe: Exception while deploying the app [firstcup-war] : Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.7.0.v20170811-d680af5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'sun-appserv-samples', see the next exception for details.::SQLSTATE: XBM01::SQLSTATE: XJ001
Error Code: 0
I'm not sure what parts are relevant, for what it's worth here is the full log: https://pastebin.com/cRE9mVMQ
Solution 1:[1]
I can't be sure because I don't see your derby logs, but it is possible that it is connected to a Java permissions error.
If this appears in derby.log:
Java exception: 'access denied ("java.lang.RuntimePermission" "getenv.SOURCE_DATE_EPOCH"")
See this answer.
I resolved the problem by adding
permission java.lang.RuntimePermission "getenv.SOURCE_DATE_EPOCH";
to /etc/java-11-openjdk/security/java.policy
(Ubuntu) in the grant section.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Joseph S |