如何在websphere liberty 8.5

时间:2016-07-07 19:58:52

标签: java spring jvm websphere websphere-liberty

为什么我收到错误"无法识别的选项:-spring.profiles.active = development"当我尝试使用jvm.options文件启动Websphere时?我按照http://www-01.ibm.com/support/docview.wss?uid=swg21596474中提供的步骤进行操作。

实际上,我想将添加到Eclipse Server View的Websphere Liberty Profile与Tomcat一样。在Tomcat 8中,我刚刚添加了" spring.profiles.active = development"在catalina.properties中,它与我开始使用相同的效果" mvn ... -Dspring.profiles.active = development"。

我将我的问题视为开发人员主题,因为我想知道如何利用@profile启动Websphere Liberty Profile。

请务必了解我使用的是Websphere Liberty,这意味着我没有Websphere管理控制台,因此,如果有人在Websphere管理控制台屏幕中提供了相应的步骤,那么它将毫无价值。

我添加了一个图像,以显示我的Eclipse Server视图是如何以及我添加了仅包含-spring.profiles.active = development的jvm.options文件的位置。

当我尝试使用此类jvm.otions启动服务器时,只会出现错误。如果我把文件拿出来,服务器就会启动,但显然,当我添加我的应用程序时,不会考虑@profile。

完整错误:

Error: Could not create the Java Virtual Machine.

Error: A fatal exception has occurred. Program will exit.

Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0

Unrecognized option: -spring.profiles.active=development

P.S。我不认为这与我的问题有关,顺便说一句,整个申请都可以在https://github.com/jhades/spring-mvc-angularjs-sample-app找到

Eclipse Server view

***编辑1

在我按照建议添加" D"在" - "我可以启动服务器(在Tomcat中它是不同的,因为在Tomcat中你必须避免" D")。顺便说一下,当我将应用程序部署到WAS Liberty时,我根本看不到@profile正在生效。我在整个Websphere日志下面添加了,我没有看到我在Tomcat中经常看到的相同的长日志描述。由于我面临与上下文路径相关的额外错误(请参阅附带的新图片)我无法测试应用程序,除了查看欢迎页面,但我几乎可以肯定@profile因为日志没有被忽略而被忽略了。似乎是考虑到它。

********************************************************************************

product = WebSphere Application Server 8.5.5.9 (wlp-1.0.12.cl50920160227-1523)

wlp.install.dir = C:/Users/my_user/WasWebDownloadedFromEclipse/

java.home = C:\Program Files\Java\jdk1.8.0_65\jre

java.version = 1.8.0_65

java.runtime = Java(TM) SE Runtime Environment (1.8.0_65-b17)

os = Windows 7 (6.1; amd64) (en_US)

process = 6780@GH-VDIKCISV252

********************************************************************************

