Linux导出Excel 数组越界异常ArrayIndexOutOfBoundsException at sun.font.CompositeFont.getSlotFont

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

异常介绍

最近做了个功能,POI导出excel表格,在windows本地环境跑起来很正常,但是发现打包到Linux服务器上后,却一直报错:

2018-06-27 09:21:03.574 [ERROR] com.hz.shop.admin.controller.order.MallOrderController - MallOrderController>>>exportStoreOrderList:java.lang.ArrayIndexOutOfBoundsException: 0
	at sun.font.CompositeFont.getSlotFont(CompositeFont.java:356)
	at sun.font.CompositeGlyphMapper.initMapper(CompositeGlyphMapper.java:81)
	at sun.font.CompositeGlyphMapper.<init>(CompositeGlyphMapper.java:62)
	at sun.font.CompositeFont.getMapper(CompositeFont.java:414)
	at sun.font.CompositeFont.canDisplay(CompositeFont.java:440)
	at java.awt.Font.canDisplayUpTo(Font.java:2063)
	at java.awt.font.TextLayout.singleFont(TextLayout.java:470)
	at java.awt.font.TextLayout.<init>(TextLayout.java:531)
	at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:275)
	at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.<init>(AutoSizeColumnTracker.java:117)
	at org.apache.poi.xssf.streaming.SXSSFSheet.<init>(SXSSFSheet.java:82)
	at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:658)
	at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:679)
	at com.hz.shop.admin.controller.order.MallOrderController.getStoreOrderExcel(MallOrderController.java:465)
	at com.hz.shop.admin.controller.order.MallOrderController.downloadExcel(MallOrderController.java:333)
	at com.hz.shop.admin.controller.order.MallOrderController.exportStoreOrderList(MallOrderController.java:290)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)

然后我追根溯源,发现在createSheet()这里居然报数组越界异常???
然后我又是换POI的版本,又是检查Linux和windows的jdk版本是否一致,但是始终无法解决这个问题.

最后发现是Linux的字体问题:

问题解决

在Linux的/etc/fonts/local.conf创建这个文件,然后重启Linux,问题解决!

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<alias>
<family>serif</family>
<prefer><family>Utopia</family></prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer><family>Utopia</family></prefer>
</alias>
<alias>
<family>monospace</family>
<prefer><family>Utopia</family></prefer>
</alias>
<alias>
<family>dialog</family>
<prefer><family>Utopia</family></prefer>
</alias>
<alias>
<family>dialoginput</family>
<prefer><family>Utopia</family></prefer>
</alias>
</fontconfig>
展开阅读全文

Arrayindexoutofboundsexception 异常

05-22

这个问题是关于android中customListview 的。我想使用onclick事件(tv.setOnClickListener)在list中动态的添加内容。我有自定义的country类使用geter and seter 方法来储存数据。当我动态的添加新的内容,然后滚动到list的底部时,获取 Arrayindexoutofboundexception 异常。rn rnrn public class PosterList extends Activity rn rn MyCustomAdapter dataAdapter = null;rn ArrayList countryList = new ArrayList();rn TextView tv;rn @Overridern public void onCreate(Bundle savedInstanceState) rn rn super.onCreate(savedInstanceState);rn setContentView(R.layout.posterlist);rn //Click on textview to add element in contrylistrn tv = (TextView) findViewById(R.id.myFilter);rn tv.setOnClickListener(new View.OnClickListener() rn rn public void onClick(View v) rn rn Country country = new Country("df","df","df","m");rn countryList.add(country); rn dataAdapter.notifyDataSetChanged();rn rn );rn displayListView();rn rn private void displayListView() rn rn //Parse my JSON and store it in to different arraysrn rn for(int k=0;k parent, View view,rn int position, long id) rn rn Country country = (Country) parent.getItemAtPosition(position);rn Toast.makeText(getApplicationContext(),rn country.getContinent(), Toast.LENGTH_SHORT).show();rn rn );rn rn private class MyCustomAdapter extends ArrayAdapter rn rn private ArrayList originalList;rn private ArrayList countryList;rn rn public MyCustomAdapter(Context context, int textViewResourceId, rn ArrayList countryList) rn super(context, textViewResourceId, countryList);rn this.countryList = new ArrayList();rn this.countryList.addAll(countryList);rn this.originalList = new ArrayList();rn this.originalList.addAll(countryList);rn rn private class ViewHolder rn rn TextView code;rn TextView name;rn TextView continent;rn TextView region;rn rn @Overridern public View getView(int position, View convertView, ViewGroup parent) rn rn ViewHolder holder = null;rn Log.v("ConvertView", String.valueOf(position));rn if (convertView == null) rn rn LayoutInflater vi = (LayoutInflater)getSystemService(rn Context.LAYOUT_INFLATER_SERVICE);rn convertView = vi.inflate(R.layout.country_info, null);rn holder = new ViewHolder();rn holder.code = (TextView) convertView.findViewById(R.id.code);rn holder.name = (TextView) convertView.findViewById(R.id.name);rn holder.continent = (TextView) convertView.findViewById(R.id.continent);rn holder.region = (TextView) convertView.findViewById(R.id.region);rn convertView.setTag(holder);rn rn elsern rn holder = (ViewHolder) convertView.getTag();rn rn Country country = countryList.get(position);rn holder.code.setText(country.getCode());rn holder.name.setText(country.getName());rn holder.continent.setText(country.getContinent());rn holder.region.setText(country.getRegion());rn return convertView;rn rn rn 问答

