2013-02-12 5 views
3

아래 구조를 가진 EJB 응용 프로그램이 있습니다. 모든 종속성은 /lib 디렉토리에 있으며 모든 웹 모듈간에 공유됩니다.ejb 모듈 간의 struts2- 코어 공유 종속성

├── app1_war 
│   ├── index.jsp 
│   ├── META-INF 
│   └── WEB-INF 
| 
├── core.jar 
├── app2_war 
│   ├── META-INF 
│   └── WEB-INF 
| 
├── app3_war 
│   ├── META-INF 
│   └── WEB-INF 
| 
├── lib 
│   ├── struts2-core-2.3.8.jar 
│   ├── webwork-2.2.7.jar 
│   ├── xwork-1.2.3.jar 
│   └── xwork-core-2.3.8.jar 
| 
├── META-INF 
│   ├── application.xml 
│   ├── MANIFEST.MF 
| 
├── app4_war 
   ├── index.jsp 
   ├── META-INF 
   └── WEB-INF 

모든 모듈은 struts2-core-2.3.8.jar 의존성을 사용합니다. 내가 글래스 피시에이를 배포 할 때 나는 아래의 예외로 끝날 :

내 생각은,이 문맥에서 같은 struts-default.xml 파일을 모든 모듈이 동일한 종속성을 공유하고 있기 때문에 일어나고, 따라서 각각의 로딩입니다
Exception starting filter struts2 
java.lang.InstantiationException 
     at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:124) 
     at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4685) 
     at org.apache.catalina.core.StandardContext.start(StandardContext.java:5377) 
     at com.sun.enterprise.web.WebModule.start(WebModule.java:498) 
     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917) 
     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901) 
     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733) 
     at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2019) 
     at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1669) 
[...] 

Caused by: Unable to load configuration. - bean - jar:file:/opt/glassfish3/nodes/apps/fish1/applications/legacy/lib/struts2-core-2.3.8.jar!/struts-default.xml:29:72 
     at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:483) 
     at org.apache.struts2.dispatcher.ng.InitOperations.initDispatcher(InitOperations.java:74) 
     at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.init(StrutsPrepareAndExecuteFilter.java:51) 
     at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:264) 
     at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:120) 
     ... 41 more 
Caused by: Unable to load configuration. - bean - jar:file:/opt/glassfish3/nodes/apps/fish1/applications/legacy/lib/struts2-core-2.3.8.jar!/struts-default.xml:29:72 
     at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:70) 
     at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:429) 
     at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:471) 
     ... 45 more 
Caused by: Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file:/opt/glassfish3/nodes/apps/fish1/applications/legacy/lib/struts2-core-2.3.8.jar!/struts-default.xml:29:72 
     at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:245) 
     at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102) 
     at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:215) 
     at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67) 
     ... 47 more 
Caused by: Bean type class com.opensymphony.xwork2.ObjectFactory with the name xwork has already been loaded by bean - jar:file:/opt/glassfish3/nodes/apps/fish1/applications/legacy/lib/struts2-core-2.3.8.jar!/struts-default.xml:29:72 - bean - jar:file:/opt/glassfish3/nodes/apps/fish1/applications/legacy/lib/struts2-core-2.3.8.jar!/struts-default.xml:29:72 
     at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:229) 

. 아무도 이것을 해결하는 방법을 알고 있습니까?

+0

모든 WARS가 동일한 필터 이름 "struts2"를 공유합니까? 아마도 동일한 struts2 필터 이름이 EAR의 모든 응용 프로그램에서 충돌합니다. – ZeusSelerim

+0

이 답변이 도움이되는지보십시오. http://stackoverflow.com/questions/2778140/struts2-in-rad-raises-error-xwork-has-already-been-loaded-by-bean –

+0

@Jesus Mireles, 웹 모듈은 struts2를 선언합니다. – Bitmap

답변

0

이 늦은 반응이지만, 어쨌든, 여기에이 문제에 대한 나의 생각입니다 : 내가 EAR 파일 내에서 "공유"일부 종속성이 비슷한 문제를 경험 한

은. Struts는 컨텍스트가로드 될 때 첫 번째 WAR 클래스 경로 (일반적으로 Spring을 사용하여 objectfactory를 사용하여)에서 초기화됩니다. 그런 다음 다른 전쟁이로드 될 때 서로 다른 컨텍스트를 갖지만 동일한 클래스 경로 계층 구조에 포함되며 Struts는 다시 초기화되지만 초기화 된 것으로 나타납니다.

따라서 이러한 유형의 종속성은 자체 Servlet 컨텍스트에 있어야하므로 공유 할 수 없습니다. 따라서 각 WAR에 이들을 포함시켜야합니다.

더 나은 해결책을 찾은 경우 공유하십시오. 그러나 그렇지 않다면 위의 의견이 도움이되기를 바랍니다.