如何在 Eclipse 中增加 WebSphere Application Server V8.5 Liberty Profile 的堆大小?

How to increase the heap size of WebSphere Application Server V8.5 Liberty Profile in Eclipse?

我在 eclipse 中有一个 WebSphere Application Server V8.5 Liberty Profile。我的网络应用程序一直在提供 java.lang.OutOfMemoryError,因此我需要增加堆大小。

根据 this and this post 的建议,我更改了 server.xml,添加了 jvmEntries 标签(之前没有):

<server description="new server">

    <!-- Enable features -->
    <featureManager>
        <feature>jsp-2.2</feature>
        <feature>localConnector-1.0</feature>
        <feature>jpa-2.0</feature>
    </featureManager>

    <!-- To access this server from a remote client add a host attribute to 
        the following element, e.g. host="*" -->
    <httpEndpoint httpPort="9080" httpsPort="9443"  id="defaultHttpEndpoint" />

    <jvmEntries initialHeapSize="1024" maximumHeapSize="2048" />
    <applicationMonitor updateTrigger="mbean" />
    <webApplication id="app" location="app.war"
        name="app" />
</server>

但 eclipse 将其显示为无效标签,并出现以下错误:

cvc-complex-type.2.4.a: Invalid content was found starting with element 'jvmEntries'. One of '{include, variable, trustAssociation, applicationMonitor, application, classloading, basicRegistry, bundleRepository, osgiApplication, authentication, authCache, jaasLoginModule, jaasLoginContextEntry, cdiContainer, channelfw, tcpOptions, library, collectiveMember, hostAuthInfo, managedExecutorService, connectionManager, contextService, distributedMap, enterpriseApplication, webApplication, httpDispatcher, mimeTypes, httpEncoding, virtualHost, httpOptions, httpAccessLogging, httpEndpoint, authData, dataSource, jdbcDriver, jndiEntry, jpa, jspEngine, fileset, executor, featureManager, config, customLdapFilterProperties, edirectoryLdapFilterProperties, domino50LdapFilterProperties, netscapeLdapFilterProperties, ldapRegistry, securewayLdapFilterProperties, iplanetLdapFilterProperties, idsLdapFilterProperties, activedLdapFilterProperties, logging, ltpa, ejbContainer, monitor, oauthProvider, oauth-roles, remoteFileAccess, administrator-role,
quickStartSecurity, pluginConfiguration, webContainer, httpSession, httpSessionDatabase, sslDefault, keyStore, ssl, sslOptions, timedOperation, transaction, webAppSecurity, federatedRepository, zosLogging, authorization-roles}' is expected.

那我应该如何增加堆大小?

正确的做法是在服务器目录中创建 jvm.options 文件,内容如下:

-Xms512m
-Xmx1024m

勾选这个linkCustomizing the Liberty profile environment

在 Eclipse 中,您可以在 Servers 视图中右键单击服务器,然后 select New > Server Environment File > jvm.options

Liberty 配置文件与常规的 WebSphere 配置文件略有不同。您需要按照以下说明配置 jvm.options 文件:

IBM Setting generic JVM arguments in the WebSphere Application Server V8.5 Liberty profile

Customizing the Liberty profile environment