Java异常 ArrayIndexOutOfBoundsException

05-04

下面的异常如何解决啊rn3:59:36,171 ERROR ContextLoader:205 - Context initialization failedrnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orgManager' defined in file [C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\test_01\WEB-INF\classes\applicationContext-beans.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\test_01\WEB-INF\classes\applicationContext-common.xml]: Invocation of init method failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 0rnCaused by: rnorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\test_01\WEB-INF\classes\applicationContext-common.xml]: Invocation of init method failed; nested exception is java.lang.ArrayIndexOutOfBoundsException: 0rnCaused by: rnjava.lang.ArrayIndexOutOfBoundsException: 0rn at org.hibernate.persister.collection.AbstractCollectionPersister.generateSelectSizeString(AbstractCollectionPersister.java:867)rn at org.hibernate.persister.collection.AbstractCollectionPersister.(AbstractCollectionPersister.java:475)rn at org.hibernate.persister.collection.BasicCollectionPersister.(BasicCollectionPersister.java:50)rn at org.hibernate.persister.PersisterFactory.createCollectionPersister(PersisterFactory.java:72)rn at org.hibernate.impl.SessionFactoryImpl.(SessionFactoryImpl.java:250)rn at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1218)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSessionFactory(LocalSessionFactoryBean.java:807)rn at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:740)rn at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:131)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1062)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1029)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:420)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)rn at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:246)rn at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:128)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:955)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)rn at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)rn at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)rn at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)rn at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)rn at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)rn at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)rn at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)rn at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)rn at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:184)rn at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)rn at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)rn at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)rn at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)rn at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)rn at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)rn at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)rn at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)rn at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)rn at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)rn at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)rn at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)rn at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)rn at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)rn at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)rn at org.apache.catalina.core.StandardService.start(StandardService.java:516)rn at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)rn at org.apache.catalina.startup.Catalina.start(Catalina.java:578)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)rn at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)rn2010-5-3 23:59:36 org.apache.catalina.core.StandardContext listenerStart 论坛

jsp 导出excel异常

03-02

我用的的JXL导出,可是当我[color=#FF0000]取消[/color]时就出现下列异常,请问怎么解决啊?rnClientAbortException: java.net.SocketException: Connection reset by peer: socket write errorrn at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:358)rn at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:354)rn at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:381)rn at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:370)rn at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:89)rn at jxl.write.biff.MemoryDataOutput.writeData(MemoryDataOutput.java:107)rn at jxl.write.biff.CompoundFile.writeExcelData(CompoundFile.java:505)rn at jxl.write.biff.CompoundFile.write(CompoundFile.java:455)rn at jxl.write.biff.File.close(File.java:120)rn at jxl.write.biff.WritableWorkbookImpl.close(WritableWorkbookImpl.java:447)rn at com.akazam.util.ExportExcel.export(ExportExcel.java:51)rn at org.apache.jsp.district.exporting_jsp._jspService(exporting_jsp.java:80)rn at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)rn at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)rn at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:630)rn at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)rn at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)rn at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)rn at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1085)rn at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:398)rn at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:241)rn at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)rn at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)rn at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at com.akazam.util.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:28)rn at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)rn at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)rn at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)rn at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)rn at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)rn at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)rn at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)rn at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)rn at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)rn at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)rn at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)rn at java.lang.Thread.run(Unknown Source)rnCaused by: java.net.SocketException: Connection reset by peer: socket write errorrn at java.net.SocketOutputStream.socketWrite0(Native Method)rn at java.net.SocketOutputStream.socketWrite(Unknown Source)rn at java.net.SocketOutputStream.write(Unknown Source)rn at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:740)rn at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:434)rn at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:349)rn at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:764)rn at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:126)rn at org.apache.coyote.http11.InternalOutputBuffer.doWrite(InternalOutputBuffer.java:573)rn at org.apache.coyote.Response.doWrite(Response.java:560)rn at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:353)rn ... 45 more 论坛

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