2017-01-12 5 views
0

У меня есть проект Java (RESTful Services), который я разработал на машине Windows в Eclipse и работает на сервере Wildfly 10. Все работает отлично. Теперь я пытаюсь развернуть тот же проект на Eclipse на машине OSX.Запустить приложение Spring на сервере JBoss Wildfly

Я установил Eclipse Neon 2 и импортировал проект Java. Я также установил Wildfly 10 Server. Проект Java был опубликован на сервере. Я могу запустить сервер, и получить доступ к Welcome to WildFly страницу на:

localhost:8080/ 

Также в консоли, вы можете увидеть, что Spring RESTful обслуживает все нагрузки:

например

Mapped "{[/category/list],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.jobs.spring.domain.Category>> com.jobs.spring.controller.CategoryRESTService.findAllCategorys() 

enter image description here

Логи сервера идентичны среде Windows.

20:39:10,051 INFO [org.jboss.modules] (main) JBoss Modules version 1.5.2.Final 
20:39:20,242 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.6.Final 
20:39:20,309 INFO [org.jboss.as] (MSC service thread 1-6) WFLYSRV0049: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) starting 
20:39:21,277 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) WFLYDS0004: Found jbosswildfly-1.0.war in deployment directory. To trigger deployment create a file called jbosswildfly-1.0.war.dodeploy 
20:39:21,316 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0039: Creating http management service using socket-binding (management-http) 
20:39:21,332 INFO [org.xnio] (MSC service thread 1-1) XNIO version 3.4.0.Final 
20:39:21,339 INFO [org.xnio.nio] (MSC service thread 1-1) XNIO NIO Implementation Version 3.4.0.Final 
20:39:21,370 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 38) WFLYCLINF0001: Activating Infinispan subsystem. 
20:39:21,374 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 46) WFLYNAM0001: Activating Naming Subsystem 
20:39:21,384 INFO [org.jboss.as.security] (ServerService Thread Pool -- 53) WFLYSEC0002: Activating Security Subsystem 
20:39:21,388 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 37) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors 
20:39:21,384 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 54) WFLYTX0013: Node identifier property is set to the default value. Please make sure it is unique. 
20:39:21,390 INFO [org.jboss.as.security] (MSC service thread 1-5) WFLYSEC0001: Current PicketBox version=4.9.6.Final 
20:39:21,406 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 44) WFLYJSF0007: Activated the following JSF Implementations: [main] 
20:39:21,419 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 56) WFLYWS0002: Activating WebServices Extension 
20:39:21,533 INFO [org.jboss.as.naming] (MSC service thread 1-5) WFLYNAM0003: Starting Naming Service 
20:39:21,543 INFO [org.jboss.as.connector] (MSC service thread 1-5) WFLYJCA0009: Starting JCA Subsystem (WildFly/IronJacamar 1.3.4.Final) 
20:39:21,549 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0003: Undertow 1.4.0.Final starting 
20:39:21,545 INFO [org.jboss.as.mail.extension] (MSC service thread 1-1) WFLYMAIL0001: Bound mail session [java:jboss/mail/Default] 
20:39:21,554 INFO [org.jboss.remoting] (MSC service thread 1-8) JBoss Remoting version 4.0.21.Final 
20:39:21,552 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 33) WFLYJCA0004: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3) 
20:39:21,568 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) WFLYJCA0018: Started Driver service with driver-name = h2 
20:39:21,695 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 55) WFLYUT0014: Creating file handler for path '/Users/richardmarais/Development/servers/wildfly-10.1.0.Final/welcome-content' with options [directory-listing: 'false', follow-symlink: 'false', case-sensitive: 'true', safe-symlink-paths: '[]'] 
20:39:21,704 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0012: Started server default-server. 
20:39:21,708 INFO [org.wildfly.extension.undertow] (MSC service thread 1-6) WFLYUT0018: Host default-host starting 
20:39:21,843 INFO [org.jboss.as.ejb3] (MSC service thread 1-5) WFLYEJB0482: Strict pool mdb-strict-max-pool is using a max instance size of 32 (per class), which is derived from the number of CPUs on this host. 
20:39:21,844 INFO [org.jboss.as.ejb3] (MSC service thread 1-7) WFLYEJB0481: Strict pool slsb-strict-max-pool is using a max instance size of 128 (per class), which is derived from thread worker pool sizing. 
20:39:21,846 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) WFLYUT0006: Undertow HTTP listener default listening on 127.0.0.1:8080 
20:39:22,063 WARN [org.jboss.as.domain.management.security] (MSC service thread 1-7) WFLYDM0111: Keystore /Users/richardmarais/Development/servers/wildfly-10.1.0.Final/standalone/configuration/application.keystore not found, it will be auto generated on first use with a self signed certificate for host localhost 
20:39:22,083 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-5) WFLYDS0013: Started FileSystemDeploymentService for directory /Users/richardmarais/Development/servers/wildfly-10.1.0.Final/standalone/deployments 
20:39:22,096 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "jbosswildfly-1.0.war" (runtime-name: "jbosswildfly-1.0.war") 
20:39:22,315 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.4.Final 
20:39:22,351 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated. 
20:39:22,351 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 63) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated. 
20:39:22,351 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 59) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated. 
20:39:22,352 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 65) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated. 
20:39:22,353 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 63) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated. 
20:39:22,353 INFO [org.infinispan.configuration.cache.EvictionConfigurationBuilder] (ServerService Thread Pool -- 59) ISPN000152: Passivation configured without an eviction policy being selected. Only manually evicted entities will be passivated. 
20:39:22,359 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443 
20:39:22,705 INFO [org.jboss.ws.common.management] (MSC service thread 1-7) JBWS022052: Starting JBossWS 5.1.5.Final (Apache CXF 3.1.6) 
20:39:31,951 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS] 
20:39:32,148 INFO [org.jboss.weld.deployer] (MSC service thread 1-5) WFLYWELD0003: Processing weld deployment jbosswildfly-1.0.war 
20:39:32,206 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-5) HV000001: Hibernate Validator 5.2.4.Final 
20:39:32,440 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1) 
20:39:32,441 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0005: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1) 
20:39:32,444 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-4) WFLYJCA0005: Deploying non-JDBC-compliant driver class org.postgresql.Driver (version 9.2) 
20:39:32,473 INFO [org.jboss.weld.Version] (MSC service thread 1-4) WELD-000900: 2.3.5 (Final) 
20:39:32,509 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-5) WFLYJCA0018: Started Driver service with driver-name = jbosswildfly-1.0.war_com.mysql.jdbc.Driver_5_1 
20:39:32,510 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = jbosswildfly-1.0.war_com.mysql.fabric.jdbc.FabricMySQLDriver_5_1 
20:39:32,512 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-6) WFLYJCA0018: Started Driver service with driver-name = jbosswildfly-1.0.war_org.postgresql.Driver_9_2 
20:39:33,458 INFO [io.undertow.servlet] (ServerService Thread Pool -- 68) 1 Spring WebApplicationInitializers detected on classpath 
20:39:33,532 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 68) Initializing Mojarra 2.2.13.SP1 20160303-1204 for context '/jbosswildfly-1.0' 
20:39:34,739 INFO [io.undertow.servlet] (ServerService Thread Pool -- 68) Initializing Spring FrameworkServlet 'rest' 
20:39:34,741 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 68) FrameworkServlet 'rest': initialization started 
20:39:34,745 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (ServerService Thread Pool -- 68) Refreshing WebApplicationContext for namespace 'rest-servlet': startup date [Thu Jan 12 20:39:34 SAST 2017]; root of context hierarchy 
20:39:34,778 INFO [org.springframework.web.context.support.AnnotationConfigWebApplicationContext] (ServerService Thread Pool -- 68) Registering annotated classes: [class com.jobs.spring.configuration.AppConfig] 
20:39:35,061 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (ServerService Thread Pool -- 68) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring 
20:39:35,171 INFO [org.springframework.jdbc.datasource.DriverManagerDataSource] (ServerService Thread Pool -- 68) Loaded JDBC driver: com.mysql.jdbc.Driver 
20:39:35,262 INFO [org.hibernate.Version] (ServerService Thread Pool -- 68) HHH000412: Hibernate Core {5.2.1.Final} 
20:39:35,264 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 68) HHH000206: hibernate.properties not found 
20:39:35,265 INFO [org.hibernate.cfg.Environment] (ServerService Thread Pool -- 68) HHH000021: Bytecode provider name : javassist 
20:39:35,300 INFO [org.hibernate.annotations.common.Version] (ServerService Thread Pool -- 68) HCANN000001: Hibernate Commons Annotations {5.0.1.Final} 
20:39:35,588 WARN [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator] (ServerService Thread Pool -- 68) HHH000342: Could not obtain connection to query metadata : Access denied for user 'admin'@'localhost' (using password: YES) 
20:39:35,596 INFO [org.hibernate.dialect.Dialect] (ServerService Thread Pool -- 68) HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect 
20:39:35,606 INFO [org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl] (ServerService Thread Pool -- 68) HHH000422: Disabling contextual LOB creation as connection was null 
20:39:36,268 WARN [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (ServerService Thread Pool -- 68) Autowired annotation is not supported on static fields: private static final java.util.logging.Logger com.jobs.spring.service.EmailServiceImpl.logger 
20:39:36,456 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 68) Mapped "{[/category/list],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.jobs.spring.domain.Category>> com.jobs.spring.controller.CategoryRESTService.findAllCategorys() 
20:39:36,459 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 68) Mapped "{[/category/list/{id}],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<com.jobs.spring.domain.Category> com.jobs.spring.controller.CategoryRESTService.findCategoryById(java.lang.String) 
20:39:36,461 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 68) Mapped "{[/email/password/{email}/{userName}],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.lang.String> com.jobs.spring.controller.EmailRESTService.requestPassword(java.lang.String,java.lang.String) 
20:39:36,493 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 68) Mapped "{[/subcategory/list/{categoryId}],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.jobs.spring.domain.SubCategory>> com.jobs.spring.controller.SubCategoryRESTService.findAllCategorys(java.lang.String) 
20:39:36,494 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 68) Mapped "{[/subcategory/list],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<java.util.List<com.jobs.spring.domain.SubCategory>> com.jobs.spring.controller.SubCategoryRESTService.findAllCategorys() 
20:39:36,494 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 68) Mapped "{[/subcategory/{id}],methods=[GET],produces=[application/json]}" onto public org.springframework.http.ResponseEntity<com.jobs.spring.domain.SubCategory> com.jobs.spring.controller.SubCategoryRESTService.findCategoryById(java.lang.String) 
20:39:36,778 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter] (ServerService Thread Pool -- 68) Looking for @ControllerAdvice: WebApplicationContext for namespace 'rest-servlet': startup date [Thu Jan 12 20:39:34 SAST 2017]; root of context hierarchy 
20:39:36,881 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 68) FrameworkServlet 'rest': initialization completed in 2140 ms 
20:39:36,882 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 68) WFLYUT0021: Registered web context: /jbosswildfly-1.0 
20:39:36,916 INFO [org.jboss.as.server] (ServerService Thread Pool -- 34) WFLYSRV0010: Deployed "jbosswildfly-1.0.war" (runtime-name : "jbosswildfly-1.0.war") 
20:39:37,006 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management 
20:39:37,006 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990 
20:39:37,007 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0025: WildFly Full 10.1.0.Final (WildFly Core 2.2.0.Final) started in 27297ms - Started 953 of 1201 services (404 services are lazy, passive or on-demand) 

