Glassfish Admin Console throws java.lang.IllegalStateException when creating JDBC Pool

痞子三分冷 提交于 2019-11-27 06:44:55

According to the following JIRA tickets:

this is still an unresolved issue. Even though we can expect such things since Oracle abandoned a commercial support for Glassfish, it is still horrible that such basic functionality does not work.

However, if you are really desperate, there is a very nasty workaround. Glassfish arrives with a predefined JDBC pool DerbyPool that you probably won't need, unless you are dealing with Java DB. Feel free to edit it by changing Datasource classname to com.mysql.jdbc.jdbc2.optional.MysqlDataSource and adjusting additional properties to point on MySQL Server instance. Prior to doing this hack, make sure that you put MySQL connector to the Glassfish's lib folder.

UPDATE

Just noticed that there is a Glassfish version that has been patched, it is called Payara and available for download here. According to the documentation, it is a GlassFish 4.1 clone, patched and further developed by the community.

I`ve just rolled back to the 4.1.0 from 4.1.1 - works fine. Realy insane bug of GlassFish :(

Have the same problem, and this will surely make me choose an other application servers, why not tomee, jboss, wildfly, ...

Anyway here is an other workarround, just paste this peace of xml into domain.xml (between the others connection pool)

<jdbc-connection-pool connection-validation-method="auto-commit" datasource-classname="com.mysql.jdbc.jdbc2.optional.MysqlDataSource" wrap-jdbc-objects="false" res-type="javax.sql.DataSource" name="mysql_dbuser_rootPool">
      <property name="URL" value="jdbc:mysql://localhost:3306/ANYDB?zeroDateTimeBehavior=convertToNull"></property>
      <property name="driverClass" value="com.mysql.jdbc.Driver"></property>
      <property name="Password" value="THEPASS"></property>
      <property name="portNumber" value="3306"></property>
      <property name="databaseName" value="ANYDB"></property>
      <property name="User" value="THEUSER"></property>
      <property name="serverName" value="localhost"></property>
    </jdbc-connection-pool>

Hope that help

It is possible to manage JDBC connections with asadmin utility - AFAIK admin GUI is just a frontend to it.

The asadmin usage is described here: https://docs.oracle.com/cd/E26576_01/doc.312/e24928/jdbc.htm#GSADG00420

E.g.

asadmin> create-jdbc-connection-pool --datasourceclassname org.apache.derby.jdbc.ClientDataSource \\
  --restype javax.sql.XADataSource \\
  --property portNumber=1527:password=APP:user=APP:serverName=localhost:databaseName=sun-appserv-samples:connectionAttributes=\;create\\=true \\
  sample_derby_pool

Cheers,

This was a bug in GlassFish 4.1.1 as brothers have been mentioned, but it has been resolved in GlassFish 4.1.2 so you can simply download to it here, and for more info go here

If you are using Oracle just edit the file ..glassfish/domains/domain1/config/domain.xml. Look for the resources tag and add:

<jdbc-connection-pool datasource-classname="oracle.jdbc.pool.OracleConnectionPoolDataSource" name="MyPoolName" res-type="javax.sql.ConnectionPoolDataSource">
  <property name="User" value="UserName"></property>
  <property name="URL" value="jdbc:oracle:thin:@//localhost:1521/xe"></property>
  <property name="Password" value="UserPassword"></property>
</jdbc-connection-pool>

Dont forget to copy the jdbc driver in lib, and change the URL to your needs. Next start glassfish, go to JDBC Connection Pools and test your connection.

I had to do this in my assignment and was getting the same error while creating JDBC resources (Java runtime exception) and JDBC Connection pools (java.lang.IllegalStateException: getOutputStream() has already been called for this response)

I later realized this is a buggy version and our prof had already told us to use Glassfish 4.1 (https://glassfish.java.net/download-archive.html) and everything worked fine. If you don't have to use 4.1.1. please go for 4.1 instead.

The nightly build contains the fix!.You can download the nightly build from Oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!