Maven - StackOverflowError

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/lewky_liu/article/details/89740268

问题与分析

今天发现服务器上的Jenkins在集成项目时报错,报错原因如下:

error compiling: java.lang.StackOverflowError -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

还是头回遇到这种错误,由于Jenkins每天晚上都会自动集成当天提交的代码。之前一直编译正常,而今天编译报错,正好昨天我提交了代码上去。

很显然,这是由于我提交的代码造成的。一开始以为是项目代码有问题,比如无限递归之类的导致的堆栈溢出。但是在本地发现可以正常运行该Maven项目,无论是编译还是打包都一切正常。难道是Jenkins抽风了?于是重启了Jenkins任务去重新编译一次项目,结果再次挂了,报了同样的错误。

百度之后发现挺多人都遇到这种问题,原因也基本一样,都是因为jvm内存不足导致的堆栈溢出。仔细想想,确实很有可能,因为我在本地是通过eclipse来运行项目的,我在本地配置了足够的jvm参数;而服务器上则可能由于Jenkins同时运行多个任务,又或者配置的内存不够,所以就编译报错了。

再一次审视我昨晚提交的代码,发现在一个测试类里,有个方法调用了非常多的api,这个方法的方法体里大概调用了四百多个api。之所以会方法体这么长,是因为该方法用来测试某个pojo类里的字段是否和数据库里的字段能否匹配上。因为pojo里的字段有四百多个,所以就导致该方法体如此之冗长了。

也就是说,很有可能是该方法导致Jenkins在运行该测试类的该方法时调用api过多导致堆栈溢出了。于是重新修改了代码,将该方法里调用的api分别放到了另外两个方法里,大概一个方法里调用两百个api,然后测试类原来的方法则调用这两个新添加的方法。

之后提交代码,重新让Jenkins集成代码,发现不再报错。

解决方法

和老大讨论之后,决定采用修改代码的方式去fix这个问题。可能是处于服务器内存紧张的考虑,又或者是别的什么因素,不采用网友博文里说的加大jvm参数的方案。

这里还是总结下这两个方案:

方案一

在项目的启动脚本里加大jvm参数,如下:

set MAVEN_OPTS=-Xss4096k

也可以不用设置得那么大,比如设置成下面这样:

set MAVEN_OPTS=-Xss2m

方案二

修改代码内某个调用了过多api的方法,可以将其一分为二,拆分成多个子方法,各自调用一部分的api,最后由原来的方法来call这几个拆分开来的子方法。总之,应当避免在一个方法内调用过多api。

其他

这里顺便贴一下公司项目设置的参数:

echo off
setlocal
set MAVEN_DEBUG_OPTS=-Duser.timezone=GMT+8 -Xdebug -Xmx4096M -XX:PermSize=128M -XX:MaxPermSize=512M -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8088,server=y,suspend=n
mvn spring-boot:run
endlocal

参考链接

展开阅读全文

StackOverflowError (set,get)

06-20