Однако, если я пытаюсь получить доступ к одной из RESTful услуг, например:

http://localhost:8080/jbosswildfly/category/list 

я получаю:

404 - Not Found

И

Также возвращает:

404 - Not Found

Так что я думаю, что-то не так с корневым контекстом: jbosswildfly

код в точности так же, как среды Windows, так Я бы ожидал, что среда OSX будет работать.

Я не уверен, есть ли проблема с моим Wildfly Server или моей конфигурацией Spring или что-то еще.

WebInitializer.java

public class WebAppInitializer implements WebApplicationInitializer { 

    @Override 
    public void onStartup(ServletContext servletContext) throws ServletException { 
     AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); 
     ctx.register(AppConfig.class); 
     ctx.setServletContext(servletContext); 
     Dynamic dynamic = servletContext.addServlet("rest", new DispatcherServlet(ctx)); 
     dynamic.addMapping("/*"); 
     dynamic.setLoadOnStartup(1); 
    } 
} 

onStartup выше метод действительно становится вызывается при запуске.

CategoryRESTService.java

@CrossOrigin(origins = {"*"}) 
@RestController 
@RequestMapping(CategoryRESTService.BASE_URI) 
public class CategoryRESTService { 

    public static final String BASE_URI = "/category"; 

    @Autowired 
    private CategoryService categoryService; 

    @RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) 
    public ResponseEntity<List<Category>> findAllCategorys() { 
     List<Category> categories = categoryService.findAll(); 
     return new ResponseEntity<List<Category>>(categories, HttpStatus.OK); 
    } 

    @RequestMapping(value = "/list/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) 
    public ResponseEntity<Category> findCategoryById(@PathVariable String id) { 
     Category category = categoryService.findById(id); 
     return new ResponseEntity<Category>(category, HttpStatus.OK); 
    } 
} 

Приложение также успешно работает на сервере OpenShift с Wildfly 10 картриджа.

Любая помощь приветствуется.

ответ

2

Кажется, вы должны получить доступ через:

http://localhost:8080/jbosswildfly-1.0/category/list

+0

Спасибо !!! Это была проблема. – Richard

Смежные вопросы