Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #683410] Mon, 13 June 2011 13:05 Go to next message
AmFreak Missing name is currently offline AmFreak Missing name
Messages: 25
Registered: June 2011
Junior Member
Hi,

how can i catch Eclipse Link exceptions?
For example if i start my application and the server insn't running i get:

[EL Severe]: Local Exception Stack:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.2.0.v20110202-r8913): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLNonTransientConnectionException: java.net.ConnectException: Fehler beim Herstellen der Verbindung zum Server localhost am Port 1527. Nachricht: Connection refused: connect.
Error Code: 40000
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:324)
at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:319)
at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:138)
at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330)
at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:291)
at org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:418)
at org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:167)
at org.eclipse.persistence.sessions.server.ConnectionPool.startUp(ConnectionPool.java:453)
at org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:484)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:640)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:235)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:394)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.getServerSession(EntityManagerFactoryImpl.java:185)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:242)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:230)
at de.fh.stockgrabber.model.StockGrabberEntityManagerFactory.createEntityManager(StockGrabberEntityManagerFactory.java:104)
at de.fh.stockgrabber.model.StockGrabberEditorModel.<init>(StockGrabberEditorModel.java:37)
at de.fh.stockgrabber.project.model.ProjectsModel.<init>(ProjectsModel.java:40)
at de.fh.stockgrabber.views.MainView.createPartControl(MainView.java:105)
at org.eclipse.ui.internal.ViewReference.createPartHelper
..........
[many more]


The code crashes when i try to create the EntityManager:

try {
em = StockGrabberEntityManagerFactory.createEntityManager();
transaction = em.getTransaction();
transaction.begin();
} catch (Exception e) {
System.exit(0);


The Exception is catched (the app exists), but it doesn't stop the output as seen above. So how can i handle this; or can't i cause it's an "Internal Exception"?
Re: (no subject) [message #685889 is a reply to message #683410] Mon, 20 June 2011 10:17 Go to previous message
Chris Delahunt is currently offline Chris Delahunt
Messages: 1017
Registered: July 2009
Senior Member
Hello,

I'm not sure of the question, as it looks like you are handling the exception. In this case, EclipseLink is throwing an instance of org.eclipse.persistence.exceptions.DatabaseException which is caught in your try/catch block. It is being logged at the severe log level, so if you don't want it logged, you will need to turn logging off using the
<property name="eclipselink.logging.level" value="OFF"/> peristence property as described here:
http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging

Best Regards,
Chris
Previous Topic:Maven repository incomplete
Next Topic:eclipselink-orm.xml and Eclipse JPA views
Goto Forum:
  


Current Time: Wed Aug 27 21:27:19 EDT 2014

Powered by FUDForum. Page generated in 0.04319 seconds