简体   繁体   English

Glassfish 管理控制台在创建 JDBC 池时抛出 java.lang.IllegalStateException

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

A week ago I downloaded Glassfish 4.1.一周前,我下载了 Glassfish 4.1。 Did a zip install.做了一个zip安装。 Attempted to use Admin Console to create a JDBC Connection Pool.尝试使用管理控制台创建 JDBC 连接池。 Received this error message:收到此错误消息:

java.lang.IllegalStateException: getOutputStream() has already been called for this response

Lots of references to that error.大量引用该错误。 Lots of people declared it "Asked & Answered".很多人称它为“问与答”。 But I can't find a single reference anywhere to that problem, let alone a solution.但是我在任何地方都找不到该问题的参考,更不用说解决方案了。

But if anyone believes it's been answered, please be sure to add a link to the solution to this problem: New installation.但是,如果有人认为已得到解答,请务必添加指向此问题解决方案的链接:全新安装。 Did nothing but open the console and try to create a new JDBC Connection Pool.什么也没做,只是打开控制台并尝试创建一个新的 JDBC 连接池。

Resource Type: javax.sql.DataSource.  
Vendor: MySql. 

I've stored mysql-connector-java-5.1.35.jar in \\glassfish4\\glassfish\\lib我已经将 mysql-connector-java-5.1.35.jar 存储在 \\glassfish4\\glassfish\\lib

Here's the closest thing to a solution I found.这是最接近我找到的解决方案的东西。 But it was for GF v3.但它适用于 GF v3。

I finally have tracked down the actual problem in my domain.xml: -Dorg.glassfish.web.rfc2109_cookie_names_enforced=false was missing in the domain.xml created by asupgrade.我终于在我的 domain.xml 中-Dorg.glassfish.web.rfc2109_cookie_names_enforced=false了实际问题: -Dorg.glassfish.web.rfc2109_cookie_names_enforced=false在由 asupgrade 创建的 domain.xml 中丢失。 I just added it to the domain.xml jvm-options and GF v3 now works as expected.我刚刚将它添加到 domain.xml jvm-options 和 GF v3 现在按预期工作。 Added:添加:
<jvm-options>-Dorg.glassfish.web.rfc2109_cookie_names_enforced=false</jvm-options>

Tried that.试过了。 Didn't work.没用。 (I pasted the GF log entry to show the recommended line is added to the domain.xml GF used on startup.) (我粘贴了 GF 日志条目以显示推荐的行已添加到启动时使用的 domain.xml GF 中。)

I tried digging out domain.xml from my old v3 server and using it in the new v4.我尝试从旧的 v3 服务器中挖掘出 domain.xml 并在新的 v4 中使用它。 That didn't work.那没有用。

Other questions involving my Exception message all related to getting it with a deployed app -- mostly servlets.涉及我的异常消息的其他问题都与使用已部署的应用程序获取它有关——主要是 servlet。 But this is a clean server.但这是一个干净的服务器。 No apps have been installed.尚未安装任何应用程序。

I found a lot of links to people working on this Exception as a GF bug.我发现了很多链接到处理这个异常作为 GF 错误的人。 Most are awhile ago.大多数是前一段时间。 None gave a workaround or even said they'd ever solved it.没有人给出解决方法,甚至说他们曾经解决过这个问题。

Can anyone offer a solution?任何人都可以提供解决方案吗?
Or let me know if this is just a bug Oracle decided not to fix?或者让我知道这是否只是 Oracle 决定不修复的错误?
Or know of where I can find help?或者知道在哪里可以找到帮助? This is killing me.这要死我了。

In case it helps here is the GF log for a clean start up (with the jvm insert in the domain.xml.) It also shows the stack trace for the failed attempt to create a JDBC Connection Pool.如果它有帮助,这里是干净启动的 GF 日志(在 domain.xml 中插入 jvm。)它还显示了尝试创建 JDBC 连接池失败的堆栈跟踪。

