[英]Error when I deploy Web Service using Axis2
I have a question: 我有个问题:
I have a Java class (with Dynamic Web Project) that use the Weka and Jena Libraries. 我有一个使用Weka和Jena库的Java类(带有Dynamic Web Project)。 I would like to expose this class as Web Service using Tomcat7 and Axis2.
我想使用Tomcat7和Axis2将此类作为Web服务公开。 I create the Web Services by right-clicking on the class and selecting the option menu called "Web Service".
我通过右键单击该类并选择称为“ Web Service”的选项菜单来创建Web Services。
When I deploy my Web Service, I get this error: 部署Web服务时,出现以下错误:
org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: null
at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:432)
at org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:101)
at org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:178)
at org.apache.axis2.deployment.ServiceDeployer.deploy(ServiceDeployer.java:82)
at org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136)
at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:813)
at org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144)
at org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377)
at org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254)
at org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:142)
at org.apache.axis2.deployment.WarBasedAxisConfigurator.loadServices(WarBasedAxisConfigurator.java:283)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:95)
at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:584)
at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:454)
at org.apache.axis2.webapp.AxisAdminServlet.init(AxisAdminServlet.java:60)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4935)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5262)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5257)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: null
at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:396)
... 24 more
Caused by: java.lang.NullPointerException
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.generateSchema(DefaultSchemaGenerator.java:606)
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.generateSchemaTypeforNameCommon(DefaultSchemaGenerator.java:1092)
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.generateSchemaForType(DefaultSchemaGenerator.java:996)
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.processMethods(DefaultSchemaGenerator.java:413)
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.generateSchema(DefaultSchemaGenerator.java:273)
at org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:468)
at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:388)
... 24 more
[ERROR] The Prova service, which is not valid, caused The following error occurred during schema generation: null
org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: null
at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:432)
at org.apache.axis2.deployment.repository.util.ArchiveReader.buildServiceGroup(ArchiveReader.java:101)
at org.apache.axis2.deployment.repository.util.ArchiveReader.processServiceGroup(ArchiveReader.java:178)
at org.apache.axis2.deployment.ServiceDeployer.deploy(ServiceDeployer.java:82)
at org.apache.axis2.deployment.repository.util.DeploymentFileData.deploy(DeploymentFileData.java:136)
at org.apache.axis2.deployment.DeploymentEngine.doDeploy(DeploymentEngine.java:813)
at org.apache.axis2.deployment.repository.util.WSInfoList.update(WSInfoList.java:144)
at org.apache.axis2.deployment.RepositoryListener.update(RepositoryListener.java:377)
at org.apache.axis2.deployment.RepositoryListener.checkServices(RepositoryListener.java:254)
at org.apache.axis2.deployment.DeploymentEngine.loadServices(DeploymentEngine.java:142)
at org.apache.axis2.deployment.WarBasedAxisConfigurator.loadServices(WarBasedAxisConfigurator.java:283)
at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:95)
at org.apache.axis2.transport.http.AxisServlet.initConfigContext(AxisServlet.java:584)
at org.apache.axis2.transport.http.AxisServlet.init(AxisServlet.java:454)
at org.apache.axis2.webapp.AxisAdminServlet.init(AxisAdminServlet.java:60)
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1189)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1103)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1010)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4935)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5262)
at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5257)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: null
at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:396)
... 24 more
Caused by: java.lang.NullPointerException
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.generateSchema(DefaultSchemaGenerator.java:606)
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.generateSchemaTypeforNameCommon(DefaultSchemaGenerator.java:1092)
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.generateSchemaForType(DefaultSchemaGenerator.java:996)
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.processMethods(DefaultSchemaGenerator.java:413)
at org.apache.axis2.description.java2wsdl.DefaultSchemaGenerator.generateSchema(DefaultSchemaGenerator.java:273)
at org.apache.axis2.deployment.util.Utils.fillAxisService(Utils.java:468)
at org.apache.axis2.deployment.ServiceBuilder.populateService(ServiceBuilder.java:388)
... 24 more
[INFO] org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: null
[INFO] Deploying Web service: version.aar - file:/C:/apache-tomcat-8.0.1-src/wtpwebapps/ProvaListMap/WEB-INF/services/version.aar
[WARN] No transportReceiver for org.apache.axis2.transport.http.AxisServletListener found. An instance for HTTP will be configured automatically. Please update your axis2.xml file!
I have seen that I get this error when I add this method which use Weka Libs: 我看到添加使用Weka Libs的方法时出现此错误:
public Instances Prova(SortedMap<String,String> map) throws Exception {
@SuppressWarnings("rawtypes")
Iterator it = map.entrySet().iterator();
int riga=0;
int colonna=0;
String[][] data = new String[map.size()][map.size()];
while (it.hasNext()) {
@SuppressWarnings("rawtypes")
Map.Entry entry = (Map.Entry)it.next();
data [riga][colonna]=entry.getKey().toString();
data [riga][colonna+1]=entry.getValue().toString();
riga=riga+1;
}
int numInstances = data[0].length;
//ArrayList<Attribute> atts = new ArrayList<Attribute>();
FastVector atts = new FastVector();
List<Instance> instances = new ArrayList<Instance>();
for(int dim = 0; dim < 2; dim++)
{
Attribute current = new Attribute("Attribute" + dim, (FastVector) null, dim);
if(dim == 0)
{
for(int obj = 0; obj < numInstances; obj++)
{
instances.add(new SparseInstance(2));
}
}
for(int obj = 0; obj < numInstances; obj++)
{
instances.get(obj).setValue(current, data[obj][dim]);
}
atts.addElement(current);
}
Instances newDataset = new Instances("Dataset", atts, instances.size());
for(Instance inst : instances){
newDataset.add(inst);
}
return newDataset;
}
Why do I get this error? 为什么会出现此错误? In Java, I do not have this error.
在Java中,我没有此错误。
I had this kind of error recently with axis2 + TomCat 7. 我最近在axis2 + TomCat 7中遇到了此类错误。
I was lost and I had no idea were the problem came from because I had all the right configurations. 我迷路了,我不知道问题出在哪里,因为我拥有所有正确的配置。
Than I was able to detect the problem. 比我能够发现问题。 The problem was from a method name that I was using on a non-webservice class.
问题出在我在非Webservice类上使用的方法名称。
I had a class User that stores some user data and all attributes have their respective getters and setters. 我有一个User类,它存储一些用户数据,并且所有属性都有各自的getter和setter。 This class was then used by a webservice class.
然后,此类由Webservice类使用。
This was the method that was causing the exception: 这是导致异常的方法:
public class User {
...
private boolean mIsYahoo;
...
public void setIsYahoo(boolean isYahoo) {
mIsYahoo = isYahoo;
}
...
}
org.apache.axis2.deployment.DeploymentException: The following error occurred during schema generation: null
org.apache.axis2.deployment.DeploymentException:模式生成期间发生以下错误:null
The problem was fixed by just changing the method name: 只需更改方法名称即可解决此问题:
public void setYahoo(boolean isYahoo) {
mIsYahoo = isYahoo;
}
I was able to find this like so: 我可以这样找到:
I erased all the methods from the WebService and check that it was successfully deployed. 我从WebService删除了所有方法,并检查它是否已成功部署。
Then I started to re-insert the WebMethods one by one and redeploy each time until I found that this exception was caused when I inserted a WebMethod that had a User object as parameter. 然后,我开始一个接一个地重新插入WebMethod,并每次重新部署,直到发现该异常是由插入以User对象作为参数的WebMethod引起的。
I erased all methods from the User class and redeployed the WebService with all the WebMethods included the one that used a User object and checked that was successful deployed. 我从User类中删除了所有方法,并重新部署了WebService,其中所有WebMethods都包括使用User对象并检查是否已成功部署的方法。
Then I started to re-insert the User methods one by one and redeploying the WebService until I found that this exception was caused by the above mention method. 然后,我开始一个接一个地重新插入User方法并重新部署WebService,直到发现该异常是由上述方法引起的。
I changed the name of the method assuming some name resolution conflits. 假设某些名称解析受到限制,我更改了方法的名称。 And it worked !!!
它的工作!
I hope this information could be helpful for future people that could face this problem because I spent one entire night stuck on this. 我希望这些信息对将来可能会遇到此问题的人们有所帮助,因为我整夜都坚持了这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.