小编l0r*_*c10的帖子

在抛出OutOfMemoryError时将JVM设置为转储堆

我正在尝试设置我正在处理的服务器的JVM,因此它会在发生OOME时将堆转储到文件中.

我知道我必须在-XX:-HeapDumpOnOutOfMemoryError某处向JVM参数添加此选项,但我无法知道如何执行此操作.

仅供参考,我可以通过PuTTY访问服务器,所以我正在寻找一种命令行方式.

我使用的JVM是OpenJDK64-Bit Server VM.

我不知道这是否相关,但应用程序是一个war文件.

PS : ps -ef|grep java

tomcat   23837     1  0 Mar25 ?        00:03:46 /usr/lib/jvm/jre/bin/java -classpath :/usr/share/tomcat6/bin/bootstrap.jar:/usr/share/tomcat6/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat6/temp -Djava.util.logging.config.file=/usr/share/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start
Run Code Online (Sandbox Code Playgroud)

编辑:

我找到了一些东西,如果我错了就纠正我:因为我使用的是Tomcat,所以我决定在tomcat.conf文件中添加这些行:

JAVA_OPTS = -XX:-HeapDumpOnOutOfMemoryError

JAVA_OPTS = -XX:HeapDumpPath = /根/转储

JAVA_OPTS = -Xmx20m

你怎么看 ?

java java-ee

8
推荐指数
2
解决办法
3万
查看次数

SAXParseException,无法读取架构文档

我的applicationContext.xml文件出了问题.

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xmlns:security="http://www.springframework.org/schema/security" xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd      
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">  

<import resource="classpath:spring/persistence.xml"/>

<context:annotation-config />
<context:component-scan base-package="com.sgcib.mrp.cva"/> 

<util:properties id="jdbcProps" location="jdbc.properties" />   

<bean id="propertyConfigurer"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
         <value>classpath:configuration.properties</value>
         <value>classpath:jdbc.properties</value>
        </list>
    </property>
</bean>
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

org.xml.sax.SAXParseException: schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/context/spring-context-3.1.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>.
Run Code Online (Sandbox Code Playgroud)

这是什么意思 ?

spring

8
推荐指数
1
解决办法
1万
查看次数

GWT:fileUpload.getFileName()&fakepath

我正在开发一个GWT项目(Web应用程序):

在某些时候,用户可以通过FormPanel通过应用程序上传文件.

因为我需要文件名,我想我可以使用:

    FileUpload upload = new FileUpload();
    // ...
    String name = upload.getFileName();
Run Code Online (Sandbox Code Playgroud)

name原来是这样的:C:\fakepath\whatever.txt.

这是跨平台吗?其他操作系统会发生什么(我正在使用Windows)?

java gwt cross-platform

5
推荐指数
1
解决办法
4673
查看次数

在PreparedStatement中重用参数?

我将参数传递给PreparedStatement,如下所示:

public void getNodes(String runId, File file, Connection conn) {
    PreparedStatement ps = null;
    ResultSet rs = null;
    try {
        ps = conn.prepareStatement(Mat.queries.get("NettingNode.QUERY"));

        ps.setString(1, runId);
        ps.setFetchSize(10000);
        rs = ps.executeQuery();

        // etc.
    } catch (Exception e) {
        logger.error(e, e);
    } finally {
        close(rs, ps);
    }
}
Run Code Online (Sandbox Code Playgroud)

查询看起来像这样:

select * from table_1 where run_id = ?
Run Code Online (Sandbox Code Playgroud)

现在我想像这样修改我的查询,并重用第一个参数(两者?都使用runId参数):

select * from table_1 where run_id = ?
union
select * from table_2 where run_id = ?
Run Code Online (Sandbox Code Playgroud)

没有这样做可能是这样的:

ps.setString(1, runId);
ps.setString(2, runId);
Run Code Online (Sandbox Code Playgroud)

java sql oracle prepared-statement

5
推荐指数
1
解决办法
1817
查看次数

Java片段输出未被理解,可能与多态性有关

我想知道为什么这一点Java会产生2而不是3:

public class Test {
    private static class A {
        int f(A a) {
            return 1;
        }
    }
    private static class B extends A {
        int f(A a) {
            return 2;
        }
        int f(B b) {
            return 3;
        }
    }

    public static void main(String[] astrArgs) {
        A ab = new B();
        B b = new B();

        System.out.println( ab.f(b) );  
    }
}
Run Code Online (Sandbox Code Playgroud)

我在一个测试问题中遇到过这个问题,并且无法得到它背后的逻辑.

java polymorphism

4
推荐指数
1
解决办法
113
查看次数

OutOfMemoryError java堆空间分析工具

我得到一个 OutOfMemoryError: Java heap space

有什么工具可以用来找出根本原因吗?

java profiling out-of-memory

