RapidMiner

InvocationTargetException due to RapidMiner.init()

Contributor II

InvocationTargetException due to RapidMiner.init()

Hi everyone,
I'm trying to test Rapidminer as a web service, but first I created a simple class in order to test the code as an standalone application. The class, named RMin_prova, has the following method:

public void prova() {
        try {
            IOContainer ioInput = null;
            RapidMiner.setExecutionMode(RapidMiner.ExecutionMode.COMMAND_LINE);
            RapidMiner.init();

            Process pr = new Process(new File(nomFitxerDades));
            Operator op = pr.getOperator("Read Excel");
            op.setParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE,"C:\\Users\\Serpc\\Desktop\\Dades\\BD_FINAL1.xls");     
            ioResult = pr.run(ioInput);
           
        } catch (IOException | XMLException | OperatorException ex) {
            Logger.getLogger(RMin_prova.class.getName()).log(Level.SEVERE, null, ex);
        }
}


I call this class/method in another project through the code:

RMin_prova prueba = new RMin_prova();
prueba.prova();


and it works perfectly. Then I used the same code in a soap web service like that:

@WebMethod(operationName = "linear_regression")
    public void linear_regression(@WebParam(name = "name") String nomFitxer) throws InvocationTargetException {
        RMin_prova prueba = new RMin_prova();
        prueba.prova();

}


but it doesn't work. I test it through the Glassfish server with Netbeans and the browser, that it returns the message:


Exceptions details : java.lang.reflect.InvocationTargetException

javax.servlet.ServletException: java.lang.reflect.InvocationTargetException at org.glassfish.webservices.monitoring.WebServiceTesterServlet.doPost(WebServiceTesterServlet.java:342) at org.glassfish.webservices.monitoring.WebServiceTesterServlet.invoke(WebServiceTesterServlet.java:106) at org.glassfish.webservices.JAXWSServlet.doPost(JAXWSServlet.java:157) at javax.servlet.http.HttpServlet.service(HttpServlet.java:707) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174) at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283) 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.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:497) at org.glassfish.webservices.monitoring.WebServiceTesterServlet.doPost(WebServiceTesterServlet.java:313) ... 32 more Caused by: com.sun.xml.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: java.lang.NoSuchMethodException: java.lang.NoClassDefFoundError.getTargetException() Please see the server log to find more detail regarding exact cause of the failure. at com.sun.xml.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:193) at com.sun.xml.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:128) at com.sun.xml.ws.client.sei.StubHandler.readResponse(StubHandler.java:253) at com.sun.xml.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:203) at com.sun.xml.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:290) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:119) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:92) at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:161) at com.sun.proxy.$Proxy318.linearRegression(Unknown Source) ... 37 more



I've observed that the problem is due to the line:

RapidMiner.init();


If I remove that line I have no errors, but obviously the process doesn't work.

I'm using Rapidminer 5.3 as this first tests will be under the AGPL.
The same web service code works when I tried to test Weka code.

Any idea? Thanks in advance.

cesc

3 REPLIES
Moderator

Re: InvocationTargetException due to RapidMiner.init()

Hi,

1) The error you copied is only the last error. The actual cause you did not provide. That is however what would be needed to figoure out what is wrong, the error you copied says absolutely nothing.
2) SOAP? In 2016? Really? Smiley Tongue

Regards,
Marco
_________________________________________________________
Team Lead Software Engineering | RapidMiner GmbH
Contributor II

Re: InvocationTargetException due to RapidMiner.init()

Thanks Marco for your reply...
(1) It's true, in fact I'm not be able to see the problem with the text that I copied. I don't know exactly where to see the real error. Now I've seen some messages in GlassFish but I don't know interpret them either. These are:

Información:   Reading configuration resource com/rapidminer/resources/rapidminerrc.
Información:  Set locale to en.
Información:  rapidminer.home is 'C:\Users\Serpc\Documents\NetBeansProjects\RapidMiner5Quim\resources\com\rapidminer\resources'.
Grave:  Request processing failed.
com.sun.xml.ws.encoding.soap.SerializationException: java.lang.NoSuchMethodException: java.lang.NoClassDefFoundError.getTargetException()
at com.sun.xml.ws.fault.SOAPFaultBuilder.createDetailFromUserDefinedException(SOAPFaultBuilder.java:375)
at com.sun.xml.ws.fault.SOAPFaultBuilder.getFaultDetail(SOAPFaultBuilder.java:347)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:210)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createSOAPFaultMessage(SOAPFaultBuilder.java:201)
at com.sun.xml.ws.server.sei.TieHandler.createResponse(TieHandler.java:273)
at com.sun.xml.ws.server.sei.TieHandler.serializeResponse(TieHandler.java:341)
at com.sun.xml.ws.db.DatabindingImpl.serializeResponse(DatabindingImpl.java:230)
at com.sun.xml.ws.db.DatabindingImpl.serializeResponse(DatabindingImpl.java:83)
at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:99)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:136)
at org.glassfish.webservices.MonitoringPipe.process(MonitoringPipe.java:142)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:119)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
at com.sun.xml.ws.api.pipe.helper.AbstractTubeImpl.process(AbstractTubeImpl.java:136)
at com.sun.enterprise.security.webservices.CommonServerSecurityPipe.processRequest(CommonServerSecurityPipe.java:209)
at com.sun.enterprise.security.webservices.CommonServerSecurityPipe.process(CommonServerSecurityPipe.java:141)
at com.sun.xml.ws.api.pipe.helper.PipeAdapter.processRequest(PipeAdapter.java:119)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:419)
at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:868)
at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:422)
at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:169)
at org.glassfish.webservices.JAXWSServlet.doPost(JAXWSServlet.java:169)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1682)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:318)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:160)
at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:734)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:673)
at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:99)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:174)
at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:416)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:283)
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.NoSuchMethodException: java.lang.NoClassDefFoundError.getTargetException()
at java.lang.Class.getMethod(Class.java:1786)
at com.sun.xml.ws.fault.SOAPFaultBuilder.createDetailFromUserDefinedException(SOAPFaultBuilder.java:363)
... 62 more


I have not seen yet those "62 more"... Anyway, could it be something related to the file rapidminerrc?

(2)  :-[ I must confess I have no experience about web services. Simply it seemed a good way to start to try it. I suppose you consider REST as a best option, isn't it? Or is there any other better option?

Thanks again Marco

regards

cesc
Moderator

Re: InvocationTargetException due to RapidMiner.init()

Hi,

looks like Glassfish cannot find some class (weirdly does not tell which, I suppose from RapidMiner) on the classpath. Are you sure that all libraries and RapidMiner itself are available to your application at runtime? Probably the best way to check for that is to build the .war or .ear and see if it contains all the libraries needed. Then Glassfish should be able to use them.

And yes, I would almost always suggest REST nowadays. SOAP requires a specific endpoint which uses the .wsdl file to get to know your services and then query against them with loads of XML overhead due to the nature of it. This can indeed be useful sometimes (but should very rarely be necessary today).
Using REST will open up the possibility of accessing your web services from any device, e.g. an app or a webbrowser. You will have great trouble doing that with SOAP.
And building a REST service with JAX-RS 2.0 and Java EE 6 is actually very simple, way easier than using SOAP imo Smiley Happy

Regards,
Marco
_________________________________________________________
Team Lead Software Engineering | RapidMiner GmbH