I have build a web appliation containing a Spring MVC project with a mysql database and a tomcat7 server. This is now published to GIT of OpenShift.
But starting the server takes only 160ms and I can clearly see nothing is being loaded really.
How do I do a real deployment and connect the Openshift Tomcat to my project?
I can code, but deployment-wise I am not a smart bulb.
My GIT repository looks like this:
What is wrong?
EDIT:
As requested the 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.afterguard</groupId>
<artifactId>SailPlanner</artifactId>
<version>0.8.0</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<profiles>
<profile>
<id>openshift</id>
<build>
<finalName>sailplanner</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<outputDirectory>webapps</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.9</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-crypto</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>com.openshift</groupId>
<artifactId>openshift-java-client</artifactId>
<version>2.7.0.Final</version>
</dependency>
</dependencies>
</project>
The web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>SailPlanner</display-name>
<welcome-file-list>
<welcome-file>/WEB-INF/jsp/index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>sailplanner</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>sailplanner</servlet-name>
<!-- <url-pattern>/</url-pattern> -->
<url-pattern>/index</url-pattern>
<url-pattern>/inside/admin</url-pattern>
<url-pattern>/inside/admin/save</url-pattern>
<url-pattern>/inside/admin/delete</url-pattern>
<url-pattern>/inside/calendar_race</url-pattern>
<url-pattern>/inside/calendar_cruise</url-pattern>
<url-pattern>/inside/blog</url-pattern>
<url-pattern>/inside/blog/submit</url-pattern>
<url-pattern>/inside/blog/delete</url-pattern>
<url-pattern>/inside/event_feed</url-pattern>
<url-pattern>/inside/event/create</url-pattern>
<url-pattern>/inside/event/delete</url-pattern>
<url-pattern>/inside/event/crew/add</url-pattern>
<url-pattern>/inside/event/crew/remove</url-pattern>
<url-pattern>/inside/event/save</url-pattern>
<url-pattern>/login</url-pattern>
<url-pattern>/logout</url-pattern>
<url-pattern>/403</url-pattern>
<url-pattern>/registration</url-pattern>
<url-pattern>/inside/yacht/create</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/sailplanner-servlet.xml,
/WEB-INF/spring-security.xml,
/WEB-INF/spring-database.xml
</param-value>
</context-param>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Git Push Log (of successful build):
Repository ssh://566ffc920c1e668c8a000049#afterguard-sailplanner.rhcloud.com/~/git/afterguard.git/
Stopping jbossews cartridge
Sending SIGTERM to jboss:333213 ...
Stopping MySQL 5.5 cartridge
Stopping PHPMyAdmin cartridge
Waiting for stop to finish
Waiting for stop to finish
Repairing links for 1 deployments
Building git ref 'master', commit 277c797
Using Maven mirror /var/lib/openshift/566ffc920c1e668c8a000049/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml
Apache Maven 3.0.4 (r1232336; 2012-12-18 14:36:37-0500)
Maven home: /usr/share/java/apache-maven-3.0.4
Java version: 1.7.0_91, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91/jre
Default locale: en_US, platform encoding: ANSI_X3.4-1968
OS name: "linux", version: "2.6.32-573.12.1.el6.x86_64", arch: "i386", family: "unix"
Found pom.xml... attempting to build with 'mvn --global-settings /var/lib/openshift/566ffc920c1e668c8a000049/app-root/runtime/repo//.openshift/config/settings.rhcloud.xml clean package -Popenshift -DskipTests'
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building SailPlanner 0.8.0
[INFO] ------------------------------------------------------------------------
Downloading: http://maven.repository.redhat.com/techpreview/all/javax/servlet/javax.servlet-api/3.0.1/javax.servlet-api-3.0.1.pom
...A LOT OF BUILDING AND DOWNLOADING...
Downloaded: http://mirror.ops.rhcloud.com/nexus/content/groups/public/com/thoughtworks/xstream/xstream/1.3.1/xstream-1.3.1.jar (422 KB at 6105.7 KB/sec)
[INFO] Packaging webapp
[INFO] Assembling webapp [SailPlanner] in [/var/lib/openshift/566ffc920c1e668c8a000049/app-root/runtime/repo/target/sailplanner]
[INFO] Processing war project
[INFO] Copying webapp resources [/var/lib/openshift/566ffc920c1e668c8a000049/app-root/runtime/repo/WebContent]
[INFO] Webapp assembled in [517 msecs]
[INFO] Building war: /var/lib/openshift/566ffc920c1e668c8a000049/app-root/runtime/repo/WebContent/ROOT.war
[INFO] WEB-INF/web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.062s
[INFO] Finished at: Tue Dec 22 05:35:45 EST 2015
[INFO] Final Memory: 16M/161M
[INFO] ------------------------------------------------------------------------
Preparing build for deployment
Deployment id is 0f103f85
Activating deployment
Starting MySQL 5.5 cartridge
Starting PHPMyAdmin cartridge
Starting jbossews cartridge
Found 127.3.145.129:8080 listening port
-------------------------
Git Post-Receive Result: success
Activation status: success
Deployment completed with status: success
Tomcat log of OpenShift:
Dec 22, 2015 6:47:27 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1503 ms
Dec 22, 2015 6:47:27 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 22, 2015 6:47:27 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
Dec 22, 2015 6:47:27 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-127.3.145.129-8080"]
Dec 22, 2015 6:47:27 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 251 ms
File Structure of ROOT.WAR, which is located in /var/lib/openshift/<uuid>/app-root/runtime/repo/WebContent :
|- META-INF
|- resources
|-- css
|-- fonts
|-- img
|-- js
|- WEB-INF
|-- classes
|--- com
|---- ...
|-- jsp
|--- index.jsp
|--- more jsp-sites
|-- jspf
|--- JSPF SITES I USE
|-- lib
|--- THE LIBS
|-- sailplanner-servlet.xml
|-- spring-datasource.xml
|-- spring-security.xml
|-- web.xml
It seems that you have forgotten to add an openshift maven profile inside your pom.xml like bellow with proper maven-war-plugin configuration.
<profiles>
<profile>
<id>openshift</id>
<build>
<finalName>travel</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>
Then your application structure seems unusual. Usually to build a WAR with maven you put your webapp content in src/main/webapp, your resources in src/main/resources your WAR specific classes in src/main/java.
Take a look at maven-war-plugin user guide here.
Finally, check these documentations that could help you to unterstand how to deploy your application to Tomcat with OpenShift:
Host and Run Your Java Tomcat Application for Free on OpenShift’s PaaS
Tomcat Application Hosting
If you follow properly steps described in these documentations, then any git push will trigger a build and application re-deployment to Tomcat
EDIT
As you have a build compilation issue now (Java 8 not supported), you should take a look at this answer: invalid target release 1.8
I have a JSP application on OpenShift Tomcat.
But all of my source code located in /src/main
Java src code in /src/main/java that means com.example.Main 's location is <APP_NAME>/src/main/java/com/example/Main.java
JSP src code in /src/main/webapp that means index.jsp 's location is <APP_NAME>/src/main/webapp/index.jsp
Have you actually performed a git commit and git push?
If so, can you dump the logs from git push.
Related
I create a simple Spring MVC project. When I run it on the Tomcat everything work correctly, but I would like to use Maven Jetty Plugin to run it. Below a picture of project's structure:
My pom.xml file looks like:
<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.journaldev.spring.mvc</groupId>
<artifactId>spring-mvc-example</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>Spring MVC Example</name>
<description>Spring MVC Hello World Example</description>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.9.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.9.v20160517</version>
<configuration>
<webApp>
<descriptor>/WEB-INF/web.xml</descriptor>
</webApp>
<scanIntervalSeconds>2</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName> <!-- added to remove Version from WAR file -->
</build>
</project>
My web.xml file looks like:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>spring-mvc-example</display-name>
<!-- Add Spring MVC DispatcherServlet as front controller -->
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
The HomeController.java file:
#Controller
public class HomeController {
/**
* Simply selects the home view to render by returning its name.
*/
#RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
System.out.println("Home Page Requested, locale = " + locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate);
return "home";
}
#RequestMapping(value = "/user", method = RequestMethod.POST)
public String user(#Validated User user, Model model) {
System.out.println("User Page Requested");
model.addAttribute("userName", user.getUserName());
return "user";
}
}
The console's output:
[INFO] Configuring Jetty for project: Spring MVC Example
[INFO] webAppSourceDirectory C:\Users\Tom\Downloads\spring-mvc-example\src\main\webapp does not exist. Defaulting to C:\Users\Tom\Downloads\spring-mvc-example\src\main\webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes = C:\Users\Tom\Downloads\spring-mvc-example\target\classes
[INFO] Context path = /
[INFO] Tmp directory = C:\Users\Tom\Downloads\spring-mvc-example\target\tmp
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
[INFO] web.xml file = null
[INFO] Webapp directory = C:\Users\Tom\Downloads\spring-mvc-example\src\main\webapp
[INFO] jetty-8.1.4.v20120524
[INFO] No Transaction manager found - if your webapp requires one, please configure one.
[INFO] No Spring WebApplicationInitializer types detected on classpath
[INFO] started o.m.j.p.JettyWebAppContext{/,file:/C:/Users/Tom/Downloads/spring-mvc-example/src/main/webapp},file:/C:/Users/Tom/Downloads/spring-mvc-example/src/main/webapp
[INFO] started o.m.j.p.JettyWebAppContext{/,file:/C:/Users/Tom/Downloads/spring-mvc-example/src/main/webapp},file:/C:/Users/Tom/Downloads/spring-mvc-example/src/main/webapp
[INFO] started o.m.j.p.JettyWebAppContext{/,file:/C:/Users/Tom/Downloads/spring-mvc-example/src/main/webapp},file:/C:/Users/Tom/Downloads/spring-mvc-example/src/main/webapp
[INFO] Started SelectChannelConnector#0.0.0.0:8080
[INFO] Started Jetty Server
I think that I make some mistake in configuration Jetty in pom.xml and Jetty does not see the context. Generally server has started, no errors. When I look into the console's output there is:
web.xml file = null
Some problem with Jetty Configuration in pom.xml. Thank you.
If you can change your project structure, renaming from /WebContent/ to /src/main/webapp/, then it will work with all Maven provided webapp services (jetty, tomcat, jboss, glassfish, etc...) including all Intellij and Eclipse IDE webapp services.
I have a Jersey 2 Maven project.
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>com.api.rest.ApplicationResource</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>com.api.rest.ApplicationResource</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
</web-app>
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>com.api</groupId>
<artifactId>GLI_API</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>GLI_API</name>
<build>
<finalName>GLI_API</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.21</version>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP-java6</artifactId>
<version>2.2.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.36</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.3m</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>com.cloudinary</groupId>
<artifactId>cloudinary-http44</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<properties>
<jersey.version>2.19</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>
My project works fine when working locally. But it doesn't work anymore when i deploy it on my remote server.
So what happens is basically, that the WAR gets deployed correctly but there is really no error or warning in catalina.out. I get a 404 on every of my defined endpoints.
catalina.out:
Sep 14, 2015 2:03:00 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/GLI_API.war
Sep 14, 2015 2:04:17 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/ICDS_API.war
Sep 14, 2015 2:04:23 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /var/lib/tomcat7/webapps/ROOT
Sep 14, 2015 2:04:23 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Sep 14, 2015 2:04:23 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 84867 ms
ApplicationResource:
package com.api.rest;
import java.util.logging.Logger;
import org.glassfish.jersey.filter.LoggingFilter;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.ServerProperties;
import com.api.provider.ResponseCorsFilter;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
public class ApplicationResource extends ResourceConfig {
private static final Logger LOGGER = null;
public ApplicationResource() {
// Register resources and providers using package-scanning.
packages("com.api");
System.out.println("started");
register(MultiPartFeature.class);
// Register my custom provider - not needed if it's in my.package.
register(ResponseCorsFilter.class);
// Register an instance of LoggingFilter.
register(new LoggingFilter(LOGGER, true));
// Enable Tracing support.
property(ServerProperties.TRACING, "ALL");
}
}
What could be the problem? I developed on tomcat8 (but don't remember using something specifically) and deployed on tomcat7. Could this be a problem?
This endpoint should be reachable: http://54.228.220.152:8080/GLI_API/api/item
The other API works fine - so the server in general is working.
Also - if you don't have the final answer i would really appreciate it if you can point me to files/directories to look at since i don't get any error.
You may try to enable annotation scanning by setting this init parameter to your servlet:
<servlet>
...
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.yourproject.packageWhereYourResourcesAre</param-value>
</init-param>
...
</servlet>
Update
It seems you have compiled against Java 8, while Tomcat runs with Java 7? Try this:
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
You may also want to update your web.xml to 3.0:
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
i have trouble with my maven web application what was created from maven-web-archetype. i am tried deploy my "helloworldapp" with tomcat7-maven-plugin, and it's not worked.
my errors list is there:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building weba Maven Webapp 1.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # web ---
[INFO] Deleting C:\Users\БОСС ЗДЕСЬ\IdeaProjects\projectb\web\target
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.401s
[INFO] Finished at: Mon Sep 14 13:34:27 GMT+04:00 2015
[INFO] Final Memory: 7M/109M
[INFO] ------------------------------------------------------------------------
C:\Users\БОСС ЗДЕСЬ\IdeaProjects\projectb>cd web
C:\Users\БОСС ЗДЕСЬ\IdeaProjects\projectb\web>mvn tomcat7:run
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building weba Maven Webapp 1.1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> tomcat7-maven-plugin:2.2:run (default-cli) # web >>>
Downloading: http://repository.jboss.com/maven2/org/apache/tomcat/tomcat-catalina/7.0.47/tomcat-catalina-7.0.47.jar
Downloading: http://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat-catalina/7.0.47/tomcat-catalina-7.0.47.jar
Downloaded: http://repo.maven.apache.org/maven2/org/apache/tomcat/tomcat-catalina/7.0.47/tomcat-catalina-7.0.47.jar (1548 KB at 316.4 KB/sec
)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # web ---
[WARNING] Using platform encoding (Cp1251 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.0:compile (default-compile) # web ---
[INFO] No sources to compile
[INFO]
[INFO] <<< tomcat7-maven-plugin:2.2:run (default-cli) # web <<<
[INFO]
[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) # web ---
[INFO] Running war on http://localhost:8080/web
[INFO] Creating Tomcat server configuration at C:\Users\БОСС ЗДЕСЬ\IdeaProjects\projectb\web\target\tomcat
[INFO] create webapp with contextPath: /web
ёхэ 14, 2015 1:39:44 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
ёхэ 14, 2015 1:39:44 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Tomcat
ёхэ 14, 2015 1:39:44 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
ёхэ 14, 2015 1:39:44 PM org.apache.tomcat.util.digester.Digester endElement
SEVERE: End event threw exception
java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:855)
at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:201)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1051)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.
java:2973)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1899)
at org.apache.catalina.startup.ContextConfig.getDefaultWebXmlFragment(ContextConfig.java:1469)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1246)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
ёхэ 14, 2015 1:39:44 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at file:/C:/Users/┴╬╤╤%20╟─┼╤▄/IdeaProjects/projectb/web/target/tomcat/conf/web.xml
org.xml.sax.SAXParseException; systemId: file:/C:/Users/┴╬╤╤%20╟─┼╤▄/IdeaProjects/projectb/web/target/tomcat/conf/web.xml; lineNumber: 108;
columnNumber: 15; Error at (108, 15) : org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2687)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2719)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1054)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.
java:2973)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1899)
at org.apache.catalina.startup.ContextConfig.getDefaultWebXmlFragment(ContextConfig.java:1469)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1246)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:878)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:376)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:855)
at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:201)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1051)
... 26 more
ёхэ 14, 2015 1:39:44 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Occurred at line 108 column 15
ёхэ 14, 2015 1:39:45 PM org.apache.catalina.startup.ContextConfig configureStart
SEVERE: Marking this application unavailable due to previous error(s)
ёхэ 14, 2015 1:39:45 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error getConfigured
ёхэ 14, 2015 1:39:45 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/web] startup failed due to previous errors
ёхэ 14, 2015 1:39:45 PM org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc
SEVERE: The web application [/web] registered the JDBC driver [org.postgresql.Driver] but failed to unregister it when the web application w
as stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
ёхэ 14, 2015 1:39:45 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
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">
<parent>
<artifactId>spring-webmvc</artifactId>
<groupId>org.epam</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>web</artifactId>
<packaging>war</packaging>
<version>1.1</version>
<name>weba Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>4.0.1.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.47</version>
<scope>provided</scope>
</dependency>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<version>3.0</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
</plugins>
<finalName>web</finalName>
</build>
</project>
parent's 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>org.epam</groupId>
<artifactId>spring-webmvc</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Memorina</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-util</artifactId>
<version>7.0.21</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>7.0.47</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.2-1003-jdbc4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>ejb3-persistence</artifactId>
<version>1.0.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.3.1.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.10</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>JBoss repository</id>
<url>http://repository.jboss.com/maven2/</url>
</repository>
</repositories>
<build>
<finalName>spring-webmvc</finalName>
</build>
<packaging>pom</packaging>
<modules>
<module>service</module>
<module>web</module>
<module>db</module>
<module>model</module>
</modules>
</project>
my web.xml is
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- ======================== Introduction ============================== -->
<!-- This document defines default values for *all* web applications -->
<!-- loaded into this instance of Tomcat. As each application is -->
<!-- deployed, this file is processed, followed by the -->
<!-- "/WEB-INF/web.xml" deployment descriptor from your own -->
<!-- applications. -->
<!-- -->
<!-- WARNING: Do not configure application-specific resources here! -->
<!-- They should go in the "/WEB-INF/web.xml" file in your application. -->
<!-- ================== Built In Servlet Definitions ==================== -->
<!-- The default servlet for all web applications, that serves static -->
<!-- resources. It processes all requests that are not mapped to other -->
<!-- servlets with servlet mappings (defined either here or in your own -->
<!-- web.xml file). This servlet supports the following initialization -->
<!-- parameters (default values are in square brackets): -->
<!-- -->
<!-- debug Debugging detail level for messages logged -->
<!-- by this servlet. [0] -->
<!-- -->
<!-- fileEncoding Encoding to be used to read static resources -->
<!-- [platform default] -->
<!-- -->
<!-- input Input buffer size (in bytes) when reading -->
<!-- resources to be served. [2048] -->
<!-- -->
<!-- listings Should directory listings be produced if there -->
<!-- is no welcome file in this directory? [false] -->
<!-- WARNING: Listings for directories with many -->
<!-- entries can be slow and may consume -->
<!-- significant proportions of server resources. -->
<!-- -->
<!-- output Output buffer size (in bytes) when writing -->
<!-- resources to be served. [2048] -->
<!-- -->
<!-- readonly Is this context "read only", so HTTP -->
<!-- commands like PUT and DELETE are -->
<!-- rejected? [true] -->
<!-- -->
<!-- readmeFile File to display together with the directory -->
<!-- contents. [null] -->
<!-- -->
<!-- sendfileSize If the connector used supports sendfile, this -->
<!-- represents the minimal file size in KB for -->
<!-- which sendfile will be used. Use a negative -->
<!-- value to always disable sendfile. [48] -->
<!-- -->
<!-- useAcceptRanges Should the Accept-Ranges header be included -->
<!-- in responses where appropriate? [true] -->
<!-- -->
<!-- For directory listing customization. Checks localXsltFile, then -->
<!-- globalXsltFile, then defaults to original behavior. -->
<!-- -->
<!-- localXsltFile Make directory listings an XML doc and -->
<!-- pass the result to this style sheet residing -->
<!-- in that directory. This overrides -->
<!-- contextXsltFile and globalXsltFile[null] -->
<!-- -->
<!-- contextXsltFile Make directory listings an XML doc and -->
<!-- pass the result to this style sheet which is -->
<!-- relative to the context root. This overrides -->
<!-- globalXsltFile[null] -->
<!-- -->
<!-- globalXsltFile Site wide configuration version of -->
<!-- localXsltFile This argument is expected -->
<!-- to be a physical file. [null] -->
<!-- -->
<!-- -->
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>0</param-value>
</init-param>
<init-param>
<param-name>listings</param-name>
<param-value>false</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
Help me,please!
I am new to the Vaadin framework which I looks very interesting, using eclipse and maven to develop and build my application I find pretty annoying that every time I do a mvn clean install it will take so long time to build the app, I found that this is because it compiles the whole set of widgets.
Even if I am only using a Button in my layout it will take so much on building the app.
I have researched for some time in the Internet and 2 books but cannot find enough information about how to make it to only compile components that I am using and not the whole set.
I created the project by using the maven archetype:
mvn archetype:generate -DarchetypeGroupId=com.vaadin -DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.1.9
I am sure that the widgetset is being compiled every time I build the war, when I do a mvn clean it removes the directory: /src/main/webapp/VAADIN/widgetsets and /src/main/webapp/VAADIN/gwt-unitCache
When I run mvn install the build will last for more than 3 minutes:
...
[INFO] Compiling 6 permutations
[INFO] Compiling permutation 0...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 1...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 3...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 2...
[INFO] Compiling permutation 4...
[INFO] Compiling
[INFO] Compiling permutation 5...
[INFO] Compile of permutations succeeded
[INFO] Linking into /.../example/src/main/webapp/VAADIN/widgetsets/com.my.example.AppWidgetSet; Writing extras to /.../example/target/extra/com.my.example.AppWidgetSet
[INFO] Link succeeded
[INFO] Compilation succeeded -- 167.103s
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # ade ---
[INFO] Packaging webapp
[INFO] Assembling webapp [example] in [/.../example/target/example-0.1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/.../example/src/main/webapp]
[INFO] Webapp assembled in [562 msecs]
[INFO] Building war: /.../example/target/example-0.1.0-SNAPSHOT.war
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) # ade ---
[INFO] Installing /.../example/target/example-0.1.0-SNAPSHOT.war to /.../example/0.1.0-SNAPSHOT/example-0.1.0-SNAPSHOT.war
[INFO] Installing /.../example/pom.xml to /.../example/0.1.0-SNAPSHOT/example-0.1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3:03.768s
[INFO] Finished at: Fri Jan 10 00:10:45 EST 2014
[INFO] Final Memory: 16M/81M
[INFO] ------------------------------------------------------------------------
After this the directory /src/main/webapp/VAADIN/widgetsets is generated again containing the following directories:
WEB-INF
com.my.example.AppWidgetSet
It also generates /src/main/webapp/VAADIN/gwt-unitCache
Do you need a custom widgetset? If you're not using any widget addons, and since your're new to Vaadin I am assuming that you did not create your own widgets yet(?), you can simply use the precompiled widgetset provided by Vaadin. To do this, remove any xxx.gwt.xml file from your project, and replace the reference to it in web.xml with com.vaadin.DefaultWidgetset.
web.xml:
<init-param>
<name>widgetset</name>
<value>com.vaadin.DefaultWidgetSet</value>
</init-param>
pom.xml:
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>7.1.9</version> <!-- or whatever version you're using -->
</dependency>
If you do need a custom widgetset (and if you don't now, chances are that you will need one further down the road), do yourself a favor and put it in a separate project. In my experience, a widgetset very seldom changes, so why include it in a project that constantly changes. The default widgetset mentioned above, provided by Vaadin, is the prefect blueprint for building one. Just build your own, and copy its structure from vaadin-client-compiled.jar. You can use your favourite maven build helper for that, mine is assembly. Just create a maven project, setup pom.xml, add a xxx.gwt.xml and make sure web.xml contains a reference to it. My own setup looks something like what you see below.
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>
<name>MyWidgetset</name>
<groupId>com.company</groupId>
<artifactId>mywidgetset</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<vaadin.version>7.1.9</vaadin.version>
<vaadin.plugin.version>7.1.9</vaadin.plugin.version>
</properties>
<dependencies>
<!-- vaadin -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
<version>${vaadin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiler</artifactId>
<version>${vaadin.version}</version>
<scope>provided</scope>
</dependency>
<!-- custom widgets (NOTE: addons without a widget do not belong here) -->
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>filteringtable</artifactId>
<version>0.9.3.v7</version>
</dependency>
<dependency>
<groupId>org.vaadin.addons</groupId>
<artifactId>popupbutton</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- vaadin update widgetset -->
<plugin>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-maven-plugin</artifactId>
<version>${vaadin.plugin.version}</version>
<configuration>
<extraJvmArgs>-Xmx512M -Xss1024k</extraJvmArgs>
<webappDirectory>${basedir}/target/VAADIN/widgetsets</webappDirectory>
<hostedWebapp>${basedir}/target/VAADIN/widgetsets</hostedWebapp>
<force>false</force>
<strict>true</strict>
<noServer>true</noServer>
<compileReport>true</compileReport>
<style>OBF</style>
<runTarget>http://localhost:8080/</runTarget>
</configuration>
<executions>
<execution>
<goals>
<goal>resources</goal>
<goal>update-widgetset</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/resources/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>vaadin-addons</id>
<url>http://maven.vaadin.com/vaadin-addons</url>
</repository>
</repositories>
</project>
assembly.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>build-my-widgetset-jar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/target/VAADIN/widgetsets</directory>
<outputDirectory>/VAADIN/widgetsets</outputDirectory>
<excludes>
<exclude>WEB-INF/</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>
MyWidgetset.gwt.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC
"-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.vaadin.DefaultWidgetSet" />
<inherits name="org.tepi.filtertable.gwt.FilterTableWidgetset" />
<inherits name="org.vaadin.hene.popupbutton.widgetset.PopupbuttonWidgetset" />
</module>
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>MyWidgetset</display-name>
<servlet>
<servlet-name>MyWidgetset</servlet-name>
<servlet-class>com.vaadin.server.VaadinServlet</servlet-class>
<init-param>
<param-name>ui</param-name>
<param-value>com.company.mywidgetset.App</param-value> <!-- use it for testing the widgetset-->
</init-param>
<init-param>
<param-name>widgetset</param-name>
<param-value>com.company.mywidgetset.MyWidgetset</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>MyWidgetset</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
project structure:
| pom.xml
|
\---src
+---main
| +---java
| | \---com
| | \---company
| | \---mywidgetset
| | App.java
| | MyWidgetset.gwt.xml
| |
| +---resources
| | assembly.xml
| |
| \---webapp
| \---WEB-INF
| web.xml
|
\---test
\---java
Build it, use the jar as a dependency in your project, and you're done. This will permanently release you from the big pain-in-the-butt that GWT calls "widgetset compilation".
To reduce the compile time of the widgetset you could and following to the .gwt.xml file and uncomment the set-property tag.
<!-- Uncomment the following to compile the widgetset for one browser only.
This can reduce the GWT compilation time significantly when debugging. The
line should be commented out before deployment to production environments.
Multiple browsers can be specified for GWT 1.7 as a comma separated list.
The supported user agents at the moment of writing were: ie6,ie8,gecko,gecko1_8,safari,opera
The value gecko1_8 is used for Firefox 3 and later and safari is used for
webkit based browsers including Google Chrome. -->
<!-- <set-property name="user.agent" value="gecko1_8"/> -->
to create a new vaadin-maven project, you could try use the vaadin 7 plugin new project wizard which will create a new project with ivy dependency management, after creating the project, right click on the project and remove ivy dependency management, and then right click --> configure--> convert it to maven project will add maven dependency management to the project.
Just dont compile any widget, use the default one; for that you must set the following files:
web.xml:
<init-param>
<name>widgetset</name>
<value>com.vaadin.DefaultWidgetSet</value>
</init-param>
Or in the UI implementation for your project:
/**
* Initial view in Vaadin
*/
#Theme("valo")
#Widgetset("com.vaadin.DefaultWidgetSet")
public class MainUI extends UI
{
Finally in the pom.xml include just these dependencies:
<!-- Vaadin dependencies -->
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-server</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client-compiled</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-themes</artifactId>
<version>${vaadin.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
Nothing else. I solved with these, i hope you too.
If you tired with constant compiling/recompiling widgetsets,
I suggest you to use "CDN Viritin Magic"
Benefits:
No #Widgetset
no need in maven-vaadin-plugin
Decreases compilation time in N-times.
Note 1 (for Vaadin Spring Boot users) :
After successful tutorial walkthrough(do not run mvn clean install yet!)
You have to define one more thing in YourAppNameApplication class :
#Bean
public in.virit.WidgetSet viritinCdnInitializer() {
return new in.virit.WidgetSet();
}
Note 2: It's OK to use alongside with spring-boot-maven-plugin
I have the following pom.xml (see below) for building a web-app on JBoss. I run maven like this :
mvn clean compile war:exploded jboss:hard-undeploy jboss:hard-deploy jboss:start-and-wait
Every goals run fine until i hit jboss:start-and-wait goal :\ JBoss refuses to start.
I got the following error :
(...)
[INFO] [jboss:start-and-wait {execution: default-cli}]
[INFO] Starting JBoss...
[INFO] Waiting to retrieve JBoss JMX MBean connection...
[INFO] Waiting to retrieve JBoss JMX MBean connection...
[INFO] Waiting to retrieve JBoss JMX MBean connection...
[INFO] Waiting to retrieve JBoss JMX MBean connection...
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Unable to get JBoss JMX MBean connection: null
org.jboss.jmx.adaptor.rmi.RMIAdaptor
(...)
By activating the DEBUG option on maven, i detected that the root cause is a ClassNotFoundException
org.jboss.jmx.adaptor.rmi.RMIAdaptor. Why do I get this exception since my pom.xml
does contain org.jboss.jmx.adaptor.rmi.RMIAdaptor in the jmx-adaptor-plugin jar dependency ?
Using jboss-all-client jar as dependency gives no more results.
What am I missing ?
Stephan
Configuration
Maven 2.2.1
JBoss 5.1.0.GA
JBoss Maven Plugin 1.5.0
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>
<parent>
<artifactId>foo</artifactId>
<groupId>com.company.foo</groupId>
<version>1.0.0</version>
</parent>
<groupId>com.company.foo</groupId>
<artifactId>foo-webapp</artifactId>
<packaging>war</packaging>
<name>foo-webapp</name>
<version>1.0.0</version>
<dependencies>
<!-- JSF 2.0 -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.3-b02</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.3-b02</version>
</dependency>
<!-- Primefaces -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<!-- <version>3.0.M1</version> -->
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>redmond</artifactId>
<version>1.0.0</version>
</dependency>
<!-- Others -->
<dependency>
<groupId>com.company.record</groupId>
<artifactId>record-dao</artifactId>
<version>1.0.0</version>
</dependency>
<!-- Postgresql -->
<dependency>
<groupId>postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>8.3-606.jdbc4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jboss</groupId>
<artifactId>jmx-adaptor-plugin</artifactId>
<version>3.2.1</version>
</dependency>
</dependencies>
<build>
<finalName>foo.war</finalName>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<useCache>false</useCache>
<!-- Prevent a bug from plugin (see http://jira.codehaus.org/browse/MWAR-248) -->
<packagingExcludes>WEB-INF/web.xml</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-maven-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<fileName>${project.build.directory}/${project.build.finalName}</fileName>
<serverName>web</serverName>
</configuration>
</plugin>
</plugins>
</build>
(...)
Try adding it to your plugin dependencies:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jboss-maven-plugin</artifactId>
<version>1.5.0</version>
<configuration>
<fileName>${project.build.directory}/${project.build.finalName}</fileName>
<serverName>web</serverName>
</configuration>
<dependencies>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-client</artifactId>
<type>pom</type>
<version>5.1.0.GA</version>
</dependency>
</dependencies>
</plugin>