4
推荐指数
1
解决办法
6595
查看次数

for循环:无法解析为变量

我想知道为什么我在尝试这样做时出现此错误:

Map<Integer, List<String>> map = (Map<Integer, List<String>>) parameters;

for(Integer i : map.keySet()) {
    tableFiles.setWidget(row, 0, addPanelFile(String.valueOf(i)));
    row++;
    for(map.get(i)) {

    }
}
Run Code Online (Sandbox Code Playgroud)

为什么我不能解决变量?

java

2
推荐指数
1
解决办法
2810
查看次数

sql请求中的标识符无效

我有这个SQL请求:

select T1.ID, T2.ID 
from task t1, task t2
join workcase w on W.ID = T1.WORKCASE_ID
where W.ID = 1683964476
and T1.STATE < 501
and T2.STATE = 501
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,我有这个错误:

ORA-00904: "T1"."WORKCASE_ID": invalid identifier
Run Code Online (Sandbox Code Playgroud)

这有什么不对?

sql oracle

2
推荐指数
1
解决办法
1137
查看次数

如何动态删除空查询参数?

我向 API 发送一些 get 查询,当我发送空查询参数时,该 API 返回400 Bad 请求

但是,我事先并不知道哪些可选查询参数将为空。除了测试每个可选参数是否为空之外,是否有更简单的方法来动态删除空参数?

目前我正在做:

private URI getApiUrl(QueryParametersObject qpo) {
    String url = configBundle.getPropertyStr("some.api.url");
    UriComponentsBuilder builder = UriComponentsBuilder
            .fromHttpUrl(url)
            .queryParam("mandatoryParam1", qpo.getMandatoryParam1())  // MANDATORY
            .queryParam("mandatoryParam2", qpo.getMandatoryParam2());  // MANDATORY
            
    if (!qpo.getOptionalParam1().isEmpty())
        builder.queryParam("optionalParam1", qpo.getOptionalParam1());
    if (!qpo.getOptionalParam2().isEmpty())
        builder.queryParam("optionalParam2", qpo.getOptionalParam2());
    if (!qpo.getOptionalParam3().isEmpty())
        builder.queryParam("optionalParam3", qpo.getOptionalParam3());
    return builder.build().encode().toUri();
}
Run Code Online (Sandbox Code Playgroud)

当可选查询参数的数量增加时,它可能会变得相当麻烦。

java rest http

1
推荐指数
1
解决办法
4366
查看次数

SQL查询即使找不到也返回一行,至少在参数中

我想写一个SQL查询(oracle)来了解一个操作(由ope.ope_operationid标识)是否至少具有某种类型的操作(opt.opt_id),如果没有,则表明它没有'在结果中.

例如,我有这个操作LAA351BP(我知道这个操作存在于base中),我想知道它是否至少有一个id为3781的操作类型.如果有,打印所有内容,如果没有,打印operationid和旁边的"找不到"之类的东西

是nvl使用的功能吗?看来我无法让它正常工作.

SELECT  DISTINCT ope.ope_operationid,
ser.ser_code,
opt.opt_code,
ost.ost_code
FROM    od_operation ope, 
od_service_type ser,
od_operation_type opt,
od_status_type ost,
od_equipment_type eqt,
WHERE   ope.ser_id = ser.ser_id
AND     opt.opt_id = ope.opt_id
AND     ost.ost_id = ope.ost_id
AND     ope.opt_id = 3781
AND     ope.ope_operationid = 'LAA351BP'
Run Code Online (Sandbox Code Playgroud)

谢谢

oracle

0
推荐指数
1
解决办法
702
查看次数

如何有效地在表中插入约500.000个数据行

我有大约500.000行数据要插入到一个表中.

我目前正在插入一个(我知道它很糟糕),如下所示:

道法:

public static final String SET_DATA = "insert into TABLE (D_ID, N_ID, VALUE, RUN_ID) " + "values (?, ?, ?, ?)";

public void setData(String dId, String nId, BigDecimal value, Run run) throws HibernateException {
    if (session == null) {
        session = sessionFactory.openSession();
    }

    SQLQuery select = session.createSQLQuery(SET_DATA);
    select.setString(0, dId);
    select.setString(1, nId);
    select.setBigDecimal(2, value);
    select.setLong(3, run.getRunId());

    select.executeUpdate();
}
Run Code Online (Sandbox Code Playgroud)

我怎样才能更有效地做到这一点?

java sql hibernate

0
推荐指数
1
解决办法
145
查看次数

MQ:已达到通道的最大实例数

我有一个连接到MQ的Java客户端,队列管理器抱怨The maximum number of instances, 50, of channel 'CHAN' was reached

在哪里以及如何在客户端代码或属性中找到由Java客户端创建的实例数?

java spring jms ibm-mq

0
推荐指数
1
解决办法
134
查看次数