我明白上面的意思是: 堆栈溢出....下面是这个程序: 有点长....希望你忙里抽闲,能看一看...谢谢[code=Java]package com.io.Zip;rnimport javax.swing.*;rnpublic class ZipTest rnrn /**rn * @param argsrn */rn public static void main(String[] args) rn rn ZipFrame frame=new ZipFrame();rn frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn frame.setVisible(true);rn rn rnpackage com.io.Zip;rnrnimport javax.swing.*;rnrnimport java.awt.BorderLayout;rnimport java.awt.event.ActionEvent;rnimport java.awt.event.ActionListener;rnrnpublic class ZipFrame extends JFrame rn public ZipFrame()rn setTitle("ZipTest");rn setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);rn JMenuBar menuBar=new JMenuBar();rn rn JMenu menu=new JMenu("打开");rn menuBar.add(menu);rn openItem=new JMenuItem("打开");rn openItem.addActionListener(new FileAction());rn menu.add(openItem);rn rn JMenuItem exitItem=new JMenuItem("退出");rn menu.add(exitItem);rn exitItem.addActionListener(new ActionListener()rn rn public void actionPerformed(ActionEvent e)rn System.exit(0);rn rnrn rn );rn setJMenuBar(menuBar);rn fileText=new JTextArea();rn rn fileCombo=new JComboBox();rn fileCombo.addActionListener(new FileAction());rn rn add(fileCombo,BorderLayout.SOUTH);rn add(new JScrollPane(fileText),BorderLayout.CENTER);rn rn public JComboBox getFileCombo() rn return fileCombo;rn rn public void setFileCombo(JComboBox fileCombo) rn this.fileCombo = fileCombo;rn rn public JMenuItem getOpenItem() rn return openItem;rn rn public void setOpenItem(JMenuItem openItem) rn this.openItem = openItem;rn rn public JTextArea getFileText() rn return fileText;rn rn rn public static final int DEFAULT_WIDTH=400;rn public static final int DEFAULT_HEIGHT=300;rn private JTextArea fileText;rn private JComboBox fileCombo;rn private JMenuItem openItem;rn rn rn rnpackage com.io.Zip;rnrnimport java.io.File;rnimport java.util.ArrayList;rnrnimport javax.swing.filechooser.FileFilter;rnrnpublic class ExtensionFileFilter extends FileFilter rnrn public void addExtension(String extension)rn if(!extension.startsWith("."))rn extension="."+extension;rn extension.toLowerCase();rn rn public void setDescription(String description) rn this.description = description;rn rn public String getDescription()rn return description;rn rn @Overridern public boolean accept(File f) rn if(f.isDirectory()) return true;rn String name=f.getName().toLowerCase();rn for(String e :extensions)rn if(name.endsWith(e))rn return true;rn rn return false;rn rnrnrn private String description="";rn private ArrayList extensions=new ArrayList();rnrnpackage com.io.Zip;rnrnimport java.awt.event.ActionEvent;rnimport java.awt.event.ActionListener;rnimport java.io.*;rnimport java.util.zip.ZipEntry;rnimport java.util.zip.ZipInputStream;rnrnimport javax.swing.*;rnpublic class FileAction implements ActionListener rnrn @Overridern public void actionPerformed(ActionEvent e) rn if(frame.getOpenItem()==e.getSource())rn openFile();rn rn if(frame.getFileCombo()==e.getSource())rn loadFile((String)frame.getFileCombo().getSelectedItem());rn rnrn rn private void loadFile(String name) rn try rn ZipInputStream zin=new ZipInputStream(new FileInputStream(zipname));rn ZipEntry entry;rn frame.getFileText().setText("");rn while((entry=zin.getNextEntry())!=null)rn if(entry.getName().equals(name))rn BufferedReader in=new BufferedReader(new InputStreamReader(zin));rn String line ;rn while((line=in.readLine())!=null)rn frame.getFileText().append(line);rn frame.getFileText().append("/n");rn rn rn rn rn catch (FileNotFoundException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (IOException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn rn private void openFile()rn JFileChooser chooser=new JFileChooser();rn chooser.setCurrentDirectory(new File("."));rn ExtensionFileFilter filter=new ExtensionFileFilter();rn filter.addExtension(".zip");rn filter.addExtension(".jar");rn filter.setDescription("ZIP 文件");rn chooser.setFileFilter(filter);rn int r=chooser.showOpenDialog(frame);rn if(r==JFileChooser.APPROVE_OPTION)rn zipname=chooser.getSelectedFile().getPath();rn scanFile();rn rn rn rn private void scanFile()rn frame.getFileCombo().removeAllItems();rn try rn ZipInputStream zin=new ZipInputStream(new FileInputStream(zipname));rn ZipEntry entry;rn while((entry=zin.getNextEntry())!=null)rn frame.getFileCombo().addItem(entry.getName());rn zin.closeEntry();rn rn zin.close();rn catch (FileNotFoundException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn catch (IOException e) rn // TODO Auto-generated catch blockrn e.printStackTrace();rn rn rn rn private ZipFrame frame=new ZipFrame();rn private String zipname;rnrnrn[/code] 这个程序的作用是: 用一Frame 通过"打开"菜单项打开一个文件选择器...选择ZIP文件并且...读取显示在文本区域: 下面是异常.rnException in thread "main" java.lang.StackOverflowError rnat sun.awt.Win32GraphicsConfig.getBounds(Native Method) rnat sun.awt.Win32GraphicsConfig.getBounds(Unknown Source) rnat java.awt.Window.init(Unknown Source) rnat java.awt.Window. (Unknown Source) rnat java.awt.Frame. (Unknown Source) rnat java.awt.Frame. (Unknown Source) rnat javax.swing.JFrame. (Unknown Source)rnrn[color=#FF0000]我希望你能告诉我好的模式来用set get 如果你能改改,就最好了...不盛感激![/color] 论坛

StackOverflowError 应该没用到递归

06-18

总共有四个类rnZipTest[code=Java]ZipFrame frame=new ZipFrame();rn frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);rn frame.setVisible(true);[/code]rnZipFrmae [code=Java]public class ZipFrame extends JFrame rn public ZipFrame()rn setTitle("ZipTest");rn setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT);rn JMenuBar menuBar=new JMenuBar();rn rn JMenu menu=new JMenu("打开");rn menuBar.add(menu);rn openItem=new JMenuItem("打开");rn openItem.addActionListener(new FileAction()); [color=#FF0000] //这里报错[/color]rn menu.add(openItem);rn rn JMenuItem exitItem=new JMenuItem("退出");rn menu.add(exitItem);rn exitItem.addActionListener(new ActionListener()rn rn public void actionPerformed(ActionEvent e)rn System.exit(0);rn rnrn rn );rn setJMenuBar(menuBar);rn fileText=new JTextArea();rn rn fileCombo=new JComboBox();rn fileCombo.addActionListener(new FileAction()); [color=#FF0000]//这里报错[/color]rn rn add(fileCombo,BorderLayout.SOUTH);rn add(new JScrollPane(fileText),BorderLayout.CENTER);rn rn public JComboBox getFileCombo() rn return fileCombo;rn rn public void setFileCombo(JComboBox fileCombo) rn this.fileCombo = fileCombo;rn rn public JMenuItem getOpenItem() rn return openItem;rn rn public void setOpenItem(JMenuItem openItem) rn this.openItem = openItem;rn rn public JTextArea getFileText() rn return fileText;rn rn rn public static final int DEFAULT_WIDTH=400;rn public static final int DEFAULT_HEIGHT=300;rn private JTextArea fileText;rn private JComboBox fileCombo;rn private JMenuItem openItem;[/code]rn还有个事情类...rn[code=Java]rn private ZipFrame frame=new ZipFrame(); [color=#FF0000]//这里报错[/color]rn private String zipname;[/code]rn 论坛

StackOverflowError! 第一次碰到,求助!

01-04

我写的一个java程序,主界面可以正常得出来,可是当点先“圆”这个选项时,就出现了rnStackOverflowError,第一次碰到,大家有什么好的解决办法吗??现把代码贴出,共四个文件:rnrn//MainFrame.javarnrnimport java.awt.*;rnimport java.awt.event.*;rnrnpublic class MainFrame extends Frame implements ActionListener rn public MainFrame()rn super("计算机图形学课程设计V1.0");rn creatUI(); rn creatMenuBar();rn setVisible(true);rn rnrn protected void creatUI()rn Panel mainPanel = new Panel();rn Label mainLabel = new Label();rn rnrn mainLabel.setText("计算机图形学课程设计");rn //mainPanel.setLayout(new FlowLayout(FlowLayout.CENTER));rn mainPanel.add(mainLabel);rn //this.setLayout(new BorderLayout());rn this.add(mainPanel);rn rn setSize(500,400);rn center();rn rn addWindowListener(new WindowAdapter()rn public void windowClosing(WindowEvent e)rn dispose();rn System.exit(0); rn rn );rn rnrn public void center()rn Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();rn Dimension frameSize = getSize();rn int x = (screenSize.width - frameSize.width)/2;rn int y = (screenSize.height - frameSize.height)/2;rn setLocation(x,y); rn rn rn public void creatMenuBar()rn MenuBar mb = new MenuBar();rn rn Menu m1 = new Menu("基本图形生成");rn Menu m2 = new Menu("多边形区域填充"); rn Menu m3 = new Menu("二维变换");rn Menu m4 = new Menu("其他");rn rn MenuItem mi11 = new MenuItem("直线"); rn MenuItem mi12 = new MenuItem("圆"); mi12.addActionListener(this);rn MenuItem mi13 = new MenuItem("椭圆");rn rn MenuItem mi21 = new MenuItem("有效边表算法");rn MenuItem mi22 = new MenuItem("边缘填充算法");rn MenuItem mi23 = new MenuItem("区域填充");rn rn MenuItem mi31 = new MenuItem("待填...");rn rn MenuItem mi41 = new MenuItem("关于");rn MenuItem mi42 = new MenuItem("退出"); mi42.addActionListener(this);rn rn m1.add(mi11); m1.add(mi12); m1.add(mi13);rn m2.add(mi21); m2.add(mi22); m2.add(mi23);rn m3.add(mi31);rn m4.add(mi41); m4.addSeparator(); m4.add(mi42);rn rn mb.add(m1); mb.add(m2); mb.add(m3); mb.add(m4);rn rn setMenuBar(mb);rn rnrn rn public static void main(String args[])rn new MainFrame(); rn rn rn public void actionPerformed(ActionEvent e)rn if(e.getActionCommand()=="退出")rn System.exit(0);rn rn if(e.getActionCommand()=="圆")rn new Circle();rn rn rnrn//***************************************************rnrn//Circle.javarn/*rn * 创建日期 2005-1-4rn *rn * 更改所生成文件模板为rn * 窗口 > 首选项 > Java > 代码生成 > 代码和注释rn */rnrn/**rn * @author Administratorrn *rn * 更改所生成类型注释的模板为rn * 窗口 > 首选项 > Java > 代码生成 > 代码和注释rn */rnrnimport java.awt.*;rnimport java.awt.geom.*;rn//import DrawPixel;rnrnpublic class Circle extends ApplicationFramernrn public Circle()rn Circle c = new Circle(); rn Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();rn rn c.setSize(screenSize.width,screenSize.height);rn c.setLocation(0,0);rn c.setVisible(true);rn rnrn public void paint(Graphics g)rnrn MidBresenhamcircle(300,g);rn rn rn rn public void MidBresenhamcircle(int r,Graphics g)rn int x,y,d;rn x=0+300;rn y=r+300;rn d=1-r;rn while(x 论坛

关于StackOverflowError问题

03-23

以下是在报错信息rnrnException in thread "main" java.lang.StackOverflowErrorrn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(Unknown Source)rn at sun.misc.Launcher$ExtClassLoader.findClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.defineClass1(Native Method)rn at java.lang.ClassLoader.defineClassCond(Unknown Source)rn at java.lang.ClassLoader.defineClass(Unknown Source)rn at java.security.SecureClassLoader.defineClass(Unknown Source)rn at java.net.URLClassLoader.defineClass(Unknown Source)rn at java.net.URLClassLoader.access$000(Unknown Source)rn at java.net.URLClassLoader$1.run(Unknown Source)rn ...rn (中间太多类似信息)rn ...rn at java.net.URLClassLoader.findClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.defineClass1(Native Method)rn at java.lang.ClassLoader.defineClassCond(Unknown Source)rn at java.lang.ClassLoader.defineClass(Unknown Source)rn at java.security.SecureClassLoader.defineClass(Unknown Source)rn at java.net.URLClassLoader.defineClass(Unknown Source)rn at java.net.URLClassLoader.access$000(Unknown Source)rn at java.net.URLClassLoader$1.run(Unknown Source)rn at java.security.AccessController.doPrivileged(Native Method)rn at java.net.URLClassLoader.findClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at java.lang.ClassLoader.loadClass(Unknown Source)rn at sfa.a(sfa.java:38)rn at twa.(twa.java:98)rn at kaa.a(kaa.java:50)rn at ko.a(ko.java:211)rn at kaa.(kaa.java:120)rn at ko.a(ko.java:211)rn at oga.(oga.java:66)rn at ra.(ra.java:583)rn at ko.(ko.java:223)rn at kk.(kk.java:82)rn at hv.(hv.java:419)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)rn at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)rn at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)rn at java.lang.reflect.Constructor.newInstance(Unknown Source)rn at java.lang.Class.newInstance0(Unknown Source)rn at java.lang.Class.newInstance(Unknown Source)rn at Loder.(Loder.java:70)rn at Loder.main(Loder.java:225)rnrnrnrn 以下是部分代码:rnrnFile clientj = new File("client.jar");rnURLClassLoader cl = new URLClassLoader(new URL[]clientj.toURI().toURL()rn );rn Class clientc = cl.loadClass("client");rn Object clientobj = clientc.newInstance(); //报错部分显示是在创建实例中出错rn 求大大帮忙看看!rnrnrnrnrnrnrnrnrn 论坛