[7/7/16 16:13:04:151 CDT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           A CWWKE0001I: The server srvFromDefaultLink has been launched.

[7/7/16 16:13:04:175 CDT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           A CWWKE0100I: This product is licensed for development, and limited production use. The full license terms can be viewed here: https://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/license/base_ilan/ilan/8.5.5.9/lafiles/en.html

[7/7/16 16:13:07:531 CDT] 00000001 com.ibm.ws.kernel.launch.internal.FrameworkManager           I CWWKE0002I: The kernel started after 3.998 seconds

[7/7/16 16:13:07:727 CDT] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager            I CWWKF0007I: Feature update started.

[7/7/16 16:13:09:941 CDT] 00000010 com.ibm.ws.security.ready.internal.SecurityReadyServiceImpl  I CWWKS0007I: The security service is starting...

[7/7/16 16:13:11:591 CDT] 00000018 com.ibm.ws.security.token.ltpa.internal.LTPAKeyCreator       I CWWKS4105I: LTPA configuration is ready after 0.406 seconds.

[7/7/16 16:13:12:599 CDT] 00000010 com.ibm.ws.app.manager.internal.monitor.DropinMonitor        A CWWKZ0058I: Monitoring dropins for applications.

[7/7/16 16:13:13:904 CDT] 0000001d com.ibm.ws.tcpchannel.internal.TCPChannel                    I CWWKO0219I: TCP Channel defaultHttpEndpoint has been started and is now listening for requests on host 127.0.0.1  (IPv4: 127.0.0.1) port 8080.

[7/7/16 16:13:17:499 CDT] 00000010 com.ibm.ws.cache.ServerCache                                 I DYNA1001I: WebSphere Dynamic Cache instance named baseCache initialized successfully.

[7/7/16 16:13:17:502 CDT] 00000010 com.ibm.ws.cache.ServerCache                                 I DYNA1071I: The cache provider default is being used.

[7/7/16 16:13:17:503 CDT] 00000010 com.ibm.ws.cache.CacheServiceImpl                            I DYNA1056I: Dynamic Cache (object cache) initialized successfully.

[7/7/16 16:13:19:346 CDT] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0012I: The server installed the following features: [jsp-2.3, ejbLite-3.2, managedBeans-1.0, jsf-2.2, beanValidation-1.1, servlet-3.1, ssl-1.0, jndi-1.0, localConnector-1.0, jsonp-1.0, appSecurity-2.0, jdbc-4.1, jaxrs-2.0, jaxrsClient-2.0, el-3.0, json-1.0, cdi-1.2, distributedMap-1.0, webProfile-7.0, websocket-1.1, jpa-2.1].

[7/7/16 16:13:19:347 CDT] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager            I CWWKF0008I: Feature update completed in 11.807 seconds.

[7/7/16 16:13:19:348 CDT] 00000017 com.ibm.ws.kernel.feature.internal.FeatureManager            A CWWKF0011I: The server srvFromDefaultLink is ready to run a smarter planet.

[7/7/16 16:13:44:452 CDT] 00000017 com.ibm.ws.config.xml.internal.ConfigRefresher               A CWWKG0016I: Starting server configuration update.

[7/7/16 16:13:44:605 CDT] 00000018 com.ibm.ws.app.manager.AppMessageHelper                      W CWWKZ0014W: The application spring-mvc-angularjs-sample-app-master could not be started as it could not be found at location spring-mvc-angularjs-sample-app-master.war.

[7/7/16 16:13:44:606 CDT] 00000017 com.ibm.ws.config.xml.internal.ConfigRefresher               A CWWKG0017I: The server configuration was successfully updated in 0.311 seconds.

[7/7/16 16:13:45:227 CDT] 00000017 com.ibm.ws.app.manager.AppMessageHelper                      I CWWKZ0018I: Starting application spring-mvc-angularjs-sample-app-master.

[7/7/16 16:13:53:746 CDT] 00000017 org.jboss.weld.Version                                       I WELD-000900: SNAPSHOT

[7/7/16 16:14:15:269 CDT] 00000018 com.ibm.ws.app.manager.AppMessageHelper                      A CWWKZ0022W: Application spring-mvc-angularjs-sample-app-master has not started in 30.042 seconds.

[7/7/16 16:14:25:297 CDT] 00000017 com.ibm.ws.webcontainer.osgi.webapp.WebGroup                 I SRVE0169I: Loading Web Module: Archetype Created Web Application.

[7/7/16 16:14:25:302 CDT] 00000017 com.ibm.ws.webcontainer                                      I SRVE0250I: Web Module Archetype Created Web Application has been bound to default_host.

[7/7/16 16:14:25:304 CDT] 00000017 com.ibm.ws.http.internal.VirtualHostImpl                     A CWWKT0016I: Web application available (default_host): http://localhost:8080/calories-tracker/

[7/7/16 16:14:25:309 CDT] 00000017 com.ibm.ws.app.manager.AppMessageHelper                      A CWWKZ0001I: Application spring-mvc-angularjs-sample-app-master started in 40.082 seconds.

[7/7/16 16:16:53:905 CDT] 0000002b com.ibm.ws.session.WASSessionCore                            I SESN8501I: The session manager did not find a persistent storage location; HttpSession objects will be stored in the local application server's memory.

[7/7/16 16:16:53:912 CDT] 0000002b com.ibm.ws.session.WASSessionCore                            I SESN0176I: A new session context will be created for application key default_host/calories-tracker

[7/7/16 16:16:54:017 CDT] 0000002b com.ibm.ws.util                                              I SESN0172I: The session manager is using the Java default SecureRandom implementation for session ID generation.

[7/7/16 16:16:54:089 CDT] 0000002b com.ibm.ws.jsp                                               I JSPG8502I: The value of the JSP attribute jdkSourceLevel is "15".

[7/7/16 16:16:54:483 CDT] 0000002b com.ibm.ws.cache.CacheServiceImpl                            I DYNA1056I: Dynamic Cache (object cache) initialized successfully.

[7/7/16 16:16:55:462 CDT] 0000002b com.ibm.ws.webcontainer.webapp                               I SRVE0292I: Servlet Message - [spring-mvc-angularjs-sample-app-master]:.Spring WebApplicationInitializers detected on classpath: [calories.tracker.config.SecurityWebApplicationInitializer@23cbd857, calories.tracker.config.WebAppInitializer@7c711eb2]

[7/7/16 16:16:55:606 CDT] 0000002b com.ibm.ws.webcontainer.webapp                               I SRVE0292I: Servlet Message - [spring-mvc-angularjs-sample-app-master]:.Initializing Spring root WebApplicationContext

[7/7/16 16:16:55:607 CDT] 0000002b org.springframework.web.context.ContextLoader                I Root WebApplicationContext: initialization started

[7/7/16 16:16:55:678 CDT] 0000002b rk.web.context.support.AnnotationConfigWebApplicationContext I Refreshing Root WebApplicationContext: startup date [Thu Jul 07 16:16:55 CDT 2016]; root of context hierarchy

[7/7/16 16:16:55:708 CDT] 0000002b rk.web.context.support.AnnotationConfigWebApplicationContext I Registering annotated classes: [class calories.tracker.config.root.RootContextConfig,class calories.tracker.config.root.DevelopmentConfiguration,class calories.tracker.config.root.TestConfiguration,class calories.tracker.config.root.AppSecurityConfig]

[7/7/16 16:16:56:578 CDT] 0000002b eans.factory.annotation.AutowiredAnnotationBeanPostProcessor I JSR-330 'javax.inject.Inject' annotation found and supported for autowiring

[7/7/16 16:16:56:838 CDT] 0000002b org.springframework.jdbc.datasource.DriverManagerDataSource  I Loaded JDBC driver: org.postgresql.Driver

[7/7/16 16:16:56:958 CDT] 0000002b ringframework.orm.jpa.LocalContainerEntityManagerFactoryBean I Building JPA container EntityManagerFactory for persistence unit 'default'

[7/7/16 16:17:02:203 CDT] 0000002b org.springframework.security.web.DefaultSecurityFilterChain  I Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher@1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@297728f1, org.springframework.security.web.context.SecurityContextPersistenceFilter@724560fb, org.springframework.security.web.header.HeaderWriterFilter@d397b67, org.springframework.security.web.csrf.CsrfFilter@f62a487, com.allanditzel.springframework.security.web.csrf.CsrfTokenResponseHeaderBindingFilter@10fd6c23, org.springframework.security.web.authentication.logout.LogoutFilter@5ed9a45a, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@625bbf32, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@266bef7, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@343dbd9e, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@6a796e81, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@198ef120, org.springframework.security.web.session.SessionManagementFilter@79951250, org.springframework.security.web.access.ExceptionTranslationFilter@558e68b7, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@639c2328]

[7/7/16 16:17:02:250 CDT] 0000002b org.springframework.web.context.ContextLoader                I Root WebApplicationContext: initialization completed in 6629 ms

[7/7/16 16:17:02:294 CDT] 0000002b com.ibm.ws.webcontainer.webapp                               I SRVE0292I: Servlet Message - [spring-mvc-angularjs-sample-app-master]:.Initializing Spring FrameworkServlet 'dispatcher'

[7/7/16 16:17:02:294 CDT] 0000002b org.springframework.web.servlet.DispatcherServlet            I FrameworkServlet 'dispatcher': initialization started

[7/7/16 16:17:02:321 CDT] 0000002b rk.web.context.support.AnnotationConfigWebApplicationContext I Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu Jul 07 16:17:02 CDT 2016]; parent: Root WebApplicationContext

