RESTful Web service Testing error in Netbeans 6.9 with Mysql - java

Hi I have created a RESTful web service in netbeans 6.9 with mysql. I followed this tutorial from netbeans: http://netbeans.org/kb/docs/websvc/rest.html
But when I am trying to test the service I am getting the following error in browser. Can anyone please help how to resolve the issue.
Thanks in advance.
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
descriptionThe server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: null
Error Code: 0
root cause
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: null
Error Code: 0
root cause
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: null
Error Code: 0
root cause
java.sql.SQLException: Error in allocating a connection. Cause: null

I think this link may help you :
http://netbeans-org.1045718.n5.nabble.com/Error-in-allocating-a-connection-Cause-null-td3358722.html
If your mysql tables have field names that have spaces in them, it will cause this problem.

Thank you for your response Ji. And no, I didn't have any space in the column. The issue is with the Admin Properties for the mySQL. I had to put the Path to start server, path to stop server etc in the Admin Properties.
Please refer to this link for more details. http://netbeans.org/kb/docs/ide/mysql.html
Also please note, if you are using PhpMyAdmin sort of tool to control your mySQL server, then you need to put the Admin Properties according to that.

Related

An error occurred marshalling the object [java.io.IOException: Broken pipe]

I'm getting an error in my Java Springboot application, and the error doesn't mention anywhere which object is failing to be marshalled. We have org.eclipse.persistence.core at v2.7.7.
The full error is:
An I/O error has occurred while writing a response message entity to the container output stream. javax.ws.rs.WebApplicationException: HTTP 500 Internal Server Error
at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:994)
....
[Exception [EclipseLink-25003] (Eclipse Persistence Services - 2.7.7.v20200504-69f2c2b80d): org.eclipse.persistence.exceptions.XMLMarshalException
Exception Description: An error occurred marshalling the object
Internal Exception: org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe]
at org.eclipse.persistence.jaxb.JAXBMarshaller.marshal(JAXBMarshaller.java:513)
at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:992)
Any ideas on what can cause the broken pipe? Is it due to marshalling an unsupported object? Or maybe there's another underlying issue?

How to resolve this error: HTTP Status 500 - Internal Server Error

I try to open my project in Java Web using Netbeans but i dont know how to resolve this.
HTTP Status 500 - Internal Server Error
type Exception report
message Internal Server Error
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: org.postgresql.util.PSQLException: FATAL: database "eCommerce" does not exist
root cause
org.postgresql.util.PSQLException: FATAL: database "eCommerce" does not exist
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 5.0 logs.
javax.servlet.ServletException: org.postgresql.util.PSQLException: FATAL: database "eCommerce" does not exist
This is the cause of the exception. Your application is trying to access a PostgreSQL database 'eCommerce' which doesn't seem to exist. You will have to create the database 'eCommerce', if you have access to the database server and the privileges to do so.

I tried to clear entity manager after commit in JPA, so i am getting exceptions

I am using following codes.
e.getTransaction().commit();
e.clear();
but I am getting following exceptions:
org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Could not commit with auto-commit set on
Could you please help on this error?

AppEngine: Transient error

I get the exception below for more than three hours. Does anybody know how to get rid of it?
javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Transient error, please try again.
Error Code: 1
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:517)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)
There was a service disruption today: https://groups.google.com/d/msg/google-cloud-sql-discuss/KHZzpRxkSj0/27ccmG9q34oJ
Are you still experiencing this problem?

Why do I need to flush the connection pool each time I redeploy?

