GlassFish无法使用NetBeans启动域

yzk*_*yzk 3 netbeans glassfish

所以,基本上:

我创建了一个域名 asadmin create-domain test

Enter admin user name [Enter to accept default "admin" / no password]>
Using default port 4848 for Admin.
Using default port 8080 for HTTP Instance.
Using default port 7676 for JMS.
Using default port 3700 for IIOP.
Using default port 8181 for HTTP_SSL.
Using default port 3820 for IIOP_SSL.
Using default port 3920 for IIOP_MUTUALAUTH.
Using default port 8686 for JMX_ADMIN.
Using default port 6666 for OSGI_SHELL.
Using default port 9009 for JAVA_DEBUGGER.
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=G62-120ey,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
Distinguished Name of the self-signed X.509 Server Certificate is:
[CN=G62-120ey-instance,OU=GlassFish,O=Oracle Corporation,L=Santa Clara,ST=California,C=US]
No domain initializers found, bypassing customization step
Domain test created.
Domain test admin port is 4848.
Domain test allows admin login as user "admin" with no password.
Command create-domain executed successfully.
Run Code Online (Sandbox Code Playgroud)

我启动域名 asadmin start-domain test

Waiting for test to start ......................
Successfully started the domain : test
domain  Location: I:\glassfish\glassfish\domains\test
Log File: I:\glassfish\glassfish\domains\test\logs\server.log
Admin Port: 4848
Command start-domain executed successfully.
Run Code Online (Sandbox Code Playgroud)

我停止域名 asadmin stop-domain test

Waiting for the domain to stop ..
Command stop-domain executed successfully.
Run Code Online (Sandbox Code Playgroud)

一切顺利.但是,如果我使用NetBeans:

打开Netbeans - >添加GlassFish服务器(域:测试) - >创建项目项目正确启动.

如果我重新启动NetBeans,GlassFish不会启动域,如果我尝试使用控制台启动域,asadmin start-domain test我会得到:

Waiting for test to start ...Error starting domain test.
The server exited prematurely with exit code 1.
Before it died, it produced the following output:

Launching GlassFish on Felix platform
Completed shutdown of GlassFish runtime
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 com.sun.enterprise.glassfish.bootstrap.GlassFishMain.main(GlassFishMain.java:97)
        at com.sun.enterprise.glassfish.bootstrap.ASMain.main(ASMain.java:55)Caused by: org.jvnet.hk2.component.ComponentException: Failed to create a habitat
        at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createHabitat(AbstractModulesRegistryImpl.java:169)
        at com.sun.enterprise.module.bootstrap.Main.createHabitat(Main.java:425)
        at org.jvnet.hk2.osgiadapter.HK2Main.createHabitat(HK2Main.java:96)
        at com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishRuntime.newGlassFish(EmbeddedOSGiGlassFishRuntime.java:89)
        at com.sun.enterprise.glassfish.bootstrap.GlassFishMain$Launcher.launch(GlassFishMain.java:113)
        ... 6 more
Caused by: java.lang.RuntimeException: Fatal Error.  Unable to parse file:/I:/glassfish/glassfish/domains/test/config/domain.xml
        at org.glassfish.config.support.DomainXml.parseDomainXml(DomainXml.java:273)
        at org.glassfish.config.support.DomainXml.run(DomainXml.java:112)
        at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.populateConfig(AbstractModulesRegistryImpl.java:176)
        at com.sun.enterprise.module.common_impl.AbstractModulesRegistryImpl.createHabitat(AbstractModulesRegistryImpl.java:158)
        ... 10 more
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[4,64]
Message: Invalid byte 1 of 1-byte UTF-8 sequence.
        at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
        at javax.xml.stream.util.StreamReaderDelegate.next(Unknown Source)
        at org.glassfish.config.support.XMLStreamReaderFilter.thisNextTag(XMLStreamReaderFilter.java:94)
        at org.glassfish.config.support.XMLStreamReaderFilter.nextTag(XMLStreamReaderFilter.java:74)

        at org.jvnet.hk2.config.ConfigParser.handleElement(ConfigParser.java:199)
        at org.jvnet.hk2.config.ConfigParser.handleElement(ConfigParser.java:215)
        at org.jvnet.hk2.config.ConfigParser.handleElement(ConfigParser.java:167)
        at org.jvnet.hk2.config.ConfigParser.parse(ConfigParser.java:98)
        at org.jvnet.hk2.config.ConfigParser.parse(ConfigParser.java:93)
        at org.glassfish.config.support.DomainXml.parseDomainXml(DomainXml.java:254)
        ... 13 more
Run Code Online (Sandbox Code Playgroud)

WWHHYYY

Ant*_*oly 5

您的domain.xml文件未使用UTF-8编码(也许您使用记事本或其他东西手动编辑它?).

解决方案:使用适当的工具将domain.xml文件转换为UTF-8编码.

参考: Code Ranch Post.

由于您使用的是Windows,因此可以使用UTFCast.

干杯,