JBoss启动出现StackOverflowError异常

11-16

JBoss 3.0.6启动过程中出现如下的异常。但是删除 deploy/lib下面db2驱动包又能正常。rn请问这个异常是怎么引起的?rn异常信息如下:rn===============================================================================rn.rn JBoss Bootstrap Environmentrn.rn JBOSS_HOME: D:\jboss3.0.6\bin\\..rn.rn JAVA: D:\java\j2sdk1.4.2_05\bin\javarn.rn JAVA_OPTS: -Dprogram.name=run.batrn.rn CLASSPATH: ;D:\java\j2sdk1.4.2_05\lib\tools.jar;D:\jboss3.0.6\bin\\run.jarrn.rn===============================================================================rn.rn10:29:55,484 INFO [Server] JBoss Release: JBoss-3.0.6 CVSTag=JBoss_3_0_6rn10:29:55,500 INFO [Server] Home Dir: D:\jboss3.0.6rn10:29:55,500 INFO [Server] Home URL: file:/D:/jboss3.0.6/rn10:29:55,500 INFO [Server] Library URL: file:/D:/jboss3.0.6/lib/rn10:29:55,500 INFO [Server] Patch URL: nullrn10:29:55,515 INFO [Server] Server Name: defaultrn10:29:55,515 INFO [Server] Server Home Dir: D:\jboss3.0.6\server\defaultrn10:29:55,515 INFO [Server] Server Home URL: file:/D:/jboss3.0.6/server/default/rnrn10:29:55,515 INFO [Server] Server Data Dir: D:\jboss3.0.6\server\default\dbrn10:29:55,515 INFO [Server] Server Temp Dir: D:\jboss3.0.6\server\default\tmprn10:29:55,515 INFO [Server] Server Config URL: file:/D:/jboss3.0.6/server/defaulrnt/conf/rn10:29:55,515 INFO [Server] Server Library URL: file:/D:/jboss3.0.6/server/defaurnlt/lib/rn10:29:55,515 INFO [Server] Root Deployemnt Filename: jboss-service.xmlrn10:29:55,531 INFO [Server] Starting General Purpose Architecture (GPA)...rn10:29:55,828 INFO [ServerInfo] Java version: 1.4.2_05,Sun Microsystems Inc.rn10:29:55,828 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 1.4.2_05-b04rn,Sun Microsystems Inc.rn10:29:55,828 INFO [ServerInfo] OS-System: Windows 2000 5.0,x86rn10:29:55,875 INFO [ServiceController] Controller MBean onlinern10:29:55,968 INFO [MainDeployer] Creatingrn10:29:56,000 INFO [MainDeployer] Createdrn10:29:56,015 INFO [MainDeployer] Startingrn10:29:56,015 INFO [MainDeployer] Startedrn10:29:56,031 INFO [JARDeployer] Creatingrn10:29:56,031 INFO [JARDeployer] Createdrn10:29:56,031 INFO [JARDeployer] Startingrn10:29:56,031 INFO [MainDeployer] Adding deployer: org.jboss.deployment.JARDeplornyer@d19bc8rn10:29:56,031 INFO [JARDeployer] Startedrn10:29:56,046 INFO [SARDeployer] Creatingrn10:29:56,046 INFO [SARDeployer] Createdrn10:29:56,046 INFO [SARDeployer] Startingrn10:29:56,046 INFO [MainDeployer] Adding deployer: org.jboss.deployment.SARDeplornyer@1551f60rn10:29:56,078 INFO [SARDeployer] Startedrn10:29:56,078 INFO [Server] Core system initializedrn10:29:56,078 INFO [MainDeployer] Starting deployment of package: file:/D:/jbossrn3.0.6/server/default/conf/jboss-service.xmlrn10:29:59,593 ERROR [MainDeployer] could not create deployment: file:/D:/jboss3.0rn.6/server/default/conf/jboss-service.xmlrnorg.jboss.deployment.DeploymentException: instantiating org.jboss.varia.propertyrn.PropertyEditorManagerService failed: java.lang.StackOverflowError; - nested thrrnowable: (RuntimeErrorException: instantiating org.jboss.varia.property.PropertyErnditorManagerService failed: java.lang.StackOverflowErrorrnCause: java.lang.StackOverflowError)rn at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.javarn:153)rn at org.jboss.system.ServiceController.install(ServiceController.java:231rn)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.rnjava:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesrnsorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:324)rn at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBearnnDispatcher.java:284)rn at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)rn at org.jboss.util.jmx.MBeanProxy.invoke(MBeanProxy.java:174)rn at $Proxy2.install(Unknown Source)rn at org.jboss.deployment.SARDeployer.create(SARDeployer.java:189)rn at org.jboss.deployment.MainDeployer.create(MainDeployer.java:766)rn at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:626)rn at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:591)rn at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:575)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.rnjava:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesrnsorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:324)rn at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBearnnDispatcher.java:284)rn at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:517)rn at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:325)rn at org.jboss.system.server.ServerImpl.start(ServerImpl.java:222)rn at org.jboss.Main.boot(Main.java:148)rn at org.jboss.Main$1.run(Main.java:381)rn at java.lang.Thread.run(Thread.java:534)rnCaused by: RuntimeErrorException: instantiating org.jboss.varia.property.PropertrnyEditorManagerService failed: java.lang.StackOverflowErrorrnCause: java.lang.StackOverflowErrorrn at org.jboss.mx.server.MBeanServerImpl.handleInstantiateExceptions(MBeanrnServerImpl.java:883)rn at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:rn816)rn at org.jboss.mx.server.MBeanServerImpl.instantiate(MBeanServerImpl.java:rn266)rn at org.jboss.mx.server.MBeanServerImpl.createMBean(MBeanServerImpl.java:rn293)rn at org.jboss.system.ServiceCreator.install(ServiceCreator.java:86)rn at org.jboss.system.ServiceConfigurator.internalInstall(ServiceConfigurarntor.java:165)rn at org.jboss.system.ServiceConfigurator.install(ServiceConfigurator.javarn:128)rn ... 25 more 论坛

