I have a question:
I have a Java class (with Dynamic Web Project) that use the Weka and Jena Libraries. I would like to expose this class as Web Service using Tomcat7 and Axis2. I create the Web Services by right-clicking on the class and selecting the option menu called "Web Service".
When I deploy my Web Service, I get this error:
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:
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.
I had this kind of error recently with 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.
I had a class User that stores some user data and all attributes have their respective getters and setters. This class was then used by a webservice class.
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
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.
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.
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.
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.
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.