NOTE: I pulled out all [INFO] log entries.注意:我提取了所有 [INFO] 日志条目。 And the [WARNING] entries that are left all seem related to Grizzly.剩下的 [警告] 条目似乎都与灰熊有关。

[2015-10-09T12:21:24.598-1000] [] [INFO] [NCLS-GFLAUNCHER-00005] [javax.enterprise.launcher] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1444429284598] [levelValue: 800] [[
  JVM invocation command line:
C:\Program Files\Java\jdk1.8.0_05\bin\java.exe
-cp
C:/glassfish4/glassfish/modules/glassfish.jar
-XX:+UnlockDiagnosticVMOptions
-XX:NewRatio=2
-XX:MaxPermSize=192m
-Xmx512m
-javaagent:C:/glassfish4/glassfish/lib/monitor/flashlight-agent.jar
-client
-Djavax.xml.accessExternalSchema=all
-Djavax.net.ssl.trustStore=C:\glassfish4\glassfish\domains\domain1/config/cacerts.jks
-Djdk.corba.allowOutputStreamSubclass=true
-Dfelix.fileinstall.dir=C:\glassfish4\glassfish/modules/autostart/
-Dorg.glassfish.additionalOSGiBundlesToStart=org.apache.felix.shell,org.apache.felix.gogo.runtime,org.apache.felix.gogo.shell,org.apache.felix.gogo.command,org.apache.felix.shell.remote,org.apache.felix.fileinstall
-Dcom.sun.aas.installRoot=C:\glassfish4\glassfish
-Dfelix.fileinstall.poll=5000
-Djava.endorsed.dirs=C:\glassfish4\glassfish/modules/endorsed;C:\glassfish4\glassfish/lib/endorsed
-Djava.security.policy=C:\glassfish4\glassfish\domains\domain1/config/server.policy
-Dosgi.shell.telnet.maxconn=1
-Dfelix.fileinstall.bundles.startTransient=true
-Dcom.sun.enterprise.config.config_environment_factory_class=com.sun.enterprise.config.serverbeans.AppserverConfigEnvironmentFactory
-Dfelix.fileinstall.log.level=2
-Dorg.glassfish.web.rfc2109_cookie_names_enforced=false
-Djavax.net.ssl.keyStore=C:\glassfish4\glassfish\domains\domain1/config/keystore.jks
-Djava.security.auth.login.config=C:\glassfish4\glassfish\domains\domain1/config/login.conf
-Dfelix.fileinstall.disableConfigSave=false
-Dfelix.fileinstall.bundles.new.start=true
-Dcom.sun.aas.instanceRoot=C:\glassfish4\glassfish\domains\domain1
-Dosgi.shell.telnet.port=6666
-Dgosh.args=--nointeractive
-Dcom.sun.enterprise.security.httpsOutboundKeyAlias=s1as
-Dosgi.shell.telnet.ip=127.0.0.1
-DANTLR_USE_DIRECT_CLASS_LOADING=true
-Djava.awt.headless=true
-Dcom.ctc.wstx.returnNullForDefaultNamespace=true
-Djava.ext.dirs=C:\Program Files\Java\jdk1.8.0_05/lib/ext;C:\Program Files\Java\jdk1.8.0_05/jre/lib/ext;C:\glassfish4\glassfish\domains\domain1/lib/ext
-Djdbc.drivers=org.apache.derby.jdbc.ClientDriver
-Djava.library.path=C:/glassfish4/glassfish/lib;C:/ProgramData/Oracle/Java/javapath;C:/Windows/Sun/Java/bin;C:/Windows/System32;C:/Windows;C:/glassfish4/glassfish/ C:/Program Files/Dell/Dell Data Protection/Drivers/TSS/bin;C:/Program Files (x86)/Common Files/Intuit/QBPOSSDKRuntime;C:/Program Files (x86)/QuickTime/QTSystem;D:/Bulletproof/bpMySql/bin;C:/glassfish4/glassfish
com.sun.enterprise.glassfish.bootstrap.ASMain
-upgrade
false
-domaindir
C:/glassfish4/glassfish/domains/domain1
-read-stdin
true
-asadmin-args
--host,,,localhost,,,--port,,,4848,,,--secure=false,,,--terse=false,,,--echo=false,,,--interactive=true,,,start-domain,,,--verbose=false,,,--watchdog=false,,,--debug=false,,,--domaindir,,,C:\glassfish4\glassfish\domains,,,domain1
-domainname
domain1
-instancename
server
-type
DAS
-verbose
false
-asadmin-classpath
C:/glassfish4/glassfish/lib/client/appserver-cli.jar
-debug
false
-asadmin-classname
com.sun.enterprise.admin.cli.AdminMain]]

 [2015-10-09T12:21:27.864-1000] [glassfish 4.1] [WARNING] [] [org.glassfish.grizzly.config.Utils] [tid: _ThreadID=17 _ThreadName=RunLevelControllerThread-1444429287050] [timeMillis: 1444429287864] [levelValue: 900] [[
  Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-1, realClassName=org.glassfish.grizzly.http2.Http2AddOn]]

