2012-04-18 31 views
5

Tôi đang cố triển khai một ứng dụng cho Apache Felix. Đó là một ứng dụng gwt nhưng tôi đã đơn giản hóa vấn đề cho đến khi chỉ là một tập tin html thế giới hello nên vấn đề của tôi là triển khai bất kỳ loại ứng dụng web nào trong một tập tin chiến tranh. Tôi cũng đã cố gắng triển khai các cuộc chiến được tạo ra trong Apache Karaf và họ đã làm việc mà không có bất kỳ vấn đề nào (một khi bạn install feature war).Triển khai các tệp chiến tranh trong Apache Felix?

Vì vậy, ngay bây giờ tôi có điều này:

[email protected]:~/devel/webapp $ tree 
. 
├── pom.xml 
├── src 
   └── main 
    ├── resources 
    └── webapp 
     ├── foobar.html 
      └── WEB-INF 
      └── web.xml 

Các pom.xml được khá đơn giản, phần thú vị có liên quan với plugin felix, nhưng đối với cuộc chiến này mà không cần bất kỳ mã biên dịch nó không quan trọng. ..

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>com.mycompany</groupId> 
<artifactId>webapp</artifactId> 
<packaging>war</packaging> 
<version>1.0-SNAPSHOT</version> 
<name>webapp Maven Webapp</name> 
<url>http://maven.apache.org</url> 
<dependencies> 
    <dependency> 
    <groupId>javax.servlet</groupId> 
    <artifactId>servlet-api</artifactId> 
    <version>2.5</version> 
    <scope>provided</scope> 
    </dependency> 
</dependencies> 
<build> 
    <finalName>webapp</finalName> 

    <plugins> 
    <plugin> 
     <groupId>org.apache.felix</groupId> 
     <artifactId>maven-bundle-plugin</artifactId> 
     <version>2.3.7</version> 
     <extensions>true</extensions> 
     <executions> 
     <execution> 
      <id>bundle-manifest</id> 
      <phase>process-classes</phase> 
      <goals> 
      <goal>manifest</goal> 
      </goals> 
     </execution> 
     </executions> 
     <configuration> 
     <supportedProjectTypes> 
      <supportedProjectType>jar</supportedProjectType> 
      <supportedProjectType>bundle</supportedProjectType> 
      <supportedProjectType>war</supportedProjectType> 
     </supportedProjectTypes> 
     <instructions> 
      <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> 
      <Bundle-Version>${project.version}</Bundle-Version> 
      <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency> 
      <Embed-Directory>WEB-INF/lib</Embed-Directory> 
      <Embed-Transitive>true</Embed-Transitive> 
      <Import-Package>*;resolution:=optional</Import-Package> 
      <Web-ContextPath>/sample</Web-ContextPath> 
      <Webapp-Context>/sample</Webapp-Context> 
      <_wab>src/main/webapp</_wab> 
     </instructions> 
     </configuration> 
    </plugin> 


    <plugin> 
     <groupId>org.ops4j</groupId> 
     <artifactId>maven-pax-plugin</artifactId> 
     <configuration> 
     <provision> 
      <param>--platform=felix</param> 
      <param>--profiles=compendium,web,war,log</param> 
      <param>--log=debug</param> 
     </provision> 
     </configuration> 
    </plugin> 

    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-war-plugin</artifactId> 
     <version>2.1.1</version> 
     <executions> 
     <execution> 
      <phase>compile</phase> 
      <goals> 
      <goal>exploded</goal> 
      </goals> 
     </execution> 
     </executions> 
     <configuration> 
     <webappDirectory>${webappDirectory}</webappDirectory> 
     <archive> 
      <!-- add the generated manifest to the war --> 
      <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> 
     </archive> 
     </configuration> 
    </plugin> 

    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-compiler-plugin</artifactId> 
     <version>2.3.2</version> 
     <configuration> 
     <source>1.6</source> 
     <target>1.6</target> 
     </configuration> 
    </plugin> 
</plugins> 
</build> 
</project> 

Plugin pax cũng ở đó vì tôi đã cố gắng chạy ứng dụng với điều đó, nhưng tôi có cùng kết quả. Web.xml là một trống một:

<!DOCTYPE web-app PUBLIC 
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
"http://java.sun.com/dtd/web-app_2_3.dtd" > 

<web-app> 
    <display-name>Archetype Created Web Application</display-name> 
    <welcome-file-list> 
    <welcome-file>foobar.html</welcome-file> 
    </welcome-file-list> 