I have successfully made a connection to a remote MySQL server through Glassfish, however each time I make a change to the code or XHTML files, I need to open the administrator panel of Glassfish and flush the connection pool, otherwise I get the following error when I just refresh the page. Has anybody experienced this? I can post code or other information if it is needed.
HTTP Status 500 -
type Exception report
message
descriptionThe server encountered an internal error () that prevented
it from fulfilling this request.
exception
javax.servlet.ServletException: WELD-000049 Unable to invoke [method]
#PostConstruct public
com.myapp.QuestionController.initialize() on
com.myapp.QuestionController#4635bd2a
root cause
org.jboss.weld.exceptions.WeldException: WELD-000049 Unable to invoke
[method] #PostConstruct public
com.myapp.interfaces.QuestionController.initialize() on
com.myapp.interfaces.QuestionController#4635bd2a
root cause
java.lang.reflect.InvocationTargetException
root cause
javax.ejb.EJBException
root cause
javax.persistence.PersistenceException: Exception [EclipseLink-4002]
(Eclipse Persistence Services - 2.3.0.v20110604-r9504):
org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: Error in allocating a connection.
Cause: java.lang.RuntimeException: Got exception during
XAResource.start: Error Code: 0
root cause
Exception [EclipseLink-4002] (Eclipse Persistence Services -
2.3.0.v20110604-r9504): org.eclipse.persistence.exceptions.DatabaseException Internal
Exception: java.sql.SQLException: Error in allocating a connection.
Cause: java.lang.RuntimeException: Got exception during
XAResource.start: Error Code: 0
root cause
java.sql.SQLException: Error in allocating a connection. Cause:
java.lang.RuntimeException: Got exception during XAResource.start:
root cause
javax.resource.spi.ResourceAllocationException: Error in allocating a
connection. Cause: java.lang.RuntimeException: Got exception during
XAResource.start:
root cause
com.sun.appserv.connectors.internal.api.PoolingException:
java.lang.RuntimeException: Got exception during XAResource.start:
root cause
com.sun.appserv.connectors.internal.api.PoolingException:
java.lang.RuntimeException: Got exception during XAResource.start:
root cause
java.lang.RuntimeException: Got exception during XAResource.start:
root cause
javax.transaction.xa.XAException:
com.sun.appserv.connectors.internal.api.PoolingException:
javax.resource.spi.LocalTransactionException: Communications link
failure
The last packet successfully received from the server was 435�409
milliseconds ago. The last packet sent successfully to the server was
7 milliseconds ago.
Image of config
Persistence XML
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="SertifikatPU" transaction-type="JTA">
<jta-data-source>jdbc/sertifikatdb</jta-data-source>
</persistence-unit>
</persistence>
In the "Additional properties" in Glassfish connection pool settings I have just configured: servername, URL, user and password.
I HAVE SOLVED THIS PROBLEM
I made my own dual table, similar to the one in Oracle.
CREATE TABLE dual
(
x VARCHAR(1)
);
INSERT INTO dual(x) VALUES('y');
Your root cause, PoolingException: javax.resource.spi.LocalTransactionException: Communications link failure is related to this Glassfish bug, which explains (in the comments tab at the bottom) that you may need to refresh your invalid connections.
The bug comment by Jagadish says to check your connection validation type. If it is set to "autocommit" (the default), the JDBC drivers may cache the prior connection validation data, and no actual database interaction will happen during future connection validations.
To resolve the problem, set connection-validation-method="table" and validation-table-name="any_table_you_know_exists" (replace any_table_you_know_exists with the name of any existing table). Doing this forces the connections to talk to the database instead of the cache; if the connection is invalid, it will be dropped and recreated. You may need to also specify is-connection-validation-required="true".
Articles to help with additional configuration:
This article also explains the problem in detail.
Jagadish's Oracle Blog Article on this topic has more info.
Article explaining Glassfish JDBC Connection Validation in detail.
Text from Jagadish's blog:
AS_INSTALL_ROOT/bin/asadmin set domain.resources.jdbc-connection-pool.DerbyPool.is-connection-validation-required=true
domain.resources.jdbc-connection-pool.DerbyPool.is-connection-validation-required = true
AS_INSTALL_ROOT/bin/asadmin set domain.resources.jdbc-connection-pool.DerbyPool.connection-validation-method=table
domain.resources.jdbc-connection-pool.DerbyPool.connection-validation-method = table
bin/asadmin set domain.resources.jdbc-connection-pool.DerbyPool.validation-table-name=sys.systables
domain.resources.jdbc-connection-pool.DerbyPool.validation-table-name = sys.systables
Note that the sample code refers to sys.systables, which is a MS SQL table that is guaranteed to exist. For Oracle, refer to the guaranteed table dual. For MySQL, create a 1-column table solely for validation purposes; play it safe and pre-populate the table by inserting one row of data.
Should you be using this driver?
com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
I see that you are using a different driver from the attached image ...

Categories