[7/7/16 16:17:02:329 CDT] 0000002b rk.web.context.support.AnnotationConfigWebApplicationContext I Registering annotated classes: [class calories.tracker.config.servlet.ServletContextConfig]

[7/7/16 16:17:02:541 CDT] 0000002b eans.factory.annotation.AutowiredAnnotationBeanPostProcessor I JSR-330 'javax.inject.Inject' annotation found and supported for autowiring

[7/7/16 16:17:03:584 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/lifecycle],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void calories.tracker.app.controllers.LifeCycleController.createLifeCycle(calories.tracker.app.dto.LifeCycleDTO)

[7/7/16 16:17:03:586 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/meal],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public calories.tracker.app.dto.MealsDTO calories.tracker.app.controllers.MealController.searchMealsByDate(java.security.Principal,java.util.Date,java.util.Date,java.util.Date,java.util.Date,java.lang.Integer)

[7/7/16 16:17:03:587 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/meal],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.util.List<calories.tracker.app.dto.MealDTO> calories.tracker.app.controllers.MealController.saveMeals(java.security.Principal,java.util.List<calories.tracker.app.dto.MealDTO>)

[7/7/16 16:17:03:588 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/meal],methods=[DELETE],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void calories.tracker.app.controllers.MealController.deleteMeals(java.util.List<java.lang.Long>)