[2015-10-09T12:21:27.962-1000] [glassfish 4.1] [WARNING] [] [org.glassfish.grizzly.config.Utils] [tid: _ThreadID=17 _ThreadName=RunLevelControllerThread-1444429287050] [timeMillis: 1444429287962] [levelValue: 900] [[
  Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-2, realClassName=org.glassfish.grizzly.http2.Http2AddOn]]

[2015-10-09T12:21:27.970-1000] [glassfish 4.1] [WARNING] [] [org.glassfish.grizzly.config.Utils] [tid: _ThreadID=17 _ThreadName=RunLevelControllerThread-1444429287050] [timeMillis: 1444429287970] [levelValue: 900] [[
  Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=admin-listener, realClassName=org.glassfish.grizzly.http2.Http2AddOn]]

[2015-10-09T12:21:31.120-1000] [glassfish 4.1] [WARNING] [] [org.glassfish.grizzly.config.Utils] [tid: _ThreadID=75 _ThreadName=pool-13-thread-1] [timeMillis: 1444429291120] [levelValue: 900] [[
  Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-1, realClassName=org.glassfish.grizzly.http2.Http2AddOn]]

[2015-10-09T12:21:31.135-1000] [glassfish 4.1] [WARNING] [] [org.glassfish.grizzly.config.Utils] [tid: _ThreadID=75 _ThreadName=pool-13-thread-1] [timeMillis: 1444429291135] [levelValue: 900] [[
  Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-2, realClassName=org.glassfish.grizzly.http2.Http2AddOn]]

[2015-10-09T12:21:37.895-1000] [glassfish 4.1] [WARNING] [] [javax.enterprise.system.container.web.com.sun.web.security] [tid: _ThreadID=48 _ThreadName=admin-listener(4)] [timeMillis: 1444429297895] [levelValue: 900] [[
  Context path from ServletContext:  differs from path from bundle: /]]

 [2015-10-09T12:22:46.963-1000] [glassfish 4.1] [WARNING] [] [javax.enterprise.web] [tid: _ThreadID=48 _ThreadName=admin-listener(4)] [timeMillis: 1444429366963] [levelValue: 900] [[
  StandardWrapperValve[FacesServlet]: Servlet.service() for servlet FacesServlet threw exception
java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at org.apache.catalina.connector.Response.getWriter(Response.java:777)
    at org.apache.catalina.connector.ResponseFacade.getWriter(ResponseFacade.java:224)
    at com.sun.faces.context.ExternalContextImpl.getResponseOutputWriter(ExternalContextImpl.java:851)
    at com.sun.faces.context.PartialViewContextImpl.createPartialResponseWriter(PartialViewContextImpl.java:504)
    at com.sun.faces.context.PartialViewContextImpl.access$300(PartialViewContextImpl.java:79)
    at com.sun.faces.context.PartialViewContextImpl$DelayedInitPartialResponseWriter.getWrapped(PartialViewContextImpl.java:642)
    at javax.faces.context.PartialResponseWriter.startDocument(PartialResponseWriter.java:120)
    at com.sun.faces.context.AjaxExceptionHandlerImpl.handlePartialResponseError(AjaxExceptionHandlerImpl.java:202)
    at com.sun.faces.context.AjaxExceptionHandlerImpl.handle(AjaxExceptionHandlerImpl.java:127)
    at javax.faces.context.ExceptionHandlerWrapper.handle(ExceptionHandlerWrapper.java:100)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:119)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:344)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:233)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:316)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
    at org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:678)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:97)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
    at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
    at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
    at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
    at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
    at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
    at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
    at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
    at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
    at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
    at java.lang.Thread.run(Thread.java:745)
]]

