2016-03-05 92 views
0

我想运行一个用Java编写的项目,并在Linux上使用Spring框架来扩展某些功能。该项目最初是在Windows平台上开发的,但是,我试图在Ubuntu 15.10上运行(并继续工作)。该平台是Tomcat 8.0.30,PostgreSQL 9.4,JDK 1.8.0_73,Spring 4.2.0。项目是在Spring Tool Suite下使用Gradle 2.5构建的。除了必要的路径之外,所有内容大部分都在默认配置下。在java中的后端是一个REST服务,我甚至还没有开始通过代码。相同的java代码不能在不同的机器上运行

问题是,整个事情无法运行在这个特定的机器上(我会称之为桌面)。构建是成功的,一切都很好,直到战争部署在tomcat上。根据具体情况,在这台机器上,部署将产生一个Oauth bean实例化的Spring循环引用,或者将正常传递,直到来自前端的第一个请求(即登录),并且它会产生堆栈溢出错误,一遍又一遍(开始时没有其他可能的请求)。

如果在几个不同的机器上完全相同的设置完全相同的代码没有小故障,这并不奇怪。我曾尝试是:

  • 的Ubuntu 12.04,相同的Java,年长的PostgreSQL(9.1我认为) - 适用于第一次部署
  • MacOS的,最新版本的Java,最新的PostgreSQL - 适用于第一次部署
  • 的Ubuntu 12.04 (其他),同样的Java,年长的PostgreSQL - 适用于第一次部署
  • 的Windows 7 64位系统,同样的设置,在Linux上的PostgreSQL - 适用于第一次部署

要扩大一点,我最近升级了桌面,事先它正在运行除了我设法通过创建一个新用户在桌面上实际运行项目并在其下运行之外,它还具有完全相同的效果。之后,它在我的常规用户下工作,但只能在STS下运行,部署在外部tomcat 8.0.30上。如果在STS附带的Pivotal TC服务器下运行,我会得到相同的错误。如果手动部署war到tomcat 8.0.30,再次出现错误。这些“黑客”不再适用于新版本。

我也尝试从运行在其他机器上的前端查询项目,结果是一样的,所以它纯粹是关于Java和/或Tomcat的东西。我也尝试dockerize tomcat(最新的8.0.32标记,openjdk-8,还有1.8.0_73),但没有运气。将在笔记本电脑上工作的编译过的战争转移到桌面上 - 再次没有带来积极的结果。

这是日志的一部分:

05-Mar-2016 02:21:32.868 SEVERE [http-nio-8080-exec-2] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [dispatcher] in context with path [/backend] threw exception [Filter execution threw an exception] with root cause 
java.lang.StackOverflowError 
at org.springframework.beans.factory.support.AbstractBeanFactory.transformedBeanName(AbstractBeanFactory.java:1084) 
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:238) 
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) 
at org.springframework.aop.target.SimpleBeanTargetSource.getTarget(SimpleBeanTargetSource.java:35) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:187) 
at com.sun.proxy.$Proxy100.loadClientByClientId(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 
at com.sun.proxy.$Proxy100.loadClientByClientId(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 
at com.sun.proxy.$Proxy100.loadClientByClientId(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 
at com.sun.proxy.$Proxy100.loadClientByClientId(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 
at com.sun.proxy.$Proxy100.loadClientByClientId(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 
at com.sun.proxy.$Proxy100.loadClientByClientId(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 
at com.sun.proxy.$Proxy100.loadClientByClientId(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 
at com.sun.proxy.$Proxy100.loadClientByClientId(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:497) 
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133) 
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121) 
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) 
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) 
at com.sun.proxy.$Proxy100.loadClientByClientId(Unknown Source) 
at sun.reflect.GeneratedMethodAccessor107.invoke(Unknown Source) 

...它的推移和

的当前状态是:建立清洁,部署是干净的,总是给从错误登录。

我还不熟悉Spring,所以我无法从日志中找出任何有用的东西。不过,我确信,服务安装正确,并且正在运行。环境尽可能配置为接近默认值,以消除差异。

任何提示或输入什么可能是原因(和解决方案),将不胜感激。我会尽力提供任何可能有用的信息。

谢谢!

+0

向我们展示loadClientByClientId方法 –

+0

另外,如果您设置日志记录为org.springframework的调试,那么看看有什么不同,当它工作,当它不。 –

+0

如果另一方面,应用程序运行平稳呃操作系统,那么它最有可能与内存分配问题。尝试使用-Xms和-Xmx选项增加JVM内存。 – Ayman

回答

2

好,在这样的意见,非常有用的东西,但回顾一下......

要解决这个问题,这是非常有用的,我知道这个问题是不是与代码相关的,但它是一个已知的(虽然很少见)问题。确切地说,初始化的顺序是罪魁祸首,并试图访问尚未初始化的对象(其中创建代理对象)。

我的解决方案是不时尚,而且很可能不是由这本书,但它确实解决这个问题对我来说。我不是依赖@Autowired和代理,而是为每个麻烦的类创建单例,从而确保配置正确设置,并且在第一次请求时可以使用该对象 - 无论它来自何处。

在评论的链接包含有关该问题的性质更详细的解释。感谢大家的帮助!

PS。某处,而试图找到一个解决这个问题(和下面的链接),我也遇到了关于“AnnotationConfigWebApplicationContext后 - 异常上下文初始化过程中遇到 - 取消刷新尝试 org.springframework.beans.factory.BeanCreationException:错误创建豆名为“oauth2TokenController”:自动装配依赖注入失败;嵌套的例外是org.springframework.beans.factory.BeanCreationException:无法自动装配领域:......如此下去..错误名为“创造豆可能会在同一个可解但是,还没有尝试过

相关问题