</web-app> 

Khi bạn thực hiện mvn gói để tạo ra các tập tin chiến tranh, nếu tôi triển khai nó trong Apache Felix tôi nhận được không có lỗi, tình trạng bó đang hoạt động nhưng tôi chỉ nhận được 404 lỗi cố truy cập/đường dẫn mẫu. Tôi đã thử đặt cả mẫu và/mẫu làm giá trị đường dẫn ngữ cảnh. Hành vi tương tự sẽ xảy ra khi chạy mvn pax: chạy. Nếu tôi triển khai cuộc chiến ở karaf Apache, nó hoạt động nên tôi cho rằng tôi đang làm điều gì đó thực sự sai với felix.

danh sách hiện tại của tôi của bó là:

g! lb 
START LEVEL 1 
ID|State  |Level|Name 
0|Active  | 0|System Bundle (4.0.2) 
1|Active  | 1|JXSE (2.7.0) 
2|Active  | 1|Apache Felix Bundle Repository (1.6.6) 
3|Active  | 1|Apache Felix Configuration Admin Service (1.2.8) 
4|Active  | 1|Apache Felix EventAdmin (1.2.14) 
5|Active  | 1|Apache Felix File Install (3.2.0) 
7|Resolved | 1|Apache Felix Security Provider (2.0.1) 
8|Active  | 1|Apache Felix Gogo Command (0.12.0) 
9|Active  | 1|Apache Felix Gogo Runtime (0.10.0) 
10|Active  | 1|Apache Felix Gogo Shell (0.10.0) 
11|Active  | 1|Apache Felix Http Api (2.2.0) 
12|Active  | 1|Apache Felix Http Base (2.2.0) 
13|Active  | 1|Apache Felix Http Bridge (2.2.0) 
14|Active  | 1|Apache Felix Http Bundle (2.2.0) 
15|Active  | 1|Apache Felix Http Jetty (2.2.0) 
16|Active  | 1|Apache Felix Log Service (1.0.1) 
17|Active  | 1|Apache Felix Shell Service (1.4.2) 
18|Active  | 1|OPS4J Pax Logging - API (1.6.3) 
19|Active  | 1|OPS4J Pax Logging - Service (1.6.3) 
20|Active  | 1|OPS4J Pax Url - mvn: (1.2.8) 
21|Active  | 1|OPS4J Pax Url - war (1.2.8) 
22|Active  | 1|OPS4J Pax Url - wrap: (1.2.8) 
23|Active  | 1|OPS4J Pax Web - API (1.0.9) 
24|Active  | 1|OPS4J Pax Web - FileInstall Deployer (1.0.9) 
25|Active  | 1|OPS4J Pax Web - Extender - WAR (1.0.9) 
26|Active  | 1|OPS4J Pax Web - Extender - Whiteboard (1.0.9) 
27|Active  | 1|OPS4J Pax Web - Jetty Bundle (1.0.9) 
28|Active  | 1|OPS4J Pax Web - Jsp Support (1.0.9) 
29|Active  | 1|OPS4J Pax Web - Runtime (1.0.9) 
30|Active  | 1|OPS4J Pax Web - Service SPI (1.0.9) 
+0

Điều tôi muốn kiểm tra tiếp theo trong giao diện điều khiển là gói của bạn (có vẻ như không được bao gồm trong danh sách ở trên, nhưng tôi cho rằng đó chỉ là chỉnh sửa cho concision) đang sử dụng dịch vụ HTTP. Nếu có, bạn đã có một cổng hoặc URL sai. Nếu không, pax-web sẽ không nhận thấy WAB của bạn vì một lý do nào đó. –

+1

Tôi cũng khuyên bạn nên thử trong một hộp chứa đồ cổ (--platform = equinox) để xác nhận rằng vùng chứa OSGi không phải là vấn đề. Tôi nghi ngờ bạn sẽ thấy hành vi tương tự với equinox, cho thấy đó là một gói web-pax-mất tích hoặc một vấn đề pax-runner hoặc một lỗi pax-web hoặc cổng ngồi xổm - nhưng không Felix. –

Trả lời

3

Các bó mà đang làm công việc là OPS4J- những *, nhưng những người chạy cầu cảng là org.apache.felix.http *.. Khi tôi đã xóa org.apache.felix.http. * gói mọi thứ bắt đầu hoạt động.

+2

Bạn nên chấp nhận câu trả lời của riêng mình =) – earcam

Các vấn đề liên quan