排序算法中的这个StackOverflowError 怎么改 谢谢!

07-09

一个快速排序的程序,编译后出错。error如下,不知道怎么改。请大家帮忙提示一下 怎么改我的程序。非常感谢!rn[code=java]Exception in thread "main" java.lang.StackOverflowErrorrn at org.quicksortprac.kql.QuickSort1.(QuickSortApp1.java:13)rn at org.quicksortprac.kql.QuickSort1.(QuickSortApp1.java:18)rn at org.quicksortprac.kql.QuickSort1.(QuickSortApp1.java:18)rn at org.quicksortprac.kql.QuickSort1.(QuickSortApp1.java:18)rn at org.quicksortprac.kql.QuickSort1.(QuickSortApp1.java:18)rn at org.quicksortprac.kql.QuickSort1.(QuickSortApp1.java:18)rn at org.quicksortprac.kql.QuickSort1.(QuickSortApp1.java:18)[/code]rn代码如下: rn[code=java]/* Quick Sort Practicern * rn */rnpackage org.quicksortprac.kql;rnrnclass QuickSort1 // constructorrn int[] Arr;rn int p;rn int r;rn int q;rn QuickSort1 qks;rn rn public QuickSort1(int[] arr)rn Arr = arr;rn p=0;rn r= arr.length-1;rn q=0;rn qks = new QuickSort1(arr);rn rn public void sortingArray(int[] arr, int p, int r)rn QuickSort Q = new QuickSort(arr);rn q = qks.partition(p, r);rn Q.sortingArray(arr, q+1, r);rn Q.sortingArray(arr, q+1, r);rn rn//------------------------------------rn public int partition(int p, int r)rn int i, j;rn i= p-1;rn for(j=p; j A[j]rn Arr[i] = Arr[j];rn Arr[j]= Arr[tp];rn rn rn int temp = Arr[i+1];rn Arr[i+1] = Arr[j];rn Arr[j] = temp;rn return i+1; rn // end methodrn//----------------------------- rn // end classQuickSortrn//================================================rnpublic class QuickSortApp1 rn public static void main(String[] args) rn int[] A = 2, 5, 71, 23, 13, 3, 4, 9, 30;rn QuickSort sort = new QuickSort(A);rn sort.sortingArray(A, 0, A.length-1);rn for(int i=0; i 论坛

没有更多推荐了,返回首页