I have a Lotus Notes Agent written in Java which should pop up a message to the user after it is executed by clicking a button in the Notes client. Trying to display the pop-up causes an error which I see in the Java Debug console as :
java.security.AccessControlException: Access denied (java.lang.RuntimePermission exitVM.0)
at java.security.AccessController.checkPermission(AccessController.java:108)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:544)
at COM.ibm.JEmpower.applet.AppletSecurity.superDotCheckPermission(AppletSecurity.java:1449)
at COM.ibm.JEmpower.applet.AppletSecurity.checkRuntimePermission(AppletSecurity.java:1311)
at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1611)
at COM.ibm.JEmpower.applet.AppletSecurity.checkPermission(AppletSecurity.java:1464)
at java.lang.SecurityManager.checkExit(SecurityManager.java:756)
at java.lang.Runtime.exit(Runtime.java:99)
at java.lang.System.exit(System.java:279)
at ClipboardTest.main(Unknown Source)
at JavaAgent.NotesMain(Unknown Source)
at lotus.domino.AgentBase.runNotes(Unknown Source)
at lotus.domino.NotesThread.run(Unknown Source)
My agent code is
import lotus.domino.*;
import javax.swing.JOptionPane;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Document cdoc = agentContext.getDocumentContext();
String[] notesURL = new String[] {cdoc.getNotesURL()};
ClipboardTest.main(notesURL);
JOptionPane.showMessageDialog(null,"message","title",JOptionPane.WARNING_MESSAGE);
} catch(Exception e) {
e.printStackTrace();
}
}
}
I have manager access to the Database. What could be causing this error?
First look at what the error actually is:
Access denied (java.lang.RuntimePermission exitVM.0)
You are telling the VM to die and you do not have the rights to do this. If you had, you would cause anything else running on that JVM instance to die as well, possibly leading to a hang/crash.
Secondly your code is failing in the ClipboardTest.main() method, which you haven't posted any code for.
In the agent properties there is an option to add debug data. This will give you the exact line number that is causing the issue.
My guess is you have a System.exit() call in the ClipboardTest.main() . It shouldn't be there.
Related
I am using matlabcontrol to start matlab-sessions and everything works fine if i start it from eclipse. A new Matlab-session is opened or, if one is already open&connected, the old one is reactivated.
However, I want to do this via a windows command line that is called from a python program.
If I compile and export this to a .jar-file, it still works, but ONLY if an old, manually started MATLAB session is still open.
my current cmd-command is simply:
java -jar StartmatlabSim.jar
If no session is open, i get the following error in the cmd:
C:\Users\rEngel\Desktop>java -jar StartmatlabSim.jar
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: matlabcontrol.MatlabConnectionException: Support code location could not be determined. Could not ge
t path from URI location.
URI Location: jar:rsrc:matlabcontrol-4.1.0.jar!/
URL Location: jar:rsrc:matlabcontrol-4.1.0.jar!/
Code Source: (jar:rsrc:matlabcontrol-4.1.0.jar!/ <no signer certificates>)
Protection Domain: ProtectionDomain (jar:rsrc:matlabcontrol-4.1.0.jar!/ <no signer certificates>)
java.net.URLClassLoader#677327b6
<no principals>
java.security.Permissions#27973e9b (
("java.security.AllPermission" "<all permissions>" "<all actions>")
)
Class Loader: java.net.URLClassLoader#677327b6
Class Loader Class: class java.net.URLClassLoader
at matlabcontrol.Configuration.getSupportCodeLocation(Configuration.java:295)
at matlabcontrol.RemoteMatlabProxyFactory.createProcess(RemoteMatlabProxyFactory.java:289)
at matlabcontrol.RemoteMatlabProxyFactory.requestProxy(RemoteMatlabProxyFactory.java:125)
at matlabcontrol.RemoteMatlabProxyFactory.getProxy(RemoteMatlabProxyFactory.java:144)
at matlabcontrol.MatlabProxyFactory.getProxy(MatlabProxyFactory.java:81)
at StartMatlab.main(StartMatlab.java:14)
... 5 more
EDIT: For some reason, the system seems to treat a manually started session different from a commandline-started session. Strangely, a batch file with only that single command line also works, but not if it is called from python - it must be clicked on or executed from cmd (!?!?!?).
I am totally lost here....
Beeing able to run and launch my MATLAB-sessions is important for me, because I need to include it into a python-program (mosaik), which uses a cmd-command to start java.
If anybody recognizes the issue and knows a fix I would be very grateful.
Thank you®ards,
Robin
P.S.:
The Java-code is:
import matlabcontrol.*;
public class StartMatlab {
public static void main(String[] args)
throws MatlabConnectionException, MatlabInvocationException
{
// create proxy
MatlabProxyFactoryOptions options = new MatlabProxyFactoryOptions.Builder()
.setUsePreviouslyControlledSession(true).setHidden(true)
.build();
MatlabProxyFactory factory = new MatlabProxyFactory(options);
MatlabProxy proxy = factory.getProxy();
// call builtin function
proxy.eval("disp('hello world')");
// close connection
proxy.disconnect();
}
}
Also, I included matlabcontrol-4.1.0.jar to the .jar build path and chose to package the library into the jar file during export.
I am having my java program for Neo4j with the Neo4j version as 2.3.0m1 .The jar files i was using for the connect was neo4j-desktop-2.3.0-M01.jar . Everything works fine. Now i want to load databases from 2.3.0-m3 version which is not opening in the current version. I am not able to find any jar files for this new version either .
This is my java code
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Node;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.Transaction;
import org.neo4j.graphdb.factory.GraphDatabaseFactory;
public class Testing {
public static void main(String args[])
{
System.out.println("hai");
GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
GraphDatabaseService db= dbFactory.newEmbeddedDatabase("D:\\graph.db");
try (Transaction tx = db.beginTx()) {
System.out.println("began transaction");
tx.success();
}
catch(Exception e)
{
e.printStackTrace();
}
System.out.println("Done successfully");
}
}
This is the error i am getting if i try to open a higher version db (from 2.3.0-M3)
Exception in thread "main" java.lang.RuntimeException: Error starting org.neo4j.kernel.EmbeddedGraphDatabase, D:\data2\graph.db
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:314)
at org.neo4j.kernel.EmbeddedGraphDatabase.<init>(EmbeddedGraphDatabase.java:59)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:107)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:94)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:176)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newEmbeddedDatabase(GraphDatabaseFactory.java:66)
at Testing.main(Testing.java:19)
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.impl.transaction.state.DataSourceManager#258bb6ba' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:499)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:108)
at org.neo4j.kernel.InternalAbstractGraphDatabase.run(InternalAbstractGraphDatabase.java:309)
... 6 more
Caused by: org.neo4j.kernel.lifecycle.LifecycleException: Component 'org.neo4j.kernel.NeoStoreDataSource#f1cb476' was successfully initialized, but failed to start. Please see attached cause exception.
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:499)
at org.neo4j.kernel.lifecycle.LifeSupport.start(LifeSupport.java:108)
at org.neo4j.kernel.impl.transaction.state.DataSourceManager.start(DataSourceManager.java:117)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:493)
... 8 more
Caused by: org.neo4j.kernel.impl.storemigration.StoreUpgrader$UpgradingStoreVersionNotFoundException: 'neostore.nodestore.db' does not contain a store version, please ensure that the original database was shut down in a clean state.
at org.neo4j.kernel.impl.storemigration.UpgradableDatabase.checkUpgradeable(UpgradableDatabase.java:86)
at org.neo4j.kernel.impl.storemigration.StoreMigrator.needsMigration(StoreMigrator.java:158)
at org.neo4j.kernel.impl.storemigration.StoreUpgrader.getParticipantsEagerToMigrate(StoreUpgrader.java:259)
at org.neo4j.kernel.impl.storemigration.StoreUpgrader.migrateIfNeeded(StoreUpgrader.java:134)
at org.neo4j.kernel.NeoStoreDataSource.upgradeStore(NeoStoreDataSource.java:532)
at org.neo4j.kernel.NeoStoreDataSource.start(NeoStoreDataSource.java:434)
at org.neo4j.kernel.lifecycle.LifeSupport$LifecycleInstance.start(LifeSupport.java:493)
... 11 more
Also i am trying to download the enterprise version zip(2.3.0-M1) for windows from neo4j web site because i have the import-graphml feature in 2.3.0-M3 for which i want to move up to 2.3.0-M3.But the link provided in neo4j site is not downloading it completly.
http://neo4j.com/artifact.php?name=neo4j-enterprise-2.3.0-M01-windows.zip
Is there somewhere else this can be downloaded from
If you are doing upgrade of Neo4j you also need to upgrade database version.
neo4j.properties
# Enable this to be able to upgrade a store from an older version.
allow_store_upgrade=true
I wrote this simple class in NetBeans, in order to learn about connecting to and managing a Derby database through Java code, and am using the sample database provided by the IDE as the connection target. I believe it's a rather straightforward database connection example:
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
public class MainClass {
public static void main(String[] args) {
//Some code that allows me to start the connection only after keyboard input
System.out.println("Program will now connect to database");
try {
System.in.read();
}
catch (IOException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
// Redirecting DriverManager's output to the console's standard output
DriverManager.setLogWriter(new PrintWriter(System.out));
// This is where I connect to the database, execute a query and print a result
// Still barebones, I am learning SQL basics yet
String dbURL ="jdbc:derby:C:\\users\\project2100\\.netbeans-derby\\sample";
try (Connection conn = DriverManager.getConnection(dbURL, "app", "app")) {
System.out.println("Connected");
try (Statement stmt = conn.createStatement()) {
ResultSet output = stmt.executeQuery("SELECT * FROM CUSTOMER");
while (output.next()) {
System.out.println(output.getString("NAME"));
}
}
}
catch (SQLException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
// Recently added to keep the application alive
// This way, I can monitor memory usage on Task Manager
try {
System.in.read();
}
catch (IOException ex) {
Logger.getLogger(MainClass.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Java's standard output gives me the results I expect, but DriverManager's output tells me something I'm worrying about; here's the full console output from an application run:
run:
Program will now connect to database
DriverManager.getConnection("jdbc:derby:C:\users\project2100\.netbeans-derby\sample")
trying org.apache.derby.jdbc.AutoloadedDriver40
SQLState(08004) vendor code(40000)
java.sql.SQLException: Connection refused : java.lang.OutOfMemoryError
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<clinit>(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.Driver20.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at javadbpg.MainClass.main(MainClass.java:35)
SQLState(08004) vendor code(40000)
java.sql.SQLNonTransientConnectionException: Connection refused : java.lang.OutOfMemoryError
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.<clinit>(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.Driver20.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at javadbpg.MainClass.main(MainClass.java:35)
Caused by: java.sql.SQLException: Connection refused : java.lang.OutOfMemoryError
at org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown Source)
... 11 more
getConnection returning org.apache.derby.jdbc.AutoloadedDriver40
Connected
Jumbo Eagle Corp
New Enterprises
Wren Computers
Small Bill Company
Bob Hosting Corp.
Early CentralComp
John Valley Computers
Big Network Systems
West Valley Inc.
Zed Motor Co
Big Car Parts
Old Media Productions
Yankee Computer Repair Ltd
BUILD SUCCESSFUL (total time: 23 seconds)
NOTE: There is a 1-2 seconds hang between the first two errors.
Just recently, after looking around the Internet for what might be causing these OutOfMemoryErrors, I added that last try block and observed the application's memory footprint. It goes from an initial ~9MB to ~40MB.
Therefore, should I set some memory parameters inside the application, in order to reduce these errors, and eventually gain performance? (If so, could I have some pointers?) Or should i just leave everything as is and let DriverManager work by itself?
2014-08-07 Follow-up:
This time, I ran the application on debug mode, and wrote down the private memory usage step by step. Points of interest are as follows:
Memory amount right before the try (Connection conn = ... statement is 12MB;
Following this, the program hangs for about 5 seconds and fires all the OutOfMemoryErrors described above;
After the 5 seconds have elapsed, the program reserves a total memory of 37MB right before the System.out.println("Connected"); statement;
The executeQuery statement adds up another 7MB, total: 45MB. Execution time is negligible (<1/2sec);
Here's the derby.log file as requested by Bryan Pendleton, its state is after all the previous tests:
----------------------------------------------------------------
Thu Aug 07 10:10:11 CEST 2014:
Booting Derby version The Apache Software Foundation - Apache Derby - 10.10.1.3 - (1557168): instance a816c00e-0147-af84-a381-0000263f2b92
on database directory C:\Users\Project2100\.netbeans-derby\C3Subjects with class loader sun.misc.Launcher$AppClassLoader#58644d46
Loaded from file:/C:/Program%20Files/Java/jdk1.8.0_05/db/lib/derby.jar
java.vendor=Oracle Corporation
java.runtime.version=1.8.0_05-b13
user.dir=C:\Users\Project2100\Documents\NetBeansProjects\JavaDB Proving Grounds
os.name=Windows 7
os.arch=amd64
os.version=6.1
derby.system.home=C:\users\Project2100\.netbeans-derby
Database Class Loader started - derby.database.classpath=''
Yesterday, I kept searching on the Internet about memory management, and attempted to use the CLI arguments -Xms and -Xns to raise the application's starting memory, to no avail; these options manipulate only the application's reserved memory, and leaves the actual memory initially used at the usual 9-10MB. I'm getting the same memory values, errors and hangs anyway.
I guess that, for now, I'm going to chalk this behavior under loading database... and go on with SQL itself, since the system console doesn't list any complaints at all. However, if there is indeed a way to preemptively allocate more memory on database connection, I'd be grateful to get an answer about it.
Many thanks for your help!
There is a static variable in the org.apache.derby.impl.jdbc.EmbedConnection:
/**
* Static exception to be thrown when a Connection request can not
* be fulfilled due to lack of memory. A static exception as the lack
* of memory would most likely cause another OutOfMemoryException and
* if there is not enough memory to create the OOME exception then something
* like the VM dying could occur. Simpler just to throw a static.
*/
public static final SQLException NO_MEM =
newSQLException(SQLState.LOGIN_FAILED, "java.lang.OutOfMemoryError");
When you set up the logwriter for DriverManager, the SQLException will be printed:
public SQLException(String reason, String SQLState, int vendorCode) {
super(reason);
this.SQLState = SQLState;
this.vendorCode = vendorCode;
if (!(this instanceof SQLWarning)) {
if (DriverManager.getLogWriter() != null) {
DriverManager.println("SQLState(" + SQLState +
") vendor code(" + vendorCode + ")");
printStackTrace(DriverManager.getLogWriter());
}
}
}
That's why we have an ugly stack trace.
So I've spent quite awhile trying to find an answer from other people having trouble with the RMI tutorial, but I'm completely stumped on this. I'm doing this tutorial through eclipse.
My ComputeEngine Class. This is just copied from the tutorial, so I don't think there's anything wrong with it.
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
import compute.Compute;
import compute.Task;
public class ComputeEngine implements Compute {
public ComputeEngine() {
super();
}
public <T> T executeTask(Task<T> t) {
return t.execute();
}
public static void main(String[] args) {
if (System.getSecurityManager() == null) {
System.setSecurityManager(new RMISecurityManager());
}
try {
String name = "Compute";
Compute engine = new ComputeEngine();
Compute stub = (Compute) UnicastRemoteObject.exportObject(engine, 0);
Registry registry = LocateRegistry.getRegistry();
registry.rebind(name, stub);
System.out.println("ComputeEngine bound");
} catch (Exception e) {
System.err.println("ComputeEngine exception:");
e.printStackTrace();
}
}
}
I start the rmiregistry in the command line with
set classpath=
start rmiregistry
My VM arguments in eclipse are:
-Djava.rmi.server.codebase=file:/C:/Users/Kevin/workspace/RMI/bin/
-Djava.rmi.server.hostname=Compute
-Djava.security.policy=server.policy
I have the compute.jar file and the the server.policy files in the bin folder. I granted all permissions for the policy file.
grant{
permission java.security.AllPermission;
};
After all that, I run ComputeEngine and get the following errors:
ComputeEngine exception:
java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkConnect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
at engine.ComputeEngine.main(ComputeEngine.java:31)
It seems like it has some kind of problem with rebind, but I don't understand what. I also don't understand the AccessControlException, when I have the policy file. I've checked to make sure the rmiregistry is still running, and I don't close the empty window that comes up after starting it.
So yeah, I'm lost.
Clearly your security policy file isn't being found. It would need to be in the current working directory when you execute the program. Run your program with -Djava.security.debug=access,failure to see exactly what's going on.
The exception clearly says that your code base does not have permission to creat sockets/ for network communication. The reason could be with your security policy specification alone. Do not specify the policy file explicitly and allow the JVM to use the default security policy. The default policy specifies the right permissions so you should be fine.
Background: Hibernate connects to a database using a username and password entered into a GUI. Upon failure, instead of propagating the error up as an exception, it comes out as a stack trace in the logger. I don't know where the exception is being caught at. Also a tiny bit troubling is the following block:
if (reason != null) {
println("getConnection failed: " + reason);
throw reason;
}
My breakpoint is set at the throw line (and successfully triggers), but the println statement never generates output (MySQL is using some sort of logger setup I can't find an open file hand for). Any sort of trick for locating where an exception is caught?
EDIT 1:
I call
sessionFactory = /*AnnotationConfiguration*/ ac.buildSessionFactory();
The exception is caught by Hibernate somewhere between the java.sql.DriverManager class and my HibernateUtil class. I presume we can blame Hibernate deciding that I don't really want to see the exception. I want to convince hibernate to let me see the exception.
EDIT 2:
My stack is this:
java.sql.SQLException: Access denied for user 'user'#'machine' (using password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:910)
at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:3923)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1273)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2031)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:718)
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:302)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
/* Exception is thrown on the next line (1st code block in original post). */
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:154)
/* Begin hidden source calls */
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
/* End hidden source calls */
at com.****.****.util.HibernateUtil.initialize(HibernateUtil.java:34)
I can't get the debugger to look at any point above the stack beyond DriverManager.java:582. Everything in the stack beyond that is not visible in the debugger.
First of all, as you mention that there is a logger, you should replace all println statements with log calls.
You can also add further log messages to identify what happens inside the app. Alternatively (or in combination with the above), you can step through the critical code part in the debugger to see where the exception actually happens.
Here's the end result: Line 116 of org.hibernate.cfg.SettingsFactory catches the sql exception and forces it to a log. No configuration is available to change this. It appears I'll be unable to tell my end-user why their connection fails unless I make use of the logs.
Netbeans, for some annoying reason after I gave it the source for Hibernate still wanted to call all of this "hidden source calls." Some time with VIM and reading the line numbers later, I've got it cleared up.
Set a breakpoint for the exception thrown, and when the debugger starts single step to see what happens. You Will probably only need a few steps before the print happens.