2017-11-19 15 views
0

PCF経由で単純なアプリケーションをPivotal Webサービスにデプロイしようとしましたが、postgresqlまたはmysqlサービスのようなサービスをバインドするとアプリケーションがクラッシュします。SpringブートServiceバインディング付きPCFへのアプリケーションのデプロイ

MVN -DskipTests =真のクリーン

CFプッシュ-pターゲット/ CF-demo.jar cf102-デモをインストール

CFが作成:アプリケーションの構築およびデプロイする

手順は以下の通りです-serviceは

CFがcf102-デモ

0123をrestage

cardb CFバインドサービスcf102-デモcardbをスパークcleardb

アプリケーションソース - >https://github.com/babarbashir/cf-demo

package com.hrsuite.cfdemo; 

import org.springframework.boot.CommandLineRunner; 
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.data.jpa.repository.JpaRepository; 
import org.springframework.stereotype.Component; 
import org.springframework.stereotype.Repository; 
import org.springframework.web.bind.annotation.GetMapping; 
import org.springframework.web.bind.annotation.RestController; 

import javax.persistence.Entity; 
import javax.persistence.GeneratedValue; 
import javax.persistence.Id; 
import java.util.stream.Stream; 

@SpringBootApplication 
public class CfDemoApplication { 

    public static void main(String[] args) { 
     SpringApplication.run(CfDemoApplication.class, args); 
    } 
} 


@RestController 
class Greetoings{ 

    @GetMapping("/hi") 
    String hi(){ 
     return "Hello, Cloud Foundry from Windows"; 
    } 
} 


@Component 
class SampleDataCLR implements CommandLineRunner{ 

    private final CarRepository carRepository; 

    public SampleDataCLR(CarRepository carRepository) { 
     this.carRepository = carRepository; 
    } 

    @Override 
    public void run(String... args) throws Exception { 
     Stream.of("Mazda", "Toyota", "Nissan") 
     .forEach(name -> carRepository.save(new Car(name))); 

     carRepository.findAll().forEach(System.out::println); 

    } 
} 



@Repository 
interface CarRepository extends JpaRepository<Car, Long>{ 

} 



@Entity 
class Car{ 

    @Id 
    @GeneratedValue 
    private Long id; 
    private String name; 

    public Car() { //for JPA 
    } 

    public Car(String name) { 
     this.name = name; 
    } 


    public Long getId() { 
     return id; 
    } 

    public void setId(Long id) { 
     this.id = id; 
    } 

    public String getName() { 
     return name; 
    } 

    public void setName(String name) { 
     this.name = name; 
    } 

    @Override 
    public String toString() { 
     return "Car{" + 
       "id=" + id + 
       ", name='" + name + '\'' + 
       '}'; 
    } 
} 

ログはあなたが投稿したログは、それが適切なデータソースを見つけることができないことを示している

2017-11-22T09:24:52.733+03:00 [APP/PROC/WEB/0] [OUT] :: Spring Boot :: (v2.0.0.M6) 
2017-11-22T09:24:52.997+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:52.988 INFO 13 --- [ main] pertySourceApplicationContextInitializer : Adding 'cloud' PropertySource to ApplicationContext 
2017-11-22T09:24:56.715+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:56.408 INFO 13 --- [ main] urceCloudServiceBeanFactoryPostProcessor : Auto-reconfiguring beans of type javax.sql.DataSource 
2017-11-22T09:24:56.728+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:56.723 INFO 13 --- [ main] urceCloudServiceBeanFactoryPostProcessor : No matching service found. Skipping auto-reconfiguration. 
2017-11-22T09:24:57.090+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:57.090 INFO 13 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$8755c8ae] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 
2017-11-22T09:24:59.342+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.342 WARN 13 --- [ost-startStop-1] aWebConfiguration$JpaWebMvcConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning 
2017-11-22T09:24:59.411+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.410 ERROR 13 --- [ost-startStop-1] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsConfiguration.class]: Unsatisfied dependency expressed through method 'webMetricsFilter' parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcHandlerMappingIntrospector' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping]: Factory method 'requestMappingHandlerMapping' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'openEntityManagerInViewInterceptor' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/JpaBaseConfiguration$JpaWebConfiguration$JpaWebMvcConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "cloud" are currently active). 
2017-11-22T09:24:59.465+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.465 WARN 13 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat 
2017-11-22T09:24:59.491+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.491 INFO 13 --- [ main] utoConfigurationReportLoggingInitializer : 
2017-11-22T09:24:59.491+03:00 [APP/PROC/WEB/0] [OUT] Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled. 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] 2017-11-22 06:24:59.494 ERROR 13 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] *************************** 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] APPLICATION FAILED TO START 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] Description: 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] Cannot determine embedded database driver class for database type NONE 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] Action: 
2017-11-22T09:24:59.495+03:00 [APP/PROC/WEB/0] [OUT] If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "cloud" are currently active). 
2017-11-22T09:24:59.550+03:00 [APP/PROC/WEB/0] [OUT] Exit status 1 
2017-11-22T09:24:59.556+03:00 [CELL/SSHD/0] [OUT] Exit status 0 
2017-11-22T09:24:59.583+03:00 [API/22] [OUT] Process has crashed with type: "web" 
2017-11-22T09:24:59.594+03:00 [API/22] [OUT] App instance exited with guid 7d2b8a4c-5a2c-46af-a0a7-da376db94893 payload: {"instance"=>"458f5872-9dea-4690-4485-1115", "index"=>0, "reason"=>"CRASHED", "exit_description"=>"APP/PROC/WEB: Exited with status 1", "crash_count"=>1, "crash_timestamp"=>1511331899564724498, "version"=>"1c46af47-5605-4936-9846-61bdf9f50bdb"} 
2017-11-22T09:24:59.596+03:00 [CELL/0] [OUT] Stopping instance 458f5872-9dea-4690-4485-1115 
2017-11-22T09:24:59.596+03:00 [CELL/0] [OUT] Destroying container 
2017-11-22T09:24:59.935+03:00 [CELL/0] [OUT] Successfully destroyed container 
+1

cf logs cf102-demo -recentの出力は何ですか? –

+0

ありがとうございましたJosh、あなたの参照のためのログを追加しました。 – BABAR

答えて

0

以下の通りです。

<dependency> 
    <groupId>org.springframework.cloud</groupId> 
    <artifactId>spring-cloud-cloudfoundry-connector</artifactId> 
    <version>2.0.1.RELEASE</version> 
</dependency> 

これらのコネクタは、あなたのVCAP_SERVICES環境変数を検査し、DataSource豆を作成するために、春のランタイムで使用することができますServiceInfoオブジェクトを作成します:あなたのコードを見た後、私はあなたのPOMに次と再び試みる追加することをお勧め。

関連する問題