[7/7/16 16:17:03:592 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/user],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public calories.tracker.app.dto.UserInfoDTO calories.tracker.app.controllers.UserController.getUserInfo(java.security.Principal)

[7/7/16 16:17:03:593 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/user],methods=[PUT],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void calories.tracker.app.controllers.UserController.updateUserMaxCaloriesPerDay(java.security.Principal,java.lang.Long)

[7/7/16 16:17:03:597 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerMapping I Mapped "{[/user],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void calories.tracker.app.controllers.UserController.createUser(calories.tracker.app.dto.NewUserDTO)

[7/7/16 16:17:03:656 CDT] 0000002b .springframework.web.servlet.handler.SimpleUrlHandlerMapping I Mapped URL path [/resources/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

[7/7/16 16:17:03:953 CDT] 0000002b b.servlet.mvc.method.annotation.RequestMappingHandlerAdapter I Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu Jul 07 16:17:02 CDT 2016]; parent: Root WebApplicationContext

[7/7/16 16:17:04:235 CDT] 0000002b org.springframework.web.servlet.DispatcherServlet            I FrameworkServlet 'dispatcher': initialization completed in 1940 ms

[7/7/16 16:17:04:235 CDT] 0000002b com.ibm.ws.webcontainer.servlet                              I SRVE0242I: [spring-mvc-angularjs-sample-app-master] [/calories-tracker] [dispatcher]: Initialization successful.

个人资料(&#34;开发&#34;)可能会被忽略

@Configuration
@Profile("development")
@EnableTransactionManagement
public class DevelopmentConfiguration {
    @Bean(name = "datasource")
    public DriverManagerDataSource dataSource() {
...
    @Bean(name = "entityManagerFactory")
    public LocalContainerEntityManagerFactoryBean entityManagerFactory(DriverManagerDataSource dataSource) 
...

This is an error with context path blocking me to test the application

2 个答案:

答案 0 :(得分:2)

  • 通过命令行传递给java的JVM参数应该以-D

    开头
    -Dspring.profiles.active=development
    
  • 通过jvm.options传递的JVM参数应以-D

  • 开头
  • 通过catalina.properties传递的JVM参数不需要以-D

    为前缀

答案 1 :(得分:0)

如果您使用2016.10.0.0/wlp-1.0.15.20161014-2058以下版本配置工作 将您的jvm.options文件放在您自由的共享文件夹下并提供 -Dspring.profiles.active =开发并重新启动服务器。

如果您使用16.0.0.x,则应将jvm.options文件放在服务器下 - &gt; defaultserver - &gt; jvm.options。

请参阅以下链接以获取更多信息 http://www.ibm.com/support/knowledgecenter/en/SS7K4U_liberty/com.ibm.websphere.wlp.zseries.doc/ae/rwlp_dirs.html