Я пытаюсь построить встроенный причал в одной толстой банке. Я построил приложение, используя тутовое приложение, предназначенное для прикроватного обслуживания, которое мне также необходимо в моем приложении. Теперь я пытаюсь добавить/включить контекст jsf. Все отлично работает в Eclipse, но как только в развертывании с использованием Maven чистой установки, и я пытаюсь выполнить банку где-то есле, я получаю следующее сообщение об ошибке:maven jetty embedded (fat jar) - src/main/webapp отсутствует в банке
Exception in thread "main" java.lang.IllegalArgumentException: file:///home/debbie/src/main/webapp is not an existing directory. at org.eclipse.jetty.util.resource.ResourceCollection.(ResourceCollection.java:108) at com.example.haaa.server.App.start(App.java:43) at com.example.haaa.server.App.main(App.java:62)
Я проверил банку и он не оленья кожа содержит ни один из веб-приложение ресурсов, но я не понимаю, как я могу сказать maven, чтобы включить эти файлы в банку, или как я могу решить свою проблему.
После моей упрощенной pom.xml (избавившись от зависимостей здесь, как я не ожидал, что любое дело
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>haaa</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>haaa</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>prime-repo</id>
<name>Prime Repo</name>
<url>http://repository.primefaces.org</url>
</repository>
</repositories>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/webapp</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.6</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>com.example.haaa.server.App</Main-Class>
</manifestEntries>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
И следующий код в моем com.example.haaa.server.App.:
package com.example.haaa.server;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.resource.ResourceCollection;
import org.eclipse.jetty.webapp.WebAppContext;
import org.glassfish.jersey.servlet.ServletContainer;
import com.example.haaa.service.AbuseService;
public class App {
final static Logger logger = Logger.getLogger(App.class);
private final Server server;
public App() {
server = new Server(8080);
}
public void start() throws Exception {
// REST
WebAppContext restHandler = new WebAppContext();
restHandler.setResourceBase("./");
restHandler.setClassLoader(Thread.currentThread().getContextClassLoader());
ServletHolder restServlet = restHandler.addServlet(ServletContainer.class, "/abuse/*");
restServlet.setInitOrder(0);
Map<String, String> initparams = new HashMap<String, String>();
initparams.put("jersey.config.server.provider.classnames", AbuseService.class.getCanonicalName()+","+"org.glassfish.jersey.filter.LoggingFilter;org.glassfish.jersey.moxy.json.MoxyFeature;org.glassfish.jersey.media.multipart.MultiPartFeature");
restServlet.setInitParameters(initparams);
// Web
WebAppContext webHandler = new WebAppContext();
webHandler.setResourceAlias("/WEB-INF/classes/", "/classes/");
webHandler.setBaseResource(
new ResourceCollection(
new String[] { "./src/main/webapp", "./target" }));
webHandler.setContextPath("/web/");
HashLoginService loginService = new HashLoginService("HaaaRealm");
loginService.setConfig("./src/main/webapp/loginrealm.txt");
System.out.println(loginService.getConfig());
server.addBean(loginService);
// Server
HandlerCollection handlers = new HandlerCollection();
handlers.addHandler(webHandler);
handlers.addHandler(restHandler);
server.setHandler(handlers);
server.start();
}
public static void main(String[] args) throws Exception {
new App().start();
}
}
Если бы я должен был оставить любую соответствующую информацию, пожалуйста, дайте мне знать.
Спасибо, что объясняет, почему я не получил дальнейшее использование этого подхода. – Ilir