I was doing some research last time about web services that could provide build & deployment of my Java web application. I found Heroku which seemed to be okay but I encountered some problem.
First of all, my application uses Spring MVC (not Spring Boot), I have manual java-based annotation configuration without web.xml at all. That's about setup. Now when it comes to mentioned error, I connected Heroku with my GitHub repository, then deployed it. Everything built fine with one single problem at the end which looks following:
2018-03-23T07:12:02.679019+00:00 app[web.1]: Error: Main method not found in class th.config.MyWebAppInitializer, please define the main method as:
2018-03-23T07:12:02.679037+00:00 app[web.1]: public static void main(String[] args)
2018-03-23T07:12:02.679150+00:00 app[web.1]: or a JavaFX application class must extend javafx.application.Application
Apparently Heroku environment requires a class that contains main method, which does not exist in my application, at least not in my own code, but probably somewhere in class that runs servlets, like ServletInitializer or something like that. I tried to use flag <skipMain>true</skipMain> flag in order to skip this but without any luck.
Here I include my pom.xml file:
<?xml version="1.0" encoding="UTF-8"?>
....
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<skipMain>true</skipMain>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>prepare-package</phase>
<configuration>
<skipMain>true</skipMain>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<phase>package</phase>
<goals><goal>copy-dependencies</goal></goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>7.0.22.3</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>webofficesuite</groupId>
<artifactId>webofficesuite</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- SPRING COMPONENTS -->
<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.13.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.13.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.3.13.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.13.RELEASE</version>
</dependency>
<!-- SPRING SECURITY -->
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-config -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-taglibs -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
<!-- Spring ORM -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>4.3.13.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-dbcp</artifactId>
<version>7.0.55</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-catalina -->
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-catalina</artifactId>
<version>9.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/jstl/jstl -->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
...Other dependencies
</dependencies>
I would appreciate any help or guide that would allow me to successfully deploy my app. Additionally I tried other web service that is called OpenShift and I managed to deploy my application there, but I don't like that it is hardly possible to remotely connect to a mysql database, so I would prefer the Heroku solution. But if there are any other good web service hostings that you would recommend I am open for suggestions. The only requirement is that it doesn't cost ridiculously much money per month because it won't be huge application that require a lot of cores and memory.
Make sure your Procfile contains something like this:
web: java -jar target/dependency/webapp-runner.jar --port $PORT target/*.war
You can learn more about using Webapp Runner in the Heroku documentation on Deploying Tomcat-based Java Web Applications with Webapp Runner
Related
I have developed a spring boot application to run on google app engine with google sql and its working in local perfect. When i deploy the application and the rest url its working for sometime and after an hour i get the following . After deploying the code to google app engine i am able to fetch the records from database and doesnt fetch records after an hour. I am using Spring boot version 2.0.0.RELEASE and java 8
Error
org.hibernate.exception.JDBCConnectionException: Unable to open JDBC Connection for DDL execution
these are the configurations i am working with
POM.XML
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpcore -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.cloud.sql/mysql-socket-factory -->
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>1.0.5</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-net/commons-net -->
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.21.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.0.0.RELEASE</version>
</plugin>
<!-- [START cloudplugin] -->
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>1.3.1</version>
</plugin>
<!-- [END cloudplugin] -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>display-dependency-updates</goal>
<goal>display-plugin-updates</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>javax.servlet:javax.servlet-api</exclude>
<exclude>com.google.guava:guava</exclude> <!-- avoid android version -->
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
application.properties
spring.datasource.url=jdbc:mysql://google/fbconferencebot?cloudSqlInstance=conference:us-central1:appconference&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=root&password=*****
spring.jpa.hibernate.ddl-auto=none
spring.datasource.username=root
spring.datasource.password=*******
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database=MYSQL
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
It's hard to tell without a more detailed stack trace, but you should replace Hibernate's connection pooling as it's not intended for production. This will handle the underlying connections. There is a good SO answer on configuring HikariCP w/ Spring Boot here.
Additionally, you should take a look at the Spring Boot Cloud SQL starter that Mike mentioned - it includes HikariCP as a dependency.
I have the following error when I execute the command mvn install. I have seen few posts online related to my problem but I still could not resolve my issue. The error is:
<<< ERROR! java.lang.NoSuchMethodError:
org.springframework.beans.BeanUtils.instantiateClass(Ljava/lang/Class;Ljava/lang/Class;)Ljava/lang/Object;
at
org.springframework.test.context.ContextLoaderUtils.resolveContextLoader(ContextLoaderUtils.java:87)
And here is my pom.xml file:
<!-- this file is generated with GWT webAppCreator -->
<modelVersion>4.0.0</modelVersion>
<groupId>com.mangroove.utils.MangrooveApp</groupId>
<artifactId>MangrooveWeb</artifactId>
<packaging>war</packaging>
<version>0.0.0</version>
<name>Mangroove appplication UI</name>
<parent>
<groupId>com.mangroove</groupId>
<artifactId>mangroove-super-pom</artifactId>
<version>0.0.0.11</version>
</parent>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<!-- Version properties -->
<gwtVersion>2.4.0</gwtVersion>
<springVersion>3.1.1.RELEASE</springVersion>
<mangroovedao.version>[0.0,1.0)</mangroovedao.version>
<Project1.version>[1.20,1.21)</Project1.version>
<Project2.version>1.0.0.98</Project2.version>
<!-- Maven will save WAR file here -->
<final.name>MangrooveUI</final.name>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
</properties>
<dependencies>
<dependency>
<groupId>com.mangroove.dao</groupId>
<artifactId>MangrooveDao</artifactId>
<version>${mangroovedao.version}</version>
</dependency>
<dependency>
<groupId>com.mangroove.dao</groupId>
<artifactId>MangrooveDao</artifactId>
<version>${mangroovedao.version}</version>
<classifier>sources</classifier>
<scope>provided</scope>
</dependency>
<!-- Project1 dependency -->
<dependency>
<groupId>com.project1</groupId>
<artifactId>Project1</artifactId>
<version>${Project1.version}</version>
</dependency>
<!-- Project2 dependency -->
<dependency>
<groupId>com.project2</groupId>
<artifactId>Project2</artifactId>
<version>${Project2.version}</version>
</dependency>
<!-- GWT dependencies -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwtVersion}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<!-- Testing/validation dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
<classifier>sources</classifier>
<scope>test</scope>
</dependency>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.mangroove</groupId>
<artifactId>xhtmlrenderer-core-renderer</artifactId>
<version>[8.0.1,)</version>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
<dependency>
<groupId>jexcelapi</groupId>
<artifactId>jxl</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk16</artifactId>
<version>1.46</version>
</dependency>
<dependency>
<groupId>org.jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.23</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes><exclude>MangrooveWeb.xml</exclude></excludes>
</resource>
</resources>
<plugins>
<!-- Copy static web files before executing gwt:run -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
<configuration>
<webappDirectory>${webappDirectory}</webappDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<!-- <goal>test</goal> -->
<goal>generateAsync</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>Main.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
</configuration>
</plugin>
</plugins>
</build>
</project>
I am not sure this task can solve 100% problem, but it is better:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springVersion}</version>
<scope>test</scope>
</dependency>
(add scope test)
The error seems to be due to incompatible libraries being used. The spring version you are using may not support Java 1.7
http://docs.spring.io/spring/docs/3.1.1.RELEASE/spring-framework-reference/html/new-in-3.0.html#new-in-3.0-intro
Try either bumping up the spring version or downgrading the java version. Also, make sure there are no libraries with 2 different versions being added implicitly causing the incompatibility. If you are using an IDE like eclipse, try the maven plugin and see the versions of all the libraries it is resolving to. Few of the libraries you are using implicitly may download different version of a dependent library causing the conflict.
Please help me with details given at article Secure Spring REST API using OAuth2.
How to run the SpringRestClient from the given source code?
Here's the pom.xml, what is missing?
<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.websystique.springmvc</groupId>
<artifactId>SpringSecurityOAuth2Example</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<name>SpringSecurityOAuth2Example</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springframework.version>4.3.1.RELEASE</springframework.version>
<springsecurity.version>4.1.1.RELEASE</springsecurity.version>
<springsecurityoauth2.version>2.0.10.RELEASE</springsecurityoauth2.version>
<jackson.library>2.7.5</jackson.library>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${springsecurity.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${springsecurity.version}</version>
</dependency>
<!-- Spring Security OAuth2-->
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>${springsecurityoauth2.version}</version>
</dependency>
<!-- Jackson libraries -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.library}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
<version>${jackson.library}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>SpringSecurityOAuth2Example</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
<finalName>SpringSecurityOAuth2Example</finalName>
</build>
Please note that the Postman Client works fine. What is the Maven command to run the SpringRestClient Class? The SpringSecurityOAuth2Example.war is generated from mvn package.
Thanks
Consider your pom.xml is inside SpringSecurityOAuth2Example folder so from that folder you can run below command. Please make sure your war file is deployed in tomcat and server is running as SpringRestClient will look for service at http://localhost:8080/SpringSecurityOAuth2Example. Please restart you tomcat before running this command otherwise it might throw error.
mvn -Dexec.mainClass=com.websystique.springmvc.SpringRestClient -Dexec.classpathScope=test test-compile exec:java
I am trying to run my app on Heroku but it doesn't work. From logs I can see the below:
2016-01-18T13:38:31.621218+00:00 heroku[web.1]: Process exited with
status 1 2016-01-18T13:38:48.101117+00:00 app[web.1]: Error: Unable to
access jarfile target/dependency/webapp-runner-8.0.30.1.jar
2016-01-18T13:38:48.100249+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS
defaults based on dyno size. Custom settings will override them.
2016-01-18T13:38:48.700243+00:00 heroku[web.1]: State changed from
starting to crashed 2016-01-18T13:43:12.241285+00:00 heroku[router]:
at=error code=H10 desc="App crashed" method=GET path="/"
host=macfol.herokuapp.com
request_id=c6418015-843d-4f5a-8dde-83130e94a7c6 fwd="159.220.74.5"
dyno= connect= service= status=503 bytes=
I have been unsuccessfully trying to modify both pom.xml as well as procfile in order that Heroku will finally find that .jar.
There is the procfile:
web: java $JAVA_OPTS -jar target/dependency/webapp-runner-8.0.30.1.jar --target/kamienica
And the pom.xml
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>kamienica</groupId>
<packaging>war</packaging>
<version>1.0.0</version>
<name>Kamienica</name>
<properties>
<springframework.version>4.0.6.RELEASE</springframework.version>
<hibernate.version>4.3.6.Final</hibernate.version>
<mysql.version>5.1.31</mysql.version>
<joda-time.version>2.3</joda-time.version>
<testng.version>6.9.4</testng.version>
<mockito.version>1.10.19</mockito.version>
<h2.version>1.4.187</h2.version>
<dbunit.version>2.2</dbunit.version>
</properties>
<dependencies>
<!-- Spring -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${springframework.version}</version>
</dependency>
<!-- Hibernate -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- jsr303 validation -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.3.Final</version>
</dependency>
<!-- MySQL -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
<!-- Joda-Time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${joda-time.version}</version>
</dependency>
<!-- To map JodaTime with database type -->
<dependency>
<groupId>org.jadira.usertype</groupId>
<artifactId>usertype.core</artifactId>
<version>3.0.0.CR1</version>
</dependency>
<!-- Servlet+JSP+JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
<scope>compile</scope>
</dependency>
<!-- Testing dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${springframework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>${h2.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>${dbunit.version}</version>
<scope>test</scope>
</dependency>
<!-- for rest -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.1.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.1</version>
</dependency>
<!-- Spring Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.0.30.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>spring-snapshot</id>
<name>Spring Snapshot Repository</name>
<url>http://repo.springsource.org/snapshot</url>
</repository>
</repositories>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>Kamienica</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.github.jsimone</groupId>
<artifactId>webapp-runner</artifactId>
<version>8.0.24.0</version>
<destFileName>webapp-runner.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<finalName>Kamienica</finalName>
</build>
<artifactId>Kamienica</artifactId>
</project>
The "missing" jar can be found in maven dependencies.
Appreciate your help
EDIT
The procfile is now:
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port
$PORT target/kamienica.war
No result...
EDIT 2
There is some progress as it crashes elsewhere ;)
EDIT 3
It's working! Thank you all for making this possible. Finally my app is there. It took me 12 months to reach this point.
Thank you again! :)
First Remove the start <pluginManagement> and end <pluginManagement/> tags in pom.xml (Do not delete the content inside it). By including this, the dependency directory and the webapp-runner-8.0.30.1.jar will not be created and the application is getting crashed when executing the java command.
Change the finalName tag to <finalName>kamienica</finalName> . Right now you have the capital letter(K) in the <finalName>...</finalName> tag. Change it to small letter as you named it in web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/kamienica.war
Change the name to <warName>kamienica</warName> in maven-war-plugin plugin
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>src/main/webapp</warSourceDirectory>
<warName>kamienica</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
Your destFileName is webapp-runner.jar but your referencing to another jar in your Procfile:
web: java $JAVA_OPTS -jar target/dependency/webapp-runner-8.0.30.1.jar --target/kamienica
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Version is redundant
Use this instead:
web: java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/Kamienica.war
I am using Hibernate 4, Spring 3 and JSF 2.0 and Weblogic 10.3.6
I have the following in DAO class
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
CriteriaQuery<Request> c = cb.createQuery(Request.class);
When I run my application I am getting the following exception.
javax.persistence.EntityManager.getCriteriaBuilder()Ljavax/persistence/criteria
/CriteriaBuilder;
java.lang.NoSuchMethodError:
javax.persistence.EntityManager.getCriteriaBuilder()Ljavax/persistence/criteria
/CriteriaBuilder;
at net.test.request.dao.RequestDAOImpl.getRequest(RequestDAOImpl.java:51)
I did not use JPA1 jars, however I am still getting this exception. Not able to figure how to get rid of this exception. Any help is highly appreciable.
Thanks
pom.xml
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
<properties>
<spring.version>3.1.1.RELEASE</spring.version>
</properties>
<dependencies>
<!-- Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
<!-- JSF library -->
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<!-- Primefaces library -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>flick</artifactId>
<version>1.0.8</version>
</dependency>
<!-- Hibernate library -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- Oracle Java Connector library -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
<dependency>
<groupId>c3p0</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.1.2</version>
</dependency>
<!-- Log4j library -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.4</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>1.2.0.Final</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<!-- source output directory -->
<outputDirectory>target/metamodel</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
The method EntityManager.getCriteriaBuilder is a part of JPA 2 (which is part of Java EE 6), which is not provided and/or turned on by default in WebLogic 10.
Here is a link http://docs.oracle.com/cd/E17904_01/web.1111/e13720/using_toplink.htm which provides instructions that may fix your problem. If not, you'll need to start googling "weblogic 10 jpa 2" and see if you can find a solution that works for you.
If none of these solutions work, your last resort will be to redesign your application to only use JPA 1 methods. To use JPA 1 you must limit yourself to the classes and interfaces defined here: http://docs.oracle.com/javaee/5/api/javax/persistence/package-summary.html
[update]
Or - since you are using Hibernate anyways, don't rely so much on JPA classes. Use hibernate specific classes instead. Hibernate has had criteria since 3.x. Instead of an EntityManager you create a Hibernate session factory. Then you can do:
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
...
Session session = sessionFactory.openSession();
Criteria crit = session.createCriteria(Person.class);
Your code is now locked into using Hibernate as your persistence provider. In my case we always use Hibernate so it's not a real problem. This is a question you have to decide for yourself. If your application can tolerate being locked into Hibernate, this should give you the functionality you need while still running on WebLogic.