According to the following JIRA tickets:根据以下JIRA门票:

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.尽管我们可以期待这样的事情,因为Oracle 放弃了对 Glassfish 的商业支持,但这样的基本功能不起作用仍然很可怕。

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. Glassfish 附带了一个预定义的 JDBC 池DerbyPool ,除非您正在处理 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.通过将数据源类名更改为com.mysql.jdbc.jdbc2.optional.MysqlDataSource并调整其他属性以指向 MySQL 服务器实例,可以随意编辑它。 Prior to doing this hack, make sure that you put MySQL connector to the Glassfish's lib folder.在进行此 hack 之前,请确保将 MySQL 连接器放入 Glassfish 的 lib 文件夹中。

UPDATE更新

Just noticed that there is a Glassfish version that has been patched, it is called Payara and available for download here .刚刚注意到有一个已打补丁的 Glassfish 版本,名为 Payara,可在此处下载。 According to the documentation, it is a GlassFish 4.1 clone, patched and further developed by the community.根据文档,它是 GlassFish 4.1 克隆,由社区修补和进一步开发。

I`ve just rolled back to the 4.1.0 from 4.1.1 - works fine.我刚刚从 4.1.1 回滚到 4.1.0 - 工作正常。 Realy insane bug of GlassFish :( GlassFish 的真正疯狂的错误 :(

Have the same problem, and this will surely make me choose an other application servers, why not tomee, jboss, wildfly, ...有同样的问题,这肯定会让我选择其他应用服务器,为什么不tomee,jboss,wildfly,...

Anyway here is an other workarround, just paste this peace of xml into domain.xml (between the others connection pool)无论如何,这是另一种解决方法,只需将 xml 的和平粘贴到 domain.xml 中(在其他连接池之间)

<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.可以使用asadmin实用程序管理 JDBC 连接 - AFAIK 管理 GUI 只是它的前端。

The asadmin usage is described here: https://docs.oracle.com/cd/E26576_01/doc.312/e24928/jdbc.htm#GSADG00420此处描述了asadmin用法: https : //docs.oracle.com/cd/E26576_01/doc.312/e24928/jdbc.htm#GSADG00420

Eg例如

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,干杯,

这是兄弟们提到的GlassFish 4.1.1中的错误,但它已在GlassFish 4.1.2解决,因此您可以简单地在此处下载,有关更多信息,请转到此处

If you are using Oracle just edit the file ..glassfish/domains/domain1/config/domain.xml.如果您使用 Oracle,只需编辑文件 ..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.不要忘记复制 lib 中的 jdbc 驱动程序,并将 URL 更改为您的需要。 Next start glassfish, go to JDBC Connection Pools and test your connection.接下来启动 glassfish,转到 JDBC 连接池并测试您的连接。

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)我必须在我的作业中执行此操作,并且在创建 JDBC 资源(Java 运行时异常)和 JDBC 连接池(java.lang.IllegalStateException: getOutputStream() 已为此响应调用)时遇到相同的错误

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.后来我意识到这是一个有问题的版本,我们的教授已经告诉我们使用 Glassfish 4.1 ( https://glassfish.java.net/download-archive.html ) 并且一切正常。 If you don't have to use 4.1.1.如果您不必使用 4.1.1。 please go for 4.1 instead.请改用 4.1。

每晚构建包含修复!您可以从 Oracle 下载每晚构建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM