我有一个.war
文件,当我复制到我的Tomcat 9本地实例中的webapps文件夹时,它会成功部署。不知何故,当我尝试在Openshift齿轮(Tomcat 7)上运行它时,它不会被部署。我正在采取的步骤:
0:我克隆了远程存储库。
1:我将war文件复制到git repository中的webapps文件夹。
2:我把它推到远程仓库,然后输出:
Writing objects: 100% (5/5), 4.50 KiB | 0 bytes/s, done.
Total 5 (delta 3), reused 0 (delta 0)
remote: Stopping jbossews cartridge
remote: Sending SIGTERM to jboss:341147 ...
remote: Building git ref 'master', commit 90c82a4
remote: Skipping Maven build due to absence of pom.xml
remote: Preparing build for deployment
remote: Deployment id is a9215a94
remote: Activating deployment
remote: Starting jbossews cartridge
remote: Found 127.12.55.129:8080 listening port
remote: -------------------------
remote: Git Post-Receive Result: success
remote: Activation status: success
remote: Deployment completed with status: success
.pom
文件和src
文件夹。Project pom:
<?xml version="1.0" encoding="UTF-8"?>
<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.tomek.example</groupId>
<artifactId>SimpleApp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>SimpleApp</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</pluginRepository>
</pluginRepositories>
<!-- <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>-->
</project>
主要java:
@SpringBootApplication
@ComponentScan({"controllers", "rest"})
public class SimpleAppApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(SimpleAppApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(applicationClass);
}
private static final Class<SimpleAppApplication> applicationClass = SimpleAppApplication.class;
}
Root Controller:
@RestController
public class MainController {
@RequestMapping("/")
public String text (){
return "ja pierdole wygral jebany!";
}
}
修改 我检查了服务器日志,我得到了很多这种类型的错误:
SEVERE: Unable to process Jar entry [javassist/ByteArrayClassPath.class] from Jar [jar:jndi:/localhost/Simple/WEB-INF/lib/javassist-3.20.0-GA.jar!/] for annotations
java.io.EOFException
at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:340)
at org.apache.tomcat.util.bcel.classfile.Utility.swallowMethodParameters(Utility.java:796)
at org.apache.tomcat.util.bcel.classfile.Attribute.readAttribute(Attribute.java:171)
at org.apache.tomcat.util.bcel.classfile.FieldOrMethod.<init>(FieldOrMethod.java:57)
at org.apache.tomcat.util.bcel.classfile.Method.<init>(Method.java:71)
at org.apache.tomcat.util.bcel.classfile.ClassParser.readMethods(ClassParser.java:267)
at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:127)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2058)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1934)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1900)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1885)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1317)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
** Tomcat记录**
Oct 07, 2016 1:18:32 PM org.apache.catalina.startup.Catalina addClusterRuleSet
INFO: Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.apache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
Oct 07, 2016 1:18:32 PM org.apache.catalina.startup.Catalina addClusterRuleSet
INFO: Cluster RuleSet not found due to [java.lang.ClassNotFoundException: org.apache.catalina.ha.ClusterRuleSet]. Cluster configuration disabled.
Oct 07, 2016 1:18:33 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: :/usr/java/packages/lib/i386:/lib:/usr/lib
Oct 07, 2016 1:18:33 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-127.9.153.1-8080"]
Oct 07, 2016 1:18:33 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1763 ms
Oct 07, 2016 1:18:34 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 07, 2016 1:18:34 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Oct 07, 2016 1:18:34 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/openshift/57efecb17628e18e59000032/app-root/runtime/dependencies/jbossews/webapps/ROOT.war
Oct 07, 2016 1:18:47 PM org.apache.catalina.startup.ContextConfig processAnnotationsJar
SEVERE: Unable to process Jar entry [javassist/ByteArrayClassPath.class] from Jar [jar:jndi:/localhost/WEB-INF/lib/javassist-3.20.0-GA.jar!/] for annotations
java.io.EOFException
at java.io.DataInputStream.readUnsignedShort(DataInputStream.java:340)
at org.apache.tomcat.util.bcel.classfile.Utility.swallowMethodParameters(Utility.java:796)
at org.apache.tomcat.util.bcel.classfile.Attribute.readAttribute(Attribute.java:171)
at org.apache.tomcat.util.bcel.classfile.FieldOrMethod.<init>(FieldOrMethod.java:57)
at org.apache.tomcat.util.bcel.classfile.Method.<init>(Method.java:71)
at org.apache.tomcat.util.bcel.classfile.ClassParser.readMethods(ClassParser.java:267)
at org.apache.tomcat.util.bcel.classfile.ClassParser.parse(ClassParser.java:127)
at org.apache.catalina.startup.ContextConfig.processAnnotationsStream(ContextConfig.java:2058)
at org.apache.catalina.startup.ContextConfig.processAnnotationsJar(ContextConfig.java:1934)
at org.apache.catalina.startup.ContextConfig.processAnnotationsUrl(ContextConfig.java:1900)
at org.apache.catalina.startup.ContextConfig.processAnnotations(ContextConfig.java:1885)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1317)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:632)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1083)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1880)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
... 许多相同的异常 ...
Oct 07, 2016 1:18:52 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.9.153.1-8080"]
Oct 07, 2016 1:18:52 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 18101 ms
答案 0 :(得分:4)
现在看到四个问题:
org.javassist
mvn dependency:tree
显示
[INFO] \- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.4.1.RELEASE:compile
[INFO] +- org.thymeleaf:thymeleaf-spring4:jar:2.1.5.RELEASE:compile
[INFO] | +- org.thymeleaf:thymeleaf:jar:2.1.5.RELEASE:compile
[INFO] | | +- ognl:ognl:jar:3.0.8:compile
[INFO] | | +- org.javassist:javassist:jar:3.20.0-GA:compile (version managed from 3.16.1-GA)
[INFO] | | \- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
[INFO] | \- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile
[INFO] \- org.codehaus.groovy:groovy:jar:2.4.7:compile (version managed from 2.4.3)
该依赖关系来自spring-boot-starter-thymeleaf
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<exclusions>
<exclusion>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.17.1-GA</version>
</dependency>
归因于OpenShift Tomcat Processing Annotations Error Deploying War
可以通过pom.xml
<properties>
<java.version>1.7</java.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<start-class>com.example.SimpleAppApplication</start-class>
<tomcat.version>7.0.54</tomcat.version>
</properties>
检查由于https://developers.openshift.com/servers/tomcat/getting-started.html#other
而在OpenShift git repo上是否存在标记文件.openshift/markers/java7
您可以选择添加标记.openshift/markers/skip_maven_build
以跳过maven构建。
如果PagesController.java
包含controllers
@Configuration
@EnableAutoConfiguration
@ComponentScan("controllers")
@RestController
public class SimpleAppApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application;
}
public static void main(String[] args) {
SpringApplication.run(SimpleAppApplication.class, args);
}
}
答案 1 :(得分:3)
您是否尝试在pom.xml
上指定战争部署?
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<outputDirectory>target</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
答案 2 :(得分:3)
我认为你只是在你的pom中在Java 8的本地环境中编译,然后在没有pom和source的情况下在openshift上推送战争,所以没有重建。我本来期待一个不同的例外,但这是我的猜测。 默认情况下,如果配置标记,则openhift上的Tomcat 7将运行Java 6或Java 7。如果您不需要最新版本的新功能,我建议您将本地配置与openshift(jdk和tomcat)上的配置对齐。您还必须使用适当版本的Java更改pom.xml中的这些行。
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
更新1
请同时尝试其中一种解决方案:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
<exclusions>
<exclusion>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
</exclusions>
</dependency>
或编辑齿轮上的文件catalina.properties: tomcat.util.scan.DefaultJarScanner.jarsToSkip =了Javassist - *罐
更新2
我看到你依赖于thyperleaf依赖javaassist,然后将这个排除添加到你的pom并切换到java 1.7因为你有一个web模块3.1(在openshift上添加一个标记让他使用java 7)
<properties>
<java.version>1.7</java.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<start-class>com.example.SimpleAppApplication</start-class>
</properties>
你不能排除百科全书的javaassist所以唯一的选择。是添加:
tomcat.util.scan.DefaultJarScanner.jarsToSkip = [existing exclusions] javassist-*.jar
在openshift中到 catalina.properties