我在正在进行的一个小项目上遇到错误。我在Wildfly应用服务器上运行了一个EJB项目。此服务器已连接到Oracle数据库。这通过我在Eclipse中实现的Test-Client工作正常。但是,我想通过Webservice提供应用程序。所以我实现了一个WebProject并在通过另一个客户端调用该WebProject时出现以下错误:
Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: WFLYEE0042: Failed to construct component instance Please see the server log to find more detail regarding exact cause of the failure.
at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:116)
at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189)
at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
at com.sun.proxy.$Proxy30.getFacilities(Unknown Source)
at ws.WebServiceClientApp.main(WebServiceClientApp.java:9)
Wildfly应用程序服务器上的错误是:
16:04:59,283 WARNING [org.apache.cxf.phase.PhaseInterceptorChain] (default task-5) Application {http://ws/}FacilityWebserviceService#{http://ws/}getFacilities has thrown exception, unwinding now: org.apache.cxf.interceptor.Fault: WFLYEE0042: Failed to construct component instance
at org.apache.cxf.service.invoker.AbstractInvoker.createFault(AbstractInvoker.java:163)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.createFault(AbstractJAXWSMethodInvoker.java:267)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:129)
at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232)
at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:69)
at org.jboss.wsf.stack.cxf.JBossWSInvoker.invoke(JBossWSInvoker.java:151)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$2.run(ServiceInvokerInterceptor.java:126)
at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:251)
at org.jboss.wsf.stack.cxf.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:111)
at org.jboss.wsf.stack.cxf.transport.ServletHelper.callRequestHandler(ServletHelper.java:136)
at org.jboss.wsf.stack.cxf.CXFServletExt.invoke(CXFServletExt.java:88)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:293)
at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doPost(AbstractHTTPServlet.java:212)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.jboss.wsf.stack.cxf.CXFServletExt.service(CXFServletExt.java:136)
at org.jboss.wsf.spi.deployment.WSFServlet.service(WSFServlet.java:140)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:86)
at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:58)
at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:72)
at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:282)
at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:261)
at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:80)
at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:172)
at io.undertow.server.Connectors.executeRootHandler(Connectors.java:199)
at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:774)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)
at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:88)
at org.jboss.as.webservices.injection.WSComponent.getComponentInstance(WSComponent.java:52)
at org.jboss.as.webservices.deployers.WSComponentInstanceAssociationInterceptor.processInvocation(WSComponentInstanceAssociationInterceptor.java:53)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
at org.wildfly.security.manager.WildFlySecurityManager.doChecked(WildFlySecurityManager.java:634)
at org.jboss.invocation.AccessCheckingInterceptor.processInvocation(AccessCheckingInterceptor.java:61)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:195)
at org.jboss.as.webservices.invocation.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:135)
at org.jboss.wsf.stack.cxf.JBossWSInvoker.performInvocation(JBossWSInvoker.java:185)
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:97)
... 48 more
Caused by: java.lang.IllegalArgumentException: Can not set model.FacilityManagerRemote field ws.FacilityWebservice.facility to com.sun.proxy.$Proxy85
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81)
at java.lang.reflect.Field.set(Field.java:764)
at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:106)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:64)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.InterceptorContext.run(InterceptorContext.java:356)
at org.jboss.invocation.PrivilegedWithCombinerInterceptor.processInvocation(PrivilegedWithCombinerInterceptor.java:80)
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:340)
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61)
at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161)
... 65 more
WebProject中的Web服务是:
package ws;
import java.util.Collection;
import javax.ejb.EJB;
import javax.jws.WebMethod;
import javax.jws.WebService;
import org.jboss.resteasy.logging.Logger;
import model.*;
@WebService
public class FacilityWebservice {
public static final int MILLI_SECONDS = 1000;
public static final String EJBName = "java:global/PIS/FacilityManager!session.FacilityManagerRemote";
private static final Logger log = Logger.getLogger(FacilityWebservice.class);
@EJB(mappedName = EJBName)
private FacilityManagerRemote facility;
@WebMethod
public Collection<Facility> getFacilities() {
log.info("<<<<<<<<<<<<<<<<<<<<<<<-------------getLocations");
log.info("webmethod getLocations called");
return facility.getAllFacilities();
}
}
Wildfly的注册名称:
6:04:29,019 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-2) JNDI bindings for session bean named FacilityManager in deployment unit deployment "PIS.jar" are as follows:
java:global/PIS/FacilityManager!session.FacilityManagerRemote
java:app/PIS/FacilityManager!session.FacilityManagerRemote
java:module/FacilityManager!session.FacilityManagerRemote
java:jboss/exported/PIS/FacilityManager!session.FacilityManagerRemote
java:global/PIS/FacilityManager
java:app/PIS/FacilityManager
java:module/FacilityManager
这是我在WebApplication中的界面
package model;
import java.util.Collection;
import javax.ejb.Remote;
import javax.ejb.Remove;
@Remote
public interface FacilityManagerRemote {
public Collection<Permission> getAllPermissions();
public Collection<Staff> getAllStaff();
public Collection<User> getAllUsers();
public Collection<Sequence> getAllSequences();
public Collection<Facility> getAllFacilities();
public Collection<MachineMasterData> getAllMachines();
public Collection<Productline> getAllProductlines();
public Collection<MachineDayData> getAllMachineDayData();
public Collection<GpsPoint> getAllGpsPoints();
public Collection<Facility> getFacilitiesByPrecedingFacility(Facility precedingFacility);
public Collection<Facility> getHighestTierFacilities();
public Facility getFacilityById(Facility facility);
@Remove
public void remove();
}
这是我在EJB Project中的界面:
package session;
import java.util.Collection;
import javax.ejb.Remote;
import javax.ejb.Remove;
import exceptions.NoSuchRow;
import model.*;
@Remote
public interface FacilityManagerRemote {
public Collection<Permission> getAllPermissions();
public Collection<Staff> getAllStaff();
public Collection<User> getAllUsers();
public Collection<Sequence> getAllSequences();
public Collection<Facility> getAllFacilities();
public Collection<MachineMasterData> getAllMachines();
public Collection<Productline> getAllProductlines();
public Collection<MachineDayData> getAllMachineDayData();
public Collection<GpsPoint> getAllGpsPoints();
public Collection<Facility> getFacilitiesByPrecedingFacility(Facility precedingFacility);
public Collection<Facility> getHighestTierFacilities();
public Facility getFacilityById(Facility facility);
@Remove
public void remove();
}
这是我在EJB项目中的会话Bean:
package session;
import java.util.Collection;
import javax.ejb.EJB;
import javax.ejb.Remote;
import javax.ejb.Stateful;
import exceptions.NoSuchRow;
import model.*;
@Stateful
@Remote(FacilityManagerRemote.class)
public class FacilityManager implements java.io.Serializable {
private static final long serialVersionUID = 4460916846265144595L;
@EJB
private DefaultManager dm;
public FacilityManager() {
}
public Collection<Facility> getHighestTierFacilities(){
return (Collection<Facility>)dm.findByNamedQuery("Facility.findHighestTierFacilities");
}
public Collection<Facility> getFacilitiesByPrecedingFacility(Facility precedingFacility){
return (Collection<Facility>)dm.findByParameter
("Facility.findByPrecedingFacility", "precedingFacility", precedingFacility);
}
public Facility getFacilityById(Facility facility)throws NoSuchRow{
return (Facility)dm.findByPrimaryKey(Facility.class, facility.getFacilityID());
}
//TODO for testing
public Collection<Permission> getAllPermissions() {
return (Collection<Permission>) dm.list(Permission.class);
}
public Collection<Staff> getAllStaff() {
return (Collection<Staff>) dm.list(Staff.class);
}
public Collection<User> getAllUsers() {
return (Collection<User>) dm.list(User.class);
}
public Collection<Sequence> getAllSequences() {
return (Collection<Sequence>) dm.list(Sequence.class);
}
public Collection<MachineMasterData> getAllMachines() {
return (Collection<MachineMasterData>) dm.list(MachineMasterData.class);
}
public Collection<Facility> getAllFacilities() {
return (Collection<Facility>) dm.list(Facility.class);
}
public Collection<Productline> getAllProductlines() {
return (Collection<Productline>) dm.list(Productline.class);
}
public Collection<MachineDayData> getAllMachineDayData() {
return (Collection<MachineDayData>) dm.list(MachineDayData.class);
}
public Collection<GpsPoint> getAllGpsPoints() {
return (Collection<GpsPoint>) dm.list(GpsPoint.class);
}
}
我通过java的wsimport工具包为WebApplicationClient生成了其他类。我似乎无法弄清问题是什么。我已经查过这篇文章: Can not set field to com.sun.proxy.$Proxy 但在我的情况下,FacilityManagerRemote是一个接口,而不是一个类。我不知道如何进一步解决这个问题。有人可以帮忙吗?
答案 0 :(得分:0)