获取嵌套异常为:IllegalArgumentException:Java 中超出了代码大小限制

getting nested exception is: IllegalArgumentException: code size limit exceeded in Java

提问人:uday 提问时间:10/20/2023 更新时间:10/20/2023 访问量:39

问:

我有一个 Java 项目,其中包含多个模块(休眠、对象和存储方法)作为项目,所有这些项目类和方法都通过物流层(包含接口和实现的方法)作为 Weblayer 的 RemoteException 访问,其中包含 bean 和 xhtml 文件。 (Java 1.8、apache tomcat8、eclipse luna)

在中间的物流层包含许多接口,并通过相互扩展的模块来实现方法。

public interface LogisticsManager extends LogisticsValidationManager,
        LogisticsPOManager, LogisticsSessionManager, LogisticsDrivManager,
        LogisticsTripManager, LogisticsRoundManager, LogisticsTaxManager,
        LogisticsContainerManager, LogisticsCompanyManager,
        LogisticsLocationManager, LogisticsCardManager,
        ....{
    public void start() throws RemoteException, LogisticsException;
    public void stop() throws RemoteException, LogisticsException;
    public LogisticsConfig getLogisticsConfig()
            throws RemoteException, LogisticsException;
    public String getStatisticsString() throws RemoteException;
    public String getMessage(String componentName, String messageCode, Object[] args)
            throws RemoteException, LogisticsException;
    }

    //Sample Interface file

    public interface LogisticsCompanyManager extends java.rmi.Remote {

    public String createCompany(String sessionId, CompanyObject companyObject)
            throws RemoteException, LogisticsException, CompanyException,
                    CompanyExistsException;
    public void activateCompany(String sessionId, String companyId)
            throws RemoteException, LogisticsException, CompanyException,
                    CompanyNotFoundException;
    public void inactivateCompany(String sessionId, String companyId)
            throws RemoteException, LogisticsException, CompanyException,
                    CompanyNotFoundException;
    public void updateCompany(String sessionId, CompanyObject companyObject)
            throws RemoteException, LogisticsException, CompanyException,
                    CompanyNotFoundException;
    public void removeCompany(String sessionId, String companyId)
            throws RemoteException, LogisticsException, CompanyException,
                    CompanyNotFoundException;
    public CompanyObject getCompany(String sessionId, String companyId)
            throws RemoteException, LogisticsException, CompanyException,
                    CompanyNotFoundException;
    public CompanyObject getCompanyByName(String sessionId, String companyName)
            throws RemoteException, LogisticsException, CompanyException,
                    CompanyNotFoundException;
    public java.util.List<CompanyObject> getCompanies(String sessionId)
            throws RemoteException, LogisticsException, CompanyException;
    }


    public abstract class LogisticsCompanyManagerImpl
        extends LogisticsContainerManagerImpl {
    //... have method implementations...        
    }

现在我正在尝试在 Interface 和 impl 类中添加更多方法。在 Ant 中编译时没有错误。但是,在 ApacheTomcat 8 中部署时,它不会部署,而是获得以下错误日志:

SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logisticsManager' defined in class path resource [com/cosoft/logistics/logisticsClient.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: code size limit exceeded
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1628)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:742)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:939)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1812)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: code size limit exceeded
at sun.misc.ProxyGenerator.generateStaticInitializer(ProxyGenerator.java:1261)
at sun.misc.ProxyGenerator.generateClassFile(ProxyGenerator.java:484)
at sun.misc.ProxyGenerator.generateProxyClass(ProxyGenerator.java:339)
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:639)
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:557)
at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:230)
at java.lang.reflect.WeakCache.get(WeakCache.java:127)
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:419)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:719)
at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:122)
at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
at org.springframework.remoting.rmi.RmiProxyFactoryBean.afterPropertiesSet(RmiProxyFactoryBean.java:72)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1687)`

我尝试了增加VM大小的选项 在 Eclipse INI 文件中

-vmargs -XMX2400米 -XMS1024米 -XX:PermSize=512m -XX:MaxPermSize=1023m

同样在 Tomcat Web 文件中 JAVA_OPTS=“$JAVA_OPTS -XX:MaxInlineSize=1000 $LOGGING_CONFIG”

还尝试在单独的文件中创建 New Interface 和 Impl 方法并扩展到 LogisticsManager,但仍然出现相同的错误。

我想在物流中添加更多模块及其接口和 Impl 方法。

Java 大小 限制 remoteexception

评论

0赞 experiment unit 1998X 10/20/2023
这回答了你的问题吗?ExceptionInInitializerError:在 JNA 中加载 DLL 时超出代码大小限制
0赞 experiment unit 1998X 10/20/2023
引用这个答案:“限制比技术更实用。一个现实的限制是手写代码的几十个。对于生成的代码,你可以有更多,但我怀疑如果你有那么多,你的设计有问题。文件格式的限制为 65535。鉴于大多数大型项目的类数少于 10K,因此很难想象为什么要在一个类中实现这么多接口。
0赞 uday 10/26/2023
@experimentunit1998X,我为每个模块都有不同的模块,每个接口中都有不同的接口,有一组方法,如 create/update/dele/get/list,所有接口都有自己的实现方法类。 所以现在接口中的方法达到了极限。我是如何克服这个问题的。

答: 暂无答案