我正在構建OpenShift PaaS的第一個項目。決定與Java一起下載JBoss Developer Studio並創建了第一個項目。 Openshift類型已經創建了模板,所以它應該運行。但在Developer Studio中,有錯誤:javax.servlet無法解析爲OpenShift Tomcat 7(JBoss EWS 2.0)
javax.servlet cannot be resolved
我知道這可能是簡單的Java EE的人,但我的問題是,OpenShift,將在解決方案相同。我們可以將apache tomcat jar複製到項目文件夾中嗎?我猜JBoss Develper Studio不完全是Eclipse嗎?所以我添加了jar,錯誤消失了。再有就是這樣的警告:
Classpath entry .. tomecat-7.0.42/lib/servlet-api.jar will not be exported or published ClassNotFoundException may result.
問題
什麼是錯誤和警告消失了正確的事情?應該Openshift已經有了罐子,因爲它是一個PaaS,而不是IaaS。我們是否需要構建jar,但這個jar不會成爲web應用程序的一部分?
信息
JBoss的開發工作室確實有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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tom</groupId>
<artifactId>tom</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>tom</name>
<repositories>
<repository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>eap</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.25</version>
</dependency>
</dependencies>
<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when
invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app
will need. -->
<!-- By default that is to put the resulting archive into the 'webapps'
folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<finalName>tom</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<outputDirectory>webapps</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
是啊...周圍複製隨機'jar's可能是一個壞主意。 'jar'是'class'文件的壓縮集合。 –
看起來像他用外部罐子,否則,爲什麼警告指向另一條路徑?一個新手可能嘗試過不同的事情,並忘記最終使其工作。通常servlet-api.jar(tomcat)已經是JBOSS服務器的一部分。對於開發人員,只需要編譯即可。 –
你在使用maven嗎?如果是,請顯示你的pom.xml – fascynacja