我已经在eclipse-neon中安装了Jboss插件,并且在部署时遇到了一些问题,更具体地说,从eclipse部署时没有进行控制器映射,我花了一段时间才注意到为什么我的应用程序无法工作直到我密切关注控制台:
使用eclipse部署时的Jboss控制台
09:53:07,024 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 106) updating schema
09:53:07,026 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 106) schema update complete
09:53:07,062 INFO [org.springframework.orm.hibernate3.HibernateTransactionManager] (ServerService Thread Pool -- 106) Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@5710e515] of Hibernate SessionFactory for HibernateTransactionManager
09:53:07,087 INFO [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 106) Root WebApplicationContext: initialization completed in 618 ms
09:53:07,090 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 106) Initializing Mojarra 2.2.12-jbossorg-2 for context '/TestPJ-2'
09:53:07,611 INFO [io.undertow.servlet] (ServerService Thread Pool -- 106) Initializing Spring FrameworkServlet 'deServlet'
09:53:07,611 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 106) FrameworkServlet 'deServlet': initialization started
09:53:07,613 INFO [org.springframework.web.context.support.XmlWebApplicationContext] (ServerService Thread Pool -- 106) Refreshing WebApplicationContext for namespace 'deServlet-servlet': startup date [Wed Apr 05 09:53:07 CDT 2017]; parent: Root WebApplicationContext
09:53:07,613 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 106) Loading XML bean definitions from ServletContext resource [/WEB-INF/deServlet-servlet.xml]
09:53:07,659 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (ServerService Thread Pool -- 106) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
09:53:07,728 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (ServerService Thread Pool -- 106) Mapped URL path [/pages/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
09:53:07,859 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 106) FrameworkServlet 'deServlet': initialization completed in 248 ms
09:53:07,860 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 106) WFLYUT0021: Registered web context: /TestPJ-2
09:53:07,880 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) WFLYSRV0010: Deployed "TestPJ-2.war" (runtime-name : "TestPJ-2.war")
直接部署时的Jboss控制台
09:28:32,619 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 71) updating schema
09:28:32,621 INFO [org.hibernate.tool.hbm2ddl.SchemaUpdate] (ServerService Thread Pool -- 71) schema update complete
09:28:32,802 INFO [org.springframework.orm.hibernate3.HibernateTransactionManager] (ServerService Thread Pool -- 71) Using DataSource [org.springframework.jdbc.datasource.DriverManagerDataSource@3fb339bb] of Hibernate SessionFactory for HibernateTransactionManager
09:28:32,915 INFO [org.springframework.security.web.DefaultSecurityFilterChain] (ServerService Thread Pool -- 71) Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@5481c4f2, org.springframework.security.web.context.SecurityContextPersistenceFilter@3bf500d5, org.springframework.security.web.header.HeaderWriterFilter@5162956e, org.springframework.security.web.authentication.logout.LogoutFilter@37b243f2, com.pier.security.filters.JwtAuthenticationTokenFilter@10d418a7, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@49ee8f82, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@48cd3f9d, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@274b25f9, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@2624ef4d, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@258c1ccf, org.springframework.security.web.session.SessionManagementFilter@2ed083b3, org.springframework.security.web.access.ExceptionTranslationFilter@157aedd3, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@614ad1d3]
09:28:32,946 INFO [org.springframework.web.context.ContextLoader] (ServerService Thread Pool -- 71) Root WebApplicationContext: initialization completed in 2388 ms
09:28:32,980 INFO [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 71) Initializing Mojarra 2.2.12-jbossorg-2 for context '/TestPJ-2'
09:28:33,780 INFO [io.undertow.servlet] (ServerService Thread Pool -- 71) Initializing Spring FrameworkServlet 'deServlet'
09:28:33,780 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 71) FrameworkServlet 'deServlet': initialization started
09:28:33,781 INFO [org.springframework.web.context.support.XmlWebApplicationContext] (ServerService Thread Pool -- 71) Refreshing WebApplicationContext for namespace 'deServlet-servlet': startup date [Wed Apr 05 09:28:33 CDT 2017]; parent: Root WebApplicationContext
09:28:33,782 INFO [org.springframework.beans.factory.xml.XmlBeanDefinitionReader] (ServerService Thread Pool -- 71) Loading XML bean definitions from ServletContext resource [/WEB-INF/deServlet-servlet.xml]
09:28:33,850 INFO [org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor] (ServerService Thread Pool -- 71) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
09:28:33,906 INFO [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] (ServerService Thread Pool -- 71) Mapped URL path [/pages/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
09:28:33,930 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 71) Mapped "{[/persons/{name}],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public static com.pier.rest.Person com.pier.rest.PersonRestService.getPerson(java.lang.String)
09:28:33,931 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 71) Mapped "{[/persons],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public static java.util.List<com.pier.rest.Person> com.pier.rest.PersonRestService.getPersons()
09:28:33,931 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 71) Mapped "{[/refresh],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<?> com.pier.security.controller.AuthenticationRestController.refreshAndGetAuthenticationToken(javax.servlet.http.HttpServletRequest)
09:28:33,931 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 71) Mapped "{[/login],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<?> com.pier.security.controller.AuthenticationRestController.authenticateUser(com.pier.security.AuthenticationRequest,org.springframework.mobile.device.Device)
09:28:33,931 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 71) Mapped "{[/protected],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<?> com.pier.security.controller.MethodProtectedRestController.getProtectedGreeting()
09:28:33,932 INFO [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] (ServerService Thread Pool -- 71) Mapped "{[/user],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public com.pier.security.JwtUser com.pier.security.controller.UserRestController.getauthenticatedUser(javax.servlet.http.HttpServletRequest)
09:28:34,289 INFO [org.springframework.security.web.DefaultSecurityFilterChain] (ServerService Thread Pool -- 71) Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@224abc36, org.springframework.security.web.context.SecurityContextPersistenceFilter@2e6245fa, org.springframework.security.web.header.HeaderWriterFilter@c035836, org.springframework.security.web.authentication.logout.LogoutFilter@61005d5d, com.pier.security.filters.JwtAuthenticationTokenFilter@5a54f1f1, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@4589b9ca, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@71ddefb7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@18f8559c, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@e2c6c5d, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@347b117a, org.springframework.security.web.session.SessionManagementFilter@395ad326, org.springframework.security.web.access.ExceptionTranslationFilter@3320a193, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@c13469b]
09:28:34,326 INFO [org.springframework.web.servlet.DispatcherServlet] (ServerService Thread Pool -- 71) FrameworkServlet 'deServlet': initialization completed in 546 ms
09:28:34,327 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 71) WFLYUT0021: Registered web context: /TestPJ-2
09:28:34,372 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0010: Deployed "TestPJ-2.war" (runtime-name : "TestPJ-2.war")
我也在使用maven插件,如果我将通过eclipse的maven插件运行“clean install”时构建的完全相同的战争复制到jboss目录中的“deployments”文件夹,应用程序工作正常,任何想法为何?< / p>
更新:添加了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>TestPJ</groupId>
<artifactId>TestPJ</artifactId>
<build>
<sourceDirectory>C:\Users\PC\workspace\TestPJ\src\main\java</sourceDirectory>
<scriptSourceDirectory>C:\Users\PC\workspace\TestPJ\src\main\scripts</scriptSourceDirectory>
<outputDirectory>C:\Users\PC\workspace\TestPJ\target\classes</outputDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.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>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springsecurity.version>4.0.1.RELEASE</springsecurity.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.2.1.RELEASE</version>
</dependency>
<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>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0-alpha-1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.3.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-expression -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.8.Final</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.7.0</version>
</dependency>
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
<version>1.1.5.RELEASE</version>
</dependency>
</dependencies>
<version>2</version>
<packaging>war</packaging>
</project>
答案 0 :(得分:1)
好的,我会刺伤一下。这听起来好像Eclipse没有创建与Maven相同的WAR文件 - 您的项目的部署程序集配置可能是错误的。
通过检查deploy
目录是否包含不完整的爆炸war文件(WAR格式的未压缩目录)来验证JBoss是否正在部署bum版本。如果您缺少WEB-INF / classes中的类(例如com.pier.rest.PersonRestService
)
如果是(或不管),请验证Eclipse配置:
Source Deploy Path /src/main/java WEB-INF/classes /src/main/resources WEB-INF/classes /src/main/webapp / /target/m2e-wtp/web-resources / Maven Dependencies WEB-INF/lib
我假设您会发现以上内容被搞砸了,因为Eclipse正在使用此配置部署到JBoss。
答案 1 :(得分:0)
我希望有一个更自动化的流程来热部署代码更改,因此我打算使用jboss服务器插件添加项目。 最后一个解决方法是使用maven的jboss插件而不是&#34;添加/删除&#34; Eclipse项目服务器插件中的项目。
<强>的pom.xml:强>
<plugins>
<!-- configure WAR stuff etc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<filteringDeploymentDescriptors>true</filteringDeploymentDescriptors>
<warName>${plugin.war.warName}</warName>
</configuration>
</plugin>
<!-- this is important!! -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- jboss plugin important too!!-->
<plugin>
<groupId>org.jboss.as.plugins</groupId>
<artifactId>jboss-as-maven-plugin</artifactId>
<configuration>
<filename>${artifactId}-${project.version}.ear</filename>
<port>8999</port> <!-- you change it following what you have on your server config -->
<filename>${plugin.war.warName}.${project.packaging}</filename>
</configuration>
</plugin>
</plugins>
然后在运行配置下使用这些参数执行或运行项目:clean install jboss-as:deploy