2012-02-09 6 views
3

felix에서 war bundle 안에 spring을 사용할 수 있습니까? 글래스 피쉬에서 felix와 함께 봄 3.0.5를 사용합니다.Spring + Felix war = FileNotFoundException

펠릭스에서 OSGI war bundle 안에 component-scan 태그를 입력하려고했는데, 아래 예외가 나타납니다.

나는 similar bug이 춘분 (Equinox)을 위해 풀린 것을 보았으며, 펠릭스는 어땠습니까? 이 문제에 대한 해결 방법이나 해결책이 있습니까?

PS :

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value>classpath*:META-INF/spring/*.xml</param-value> 
</context-param> 

예외 :

2012-02-08 18:30:23,194 [pool-28-thread-1] (PathMatchingResourcePatternResolver.java:532) WARN - Cannot search for matching files underneath URL [bundle://275.0:2/examples/services/] because it does not correspond to a directory in the file system 
java.io.FileNotFoundException: URL [bundle://275.0:2/examples/services/] cannot be resolved to absolute file path because it does not reside in the file system: bundle://275.0:2/examples/services/ 
at org.springframework.util.ResourceUtils.getFile(Res ourceUtils.java:204) 
at org.springframework.core.io.AbstractFileResolvingR esource.getFile(AbstractFileResolvingResource.java :52) 
at org.springframework.core.io.UrlResource.getFile(Ur lResource.java:168) 
at org.springframework.core.io.support.PathMatchingRe sourcePatternResolver.doFindPathMatchingFileResour ces(PathMatchingResourcePatternResolver.java:528) 
... 
2012-02-08 18:30:23,194 [pool-28-thread-1] (PathMatchingResourcePatternResolver.java:353) DEBUG - Resolved location pattern [classpath*:examples/services/**/*.class] to resources [] 

applicationContext.xml :

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xsi:schemaLocation=" 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd 
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx"> 

    <context:annotation-config/> 

    <tx:annotation-driven /> 

    <context:component-scan base-package="examples.services" /> 

</beans> 
I는 web.xml의 contextConfigLocation에서 *로 경로를 정의하는 경우와 동일한 예외는 예를 들면, 슬로우

팁 주셔서 감사합니다.

답변

1

해결 방법은 두 가지가 있습니다. 아직도 나는 펠릭스에 대한 진정한 해결책을 듣게되어 기쁘다.

해결 방법은 다음과 같습니다

  1. 사용 춘분 대신 펠릭스 :
  2. (추한 일) 임시 폴더를 만들고 그것으로 모든 클래스의 압축을 풉니 다. 함수

공공 정적 URL의 해결 (URL의 URL)와 함께 클래스 org.eclipse.core.runtime.FileLocator을 만들기

IOException이

을 던져를 들어,이 폴더에서 컨텐츠의 URL을 반환 예 :

String path = url.getPath(); 
    String str; 
    if(path.contains("com")){ 
     str = path.substring(path.indexOf("com")); 
    } 
    return new URL("file:\\c:\\temp_classes\\"+str); 
0

펠릭스에게 자신을 묶어 두지 않는다면 약간 더 우아한 해결책입니다.

-Dorg.osgi.framework.system.packages.extra=org.apache.felix.framework 
:
package org.eclipse.core.runtime; 

import java.net.URL; 

import org.apache.felix.framework.BundleRevisionImpl; 
import org.osgi.framework.Bundle; 
import org.osgi.framework.FrameworkUtil; 

public class FileLocator { 
    private FileLocator() {} 

    public static URL resolve(URL url) { 
     if(url == null) { 
      return null; 
     } 
     Bundle bundle = FrameworkUtil.getBundle(FileLocator.class).getBundleContext().getBundle(); 
     BundleRevisionImpl bundleRevision = bundle.adapt(BundleRevisionImpl.class); 
     return bundleRevision.getLocalURL(url.getPort(), url.getPath()); 
    } 
} 

는 다음과 같은 매개 변수를 사용하여 펠릭스 시작시 프레임 워크를 수출해야
관련 문제