Glassfish 4.0服务器在尝试部署以下代码时出错:
错误讯息: 无法部署部署失败=部署期间出错:准备应用程序时出现异常。有关更多详细信息,请参阅server.log。
代码:
import java.util.ArrayList;
import java.util.List;
import javax.jws.WebService;
@WebService
public class ProductCatalog
{
public List<String> getProductCategories()
{
List<String> l=new ArrayList<String>();
l.add("Books");
l.add("Music");
l.add("Movies");
return l;
}
}
服务器日志:
2017-02-12T14:33:47.252-0500|Info: Running GlassFish Version: GlassFish Server Open Source Edition 4.1.1 (build 1)
2017-02-12T14:33:47.260-0500|Info: Server log file is using Formatter class: com.sun.enterprise.server.logging.ODLLogFormatter
2017-02-12T14:33:47.589-0500|Info: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2017-02-12T14:33:47.593-0500|Info: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
2017-02-12T14:33:47.599-0500|Info: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
2017-02-12T14:33:48.153-0500|Info: Authorization Service has successfully initialized.
2017-02-12T14:33:48.690-0500|Info: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
2017-02-12T14:33:49.160-0500|Warning: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-1, realClassName=org.glassfish.grizzly.http2.Http2AddOn
2017-02-12T14:33:49.343-0500|Info: Grizzly Framework 2.3.23 started in: 99ms - bound to [/0.0.0.0:8080]
2017-02-12T14:33:49.427-0500|Warning: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=http-listener-2, realClassName=org.glassfish.grizzly.http2.Http2AddOn
2017-02-12T14:33:49.443-0500|Info: Grizzly Framework 2.3.23 started in: 2ms - bound to [/0.0.0.0:8181]
2017-02-12T14:33:49.455-0500|Warning: Instance could not be initialized. Class=interface org.glassfish.grizzly.http.server.AddOn, name=admin-listener, realClassName=org.glassfish.grizzly.http2.Http2AddOn
2017-02-12T14:33:49.469-0500|Info: Grizzly Framework 2.3.23 started in: 3ms - bound to [/0.0.0.0:4848]
2017-02-12T14:33:49.555-0500|Info: Grizzly Framework 2.3.23 started in: 0ms - bound to [/0.0.0.0:3700]
2017-02-12T14:33:49.557-0500|Info: GlassFish Server Open Source Edition 4.1.1 (1) startup time : Felix (32,719ms), startup services(2,755ms), total(35,474ms)
2017-02-12T14:33:53.625-0500|Info: HV000001: Hibernate Validator 5.1.2.Final
2017-02-12T14:33:55.102-0500|Info: JTS5014: Recoverable JTS instance, serverId = [100]
2017-02-12T14:34:00.227-0500|Info: Grizzly Framework 2.3.23 started in: 6ms - bound to [/0.0.0.0:7676]
2017-02-12T14:34:00.231-0500|Info: Registered com.sun.enterprise.glassfish.bootstrap.osgi.EmbeddedOSGiGlassFishImpl@1d25c1c as OSGi service registration: org.apache.felix.framework.ServiceRegistrationImpl@5fad41be.
2017-02-12T14:34:02.581-0500|Info: visiting unvisited references
2017-02-12T14:34:03.207-0500|Info: Web service endpoint deployment events listener registered successfully.
2017-02-12T14:34:03.533-0500|Info: Java security manager is disabled.
2017-02-12T14:34:03.535-0500|Info: Entering Security Startup Service.
2017-02-12T14:34:03.553-0500|Info: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
2017-02-12T14:34:03.679-0500|Info: Security Service(s) started successfully.
2017-02-12T14:34:04.249-0500|Info: Created HTTP listener http-listener-1 on host/port 0.0.0.0:8080
2017-02-12T14:34:04.261-0500|Info: Created HTTP listener http-listener-2 on host/port 0.0.0.0:8181
2017-02-12T14:34:04.266-0500|Info: Created HTTP listener admin-listener on host/port 0.0.0.0:4848
2017-02-12T14:34:04.317-0500|Info: Created virtual server server
2017-02-12T14:34:04.320-0500|Info: Created virtual server __asadmin
2017-02-12T14:34:04.795-0500|Info: Setting JAAS app name glassfish-web
2017-02-12T14:34:04.796-0500|Info: Virtual server server loaded default web module
2017-02-12T14:34:10.237-0500|Info: JMXStartupService has started JMXConnector on JMXService URL service:jmx:rmi://192.168.1.7:8686/jndi/rmi://192.168.1.7:8686/jmxrmi
2017-02-12T14:34:15.253-0500|Info: visiting unvisited references
2017-02-12T14:34:15.334-0500|Severe: WS00029: The javax.jws.WebService annotation targetNamespace must be used for classes or interfaces that are in no package.
2017-02-12T14:34:15.338-0500|Severe: Annotations processing failed for file:/Users/rohitaila/Downloads/glassfish4/glassfish/domains/domain1/eclipseApps/Testmart1/
2017-02-12T14:34:15.342-0500|Info: visiting unvisited references
2017-02-12T14:34:35.580-0500|Info: Webservice Endpoint deployed ProductCatalog
listening at address at http://Rohits-MacBook-Pro.local:8080/Testmart1/ProductCatalogService.
2017-02-12T14:34:35.583-0500|Severe: Exception while invoking class org.glassfish.webservices.WebServicesDeployer prepare method
2017-02-12T14:34:35.585-0500|Severe: java.lang.RuntimeException
at org.glassfish.webservices.WebServicesDeployer.prepare(WebServicesDeployer.java:185)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.glassfish.webservices.deployment.DeployedEndpointData.<init>(DeployedEndpointData.java:118)
at org.glassfish.webservices.deployment.WebServicesDeploymentMBean.deploy(WebServicesDeploymentMBean.java:272)
at org.glassfish.webservices.deployment.WebServicesDeploymentMBean.deploy(WebServicesDeploymentMBean.java:301)
at org.glassfish.webservices.WebServicesDeployer.prepare(WebServicesDeployer.java:182)
... 40 more
2017-02-12T14:34:35.587-0500|Severe: Exception while preparing the app
2017-02-12T14:34:35.588-0500|Severe: Exception during lifecycle processing
java.lang.RuntimeException
at org.glassfish.webservices.WebServicesDeployer.prepare(WebServicesDeployer.java:185)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at org.glassfish.webservices.deployment.DeployedEndpointData.<init>(DeployedEndpointData.java:118)
at org.glassfish.webservices.deployment.WebServicesDeploymentMBean.deploy(WebServicesDeploymentMBean.java:272)
at org.glassfish.webservices.deployment.WebServicesDeploymentMBean.deploy(WebServicesDeploymentMBean.java:301)
at org.glassfish.webservices.WebServicesDeployer.prepare(WebServicesDeployer.java:182)
... 40 more
答案 0 :(得分:0)
仔细查看日志文件中的此异常:
2017-02-12T14:34:15.334-0500 |严重:WS00029:javax.jws.WebService 注释targetNamespace必须用于那些类或接口 没有包裹。
根据这一点,您需要创建一个包并在其中包含服务ProductCatalog
或在targetNamespace
注释中指定@WebService
。
请参阅documentation