gpt4 book ai didi

java - 如何修复 javax.xml.ws.WebServiceException : java. lang.NullPointerException?

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:07:45 33 4
gpt4 key购买 nike

我正在运行 Spring Boot 应用程序 (mvn:spring-boot:run) 并获取下一个堆栈跟踪:

 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.2.RELEASE)

2016-02-10 09:57:31.350 INFO 8868 --- [ main] com.comp.config.Application : Starting Application on SOFT12 with PID 8868 (C:\Users\Maya\git\app-services\target\classes started by Maya in C:\Users\Maya\git\app-services)
2016-02-10 09:57:31.356 INFO 8868 --- [ main] com.comp.config.Application : No active profile set, falling back to default profiles: default
2016-02-10 09:57:31.429 INFO 8868 --- [ main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@7dd7f653: startup date [Wed Feb 10 09:57:31 MSK 2016]; root of context hierarchy
2016-02-10 09:57:33.174 INFO 8868 --- [ main] o.s.b.f.s.DefaultListableBeanFactory : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2016-02-10 09:57:35.126 INFO 8868 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2016-02-10 09:57:35.151 INFO 8868 --- [ main] o.apache.catalina.core.StandardService : Starting service Tomcat
2016-02-10 09:57:35.153 INFO 8868 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet Engine: Apache Tomcat/8.0.30
2016-02-10 09:57:35.296 INFO 8868 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2016-02-10 09:57:35.296 INFO 8868 --- [ost-startStop-1] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 3871 ms
2016-02-10 09:57:36.401 INFO 8868 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean : Mapping servlet: 'CXFServlet' to [/APPservice/*]
2016-02-10 09:57:36.408 INFO 8868 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'metricFilter' to: [/*]
2016-02-10 09:57:36.409 INFO 8868 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'characterEncodingFilter' to: [/*]
2016-02-10 09:57:36.409 INFO 8868 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2016-02-10 09:57:36.409 INFO 8868 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2016-02-10 09:57:36.410 INFO 8868 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'requestContextFilter' to: [/*]
2016-02-10 09:57:36.410 INFO 8868 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'webRequestLoggingFilter' to: [/*]
2016-02-10 09:57:36.410 INFO 8868 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'applicationContextIdFilter' to: [/*]
2016-02-10 09:57:37.028 INFO 8868 --- [ main] o.a.c.w.s.f.ReflectionServiceFactoryBean : Creating Service {http://new.webservice.namespace}CompServiceForPCO from WSDL: classpath:CompService.wsdl
2016-02-10 09:57:39.665 WARN 8868 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ws' defined in com.comp.config.Application: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.xml.ws.Endpoint]: Factory method 'ws' threw exception; nested exception is javax.xml.ws.WebServiceException: java.lang.NullPointerException
2016-02-10 09:57:39.676 INFO 8868 --- [ main] o.apache.catalina.core.StandardService : Stopping service Tomcat
2016-02-10 09:57:39.891 ERROR 8868 --- [ main] o.s.boot.SpringApplication : Application startup failed

ws 方法在 Application.class 中,如下所示:

package com.comp.config;

import org.apache.cxf.Bus;
import org.apache.cxf.bus.spring.SpringBus;
import org.apache.cxf.interceptor.LoggingInInterceptor;
import org.apache.cxf.interceptor.LoggingOutInterceptor;
import org.apache.cxf.jaxws.EndpointImpl;
import org.apache.cxf.transport.servlet.CXFServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.ServletRegistrationBean;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import com.comp.pcoserv.CompServiceEndPoindImpl;

import javax.xml.ws.Endpoint;


@Configuration
@EnableAutoConfiguration
public class Application {

public static final String SERVLET_MAPPING_URL_PATH = "/APPservice";
public static final String SERVICE_NAME_URL_PATH = "/ws";

@Autowired
private ApplicationContext applicationContext;

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

@Bean
public ServletRegistrationBean dispatcherServlet() {
return new ServletRegistrationBean(new CXFServlet(), SERVLET_MAPPING_URL_PATH + "/*");
}


@Bean(name = Bus.DEFAULT_BUS_ID)
/* <bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus">*/
public SpringBus springBus() {
return new SpringBus();
}

@Bean
/* <jaxws:endpoint id="app" implementor="com.dlizarra.app.ws.AppImpl" address="/app">*/
public Endpoint ws() {
//Bus bus = (Bus) applicationContext.getBean(Bus.DEFAULT_BUS_ID);


Object implementor = new CompServiceEndPoindImpl();
EndpointImpl endpoint = new EndpointImpl(springBus(), implementor);
endpoint.publish(SERVICE_NAME_URL_PATH);
endpoint.setWsdlLocation("CompService.wsdl");
/*endpoint.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
endpoint.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());*/
return endpoint;
}

}

我搜索了整个 Internet 以找到解决方案,但没有成功。你能帮我解决这个异常吗?

完整的堆栈跟踪在这里:full stack trace

最佳答案

当您的服务返回的对象没有空构造函数时,可能会发生此错误。

只需确保您所有的 dto 都是空构造函数。

关于java - 如何修复 javax.xml.ws.WebServiceException : java. lang.NullPointerException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35309022/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com