2016-09-15 28 views
0

我有一個Maven企業應用程序項目,我正在業餘時間工作。目前,我想切換到HTTPS,但我得到的只是頭痛。Netbeans在運行EAR時打開http而不是https

所以:我在Windows 10 Pro x64上使用NetBeans 8.1和GlassFish 4.1.1。清理,構建和運行應用程序會導致在Firefox中打開http://localhost:8181/MyApp而不是HTTPS。 我已經禁用了GF管理控制檯中的不安全的HTTP偵聽器(加載帶有端口8181的URL表明它有效),但除此之外。 cuplrit是什麼?我忘了什麼嗎?編輯:這似乎是一個GlassFish 4.1.1問題(在Windows 7 x64上用Netbeans 8.0.2和GF 4.1快速測試;也是NetBeans 8.1和GF 4.1)。看起來HTTPS聽衆無法及時啓動(標有!!!)。有沒有已知的解決方案或解決方法?

EDIT2:重新啓用不安全的HTTP偵聽器「修復」問題(加載http://localhost:8080/MyApp並重定向到http**s**://localhost:8181/MyApp)。

這是服務器日誌時將NetBeans中運行的EAR:

Launching GlassFish on Felix platform 
Sep 21, 2016 3:56:05 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner createBundleProvisioner 
INFORMATION: Create bundle provisioner class = class com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner. 
Sep 21, 2016 3:56:05 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations 
WARNUNG: Skipping entry because it is not an absolute URI. 
Sep 21, 2016 3:56:05 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner$DefaultCustomizer getLocations 
WARNUNG: Skipping entry because it is not an absolute URI. 
Sep 21, 2016 3:56:06 PM com.sun.enterprise.glassfish.bootstrap.osgi.BundleProvisioner startBundles 
WARNUNG: Can not start bundle file:/C:/Program%20Files/glassfish-4.1.1/glassfish/modules/core.jar because it is not contained in the list of installed bundles. 
Registered com.sun.e[email protected]3f6b4900 in service registry. 
#!## LogManagerService.postConstruct : rootFolder=C:\Program Files\glassfish-4.1.1\glassfish 
#!## LogManagerService.postConstruct : templateDir=C:\Program Files\glassfish-4.1.1\glassfish\lib\templates 
#!## LogManagerService.postConstruct : src=C:\Program Files\glassfish-4.1.1\glassfish\lib\templates\logging.properties 
#!## LogManagerService.postConstruct : dest=C:\Users\Tobias\AppData\Roaming\NetBeans\8.1\config\GF_4.1.1\domain1\config\logging.properties 
Information: Running GlassFish Version: GlassFish Server Open Source Edition 4.1.1 (build 1) 
Information: Server log file is using Formatter class: com.sun.enterprise.server.logging.ODLLogFormatter 
Information: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created. 
Information: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created. 
Information: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created. 
Information: Network listener http-listener-1 on port 8080 disabled per domain.xml 
Information: Authorization Service has successfully initialized. 
Information: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry 
Information: JTS5014: Recoverable JTS instance, serverId = [100] 
Schwerwiegend: Application previously deployed is not at its original location any more: file:/E:/Work/Projects/Java/XWars/XWars-ear/target/gfdeploy/XWars-ear/ 
! ! ! Warnung: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-2, realClassName=org.glassfish.grizzly.http2.Http2AddOn 
Information: Grizzly Framework 2.3.23 started in: 20ms - bound to [/0.0.0.0:8181] 
Warnung: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=admin-listener, realClassName=org.glassfish.grizzly.http2.Http2AddOn 
Information: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:4848] 
Information: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:3700] 
Information: GlassFish Server Open Source Edition 4.1.1 (1) startup time : Felix (10.819ms), startup services(1.002ms), total(11.821ms) 
Information: Grizzly Framework 2.3.23 started in: 1ms - bound to [/0.0.0.0:7676] 
Information: Registered com.su[email protected]32b9bd12 as OSGi service registration: [email protected] 
Information: JMXStartupService has started JMXConnector on JMXService URL service:jmx:rmi://Tobias-PC.fritz.box:8686/jndi/rmi://Tobias-PC.fritz.box:8686/jmxrmi 
Information: HV000001: Hibernate Validator 5.1.2.Final 
! ! ! Warnung: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-2, realClassName=org.glassfish.grizzly.http2.Http2AddOn 
Information: Grizzly Framework 2.3.23 started in: 15ms - bound to [/0.0.0.0:8181] 
Warnung: Originally deployed application at E:\Work\Projects\Java\XWars\XWars-ear\target\gfdeploy\XWars-ear not found 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: visiting unvisited references 
Information: Java security manager is disabled. 
Information: Entering Security Startup Service. 
Information: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper. 
Information: Security Service(s) started successfully. 
Information: de.dnhax.xwars.persistence.entities.Player actually got transformed 
Information: EclipseLink, version: Eclipse Persistence Services - 2.6.3.v20160428-59c81c5 
Information: /file:/E:/Work/Projects/Java/XWars/XWars-ear/target/gfdeploy/XWars-ear/XWars-ejb-1.0.0-SNAPSHOT_jar/_XWarsPU login successful 
! ! ! Information: Created HTTP listener http-listener-2 on host/port 0.0.0.0:8181 
Information: Created HTTP listener admin-listener on host/port 0.0.0.0:4848 
Information: Created virtual server server 
Information: Created virtual server __asadmin 
Information: Setting JAAS app name glassfish-web 
Information: Virtual server server loaded default web module 
Information: JTS5014: Recoverable JTS instance, serverId = [3700] 
Information: Portable JNDI names for EJB XWarsLogicImpl: [java:global/XWars-ear/XWars-ejb-1.0.0-SNAPSHOT/XWarsLogicImpl!de.dnhax.xwars.logic.XWarsLogic, java:global/XWars-ear/XWars-ejb-1.0.0-SNAPSHOT/XWarsLogicImpl] 
Information: Glassfish-specific (Non-portable) JNDI names for EJB XWarsLogicImpl: [de.dnhax.xwars.logic.XWarsLogic#de.dnhax.xwars.logic.XWarsLogic, de.dnhax.xwars.logic.XWarsLogic] 
Information: Portable JNDI names for EJB PlayerAccess: [java:global/XWars-ear/XWars-ejb-1.0.0-SNAPSHOT/PlayerAccess, java:global/XWars-ear/XWars-ejb-1.0.0-SNAPSHOT/PlayerAccess!de.dnhax.xwars.persistence.PlayerAccess] 
Information: WELD-000900: 2.2.13 (Final) 
WARN: WELD-001700: Interceptor annotation class javax.ejb.PostActivate not found, interception based on it is not enabled 
WARN: WELD-001700: Interceptor annotation class javax.ejb.PrePassivate not found, interception based on it is not enabled 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] org.glassfish.sse.impl.ServerSentEventCdiExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>, BeanManager) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] public org.glassfish.jms.injection.JMSCDIExtension.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
WARN: WELD-000411: Observer method [BackedAnnotatedMethod] private org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.processAnnotatedType(@Observes ProcessAnnotatedType<Object>) receives events for all annotated types. Consider restricting events using @WithAnnotations or a generic type with bounds. 
Information: Mojarra 2.2.12 (20150720-0848 https://svn.java.net/svn/mojarra~svn/tags/[email protected]) für Kontext '/xwars' wird initialisiert. 
Information: RewritePhaseListener starting up. 
Information: Monitoring jndi:/server/xwars/WEB-INF/faces-config.xml for modifications 
Information: Running on PrimeFaces 6.0 
Information: RewriteFilter starting up... 
Information: Loaded [4] org.ocpsoft.rewrite.servlet.spi.RewriteLifecycleListener [org.ocpsoft.rewrite.prettyfaces.PrettyFacesRewriteLifecycleListener<-100>, org.ocpsoft.rewrite.faces.FacesRewriteLifecycleListener<0>, org.ocpsoft.rewrite.servlet.impl.DefaultRewriteLifecycleListener<2147483647>, org.ocpsoft.rewrite.servlet.config.lifecycle.JoinRewriteLifecycleListener<2147483647>] 
Information: Loaded [1] org.ocpsoft.rewrite.servlet.spi.RequestCycleWrapper [org.ocpsoft.rewrite.servlet.impl.HttpRewriteRequestCycleWrapper<0>] 
Information: Loaded [1] org.ocpsoft.rewrite.spi.RewriteProvider [org.ocpsoft.rewrite.servlet.impl.DefaultHttpRewriteProvider<0>] 
Information: Loaded [1] org.ocpsoft.rewrite.servlet.spi.RewriteResultHandler [org.ocpsoft.rewrite.servlet.impl.HttpRewriteResultHandler<0>] 
Information: Loaded [1] org.ocpsoft.rewrite.servlet.spi.InboundRewriteProducer [org.ocpsoft.rewrite.servlet.impl.HttpInboundRewriteProducer<0>] 
Information: Loaded [1] org.ocpsoft.rewrite.servlet.spi.OutboundRewriteProducer [org.ocpsoft.rewrite.servlet.impl.HttpOutboundRewriteProducer<0>] 
Information: Loaded [1] org.ocpsoft.rewrite.servlet.spi.ContextListener [org.ocpsoft.rewrite.prettyfaces.PrettyConfigContextListener<0>] 
Information: Loaded [0] org.ocpsoft.rewrite.servlet.spi.RequestListener [] 
Information: Loaded [1] org.ocpsoft.rewrite.servlet.spi.RequestParameterProvider [org.ocpsoft.rewrite.prettyfaces.PrettyFacesRequestParameterProvider<0>] 
Information: Loaded [1] org.ocpsoft.rewrite.el.spi.ExpressionLanguageProvider [org.ocpsoft.rewrite.faces.FacesExpressionLanguageProvider<30>] 
Information: Loaded [1] org.ocpsoft.rewrite.spi.InvocationResultHandler [org.ocpsoft.rewrite.faces.NavigatingInvocationResultHandler<100>] 
Information: Loaded [0] org.ocpsoft.common.spi.ServiceEnricher [] 
Information: Loaded [1] org.ocpsoft.rewrite.spi.ConfigurationCacheProvider [org.ocpsoft.rewrite.servlet.impl.ServletContextConfigurationCacheProvider<0>] 
Information: Loaded [2] org.ocpsoft.rewrite.config.ConfigurationProvider [org.ocpsoft.rewrite.annotation.config.AnnotationConfigProvider<100>, org.ocpsoft.rewrite.prettyfaces.PrettyFacesRewriteConfigurationProvider<1>] 
Information: Loaded [0] org.ocpsoft.rewrite.spi.RuleCacheProvider [] 
Information: Loaded [1] org.ocpsoft.rewrite.spi.GlobalParameterProvider [org.ocpsoft.rewrite.instance.WildcardParameterProvider<0>] 
Information: Rewrite 3.4.1.Final initialized. 
Information: Loading application [XWars-ear#XWars-web-1.0.0-SNAPSHOT.war] at [/xwars] 
Information: XWars-ear was successfully deployed in 10.439 milliseconds. 

回答

0

確保您已經按照你的web.xml條目:

<web-app> 
    <security-constraint> 
     <web-resource-collection> 
     <web-resource-name>Enforce HTTPS for all urls</web-resource-name> 
     <url-pattern>/*</url-pattern> 
     </web-resource-collection> 
     <user-data-constraint> 
     <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
     </user-data-constraint> 
    </security-constraint> 
</web-app> 

來源:https://docs.oracle.com/javaee/5/tutorial/doc/bnbxw.html

+0

我有。經過進一步調查,這似乎是一個NetBeans問題(如[這裏](https://github.com/payara/Payara/issues/1108)所述))。報告錯誤[這裏](https://netbeans.org/bugzilla/show_bug.cgi?id=268195)。 – dNhax