0 Replies Latest reply on Sep 11, 2016 5:27 AM by maniek.rm

    Loading the file in java code using WEKA's library throws java.lang.ClassCastException

    maniek.rm

      Hi,

      I use a Wildfly 10 and a WEKA 3.8 in my Java EE project. I'm trying to load a CSV file in java code for the WEKA by means of the WEKA's library (based on http://weka.wikispaces.com/Use+Weka+in+your+Java+code article, chapter `3.5.5 and newer`):

       

        import weka.core.converters.ConverterUtils.DataSource;
        ....
        DataSource source=new DataSource(pathFile.toString());
        ...
      

       

      Unfortunately, the above code throws this exception:

      Problem with 'weka.filters.UnsupervisedFilter': java.lang.ClassCastException: org.jboss.modules.ModuleClassLoader cannot be cast to java.net.URLClassLoader

       

      Do you have any idea what can I do to fix this issue? Could it be a Wildfly bug?

       

      Full stacktrace:

       

        10:33:04,226 INFO  [stdout] (default task-29) Problem with 'weka.filters.UnsupervisedFilter': java.lang.ClassCastException: org.jboss.modules.ModuleClassLoader cannot be cast to java.net.URLClassLoader
        10:33:04,227 INFO  [stdout] (default task-29) Problem with 'weka.filters.UnsupervisedFilter': java.lang.ClassCastException: org.jboss.modules.ModuleClassLoader cannot be cast to java.net.URLClassLoader
        10:33:04,228 INFO  [stdout] (default task-29) Problem with 'weka.classifiers.IterativeClassifier': java.lang.ClassCastException: org.jboss.modules.ModuleClassLoader cannot be cast to java.net.URLClassLoader
        10:33:04,228 INFO  [stdout] (default task-29) Problem with 'weka.classifiers.IterativeClassifier': java.lang.ClassCastException: org.jboss.modules.ModuleClassLoader cannot be cast to java.net.URLClassLoader
        10:33:04,228 INFO  [stdout] (default task-29) Problem with 'weka.experiment.Tester': java.lang.ClassCastException: org.jboss.modules.ModuleClassLoader cannot be cast to java.net.URLClassLoader
      
        // OTHER EXCETIONS [Problem with 'weka.*': java.lang.ClassCastException: org.jboss.modules.ModuleClassLoader cannot be cast to java.net.URLClassLoader]
      
        10:33:04,427 WARNING [javax.enterprise.resource.webcontainer.jsf.lifecycle] (default task-29) #{dataAnalysisController.load()}: java.lang.ExceptionInInitializerError: javax.faces.FacesException: #{dataAnalysisController.load()}: java.lang.ExceptionInInitializerError
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
        at javax.faces.component.UICommand.broadcast(UICommand.java:315)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
        at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
        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:60)
        at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
        at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
        at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
        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:284)
        at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:263)
        at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
        at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:174)
        at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
        at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:793)
        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: javax.faces.el.EvaluationException: java.lang.ExceptionInInitializerError
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:101)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
        ... 34 more
        Caused by: java.lang.ExceptionInInitializerError
        at weka.core.converters.ConverterUtils.initialize(ConverterUtils.java:772)
        at weka.core.converters.ConverterUtils.<clinit>(ConverterUtils.java:728)
        at weka.core.converters.ConverterUtils$DataSource.<init>(ConverterUtils.java:126)
        at com.system.analysis.LearningMachine.load(LearningMachine.java:34)
        at com.system.analysis.DataMining.saveToFileMethod1(DataMining.java:284)
        at com.system.analysis.DataMining.getMethod1(DataMining.java:113)
        at com.system.analysis.DataTableWectorsMethod1Class.load(DataTableWectorsMethod1Class.java:45)
        at com.system.controller.DataAnalysisController.load(DataAnalysisController.java:134)
        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:498)
        at javax.el.ELUtil.invokeMethod(ELUtil.java:308)
        at javax.el.BeanELResolver.invoke(BeanELResolver.java:415)
        at javax.el.CompositeELResolver.invoke(CompositeELResolver.java:256)
        at com.sun.el.parser.AstValue.invoke(AstValue.java:285)
        at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
        at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
        at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
        at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
        at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
        at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
        at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
        ... 35 more
        Caused by: java.awt.HeadlessException
        at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
        at java.awt.Window.<init>(Window.java:536)
        at java.awt.Frame.<init>(Frame.java:420)
        at java.awt.Frame.<init>(Frame.java:385)
        at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1758)
        at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1833)
        at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1696)
        at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:863)
        at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)
        at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)
        at weka.gui.GenericObjectEditor.determineClasses(GenericObjectEditor.java:242)
        at weka.gui.GenericObjectEditor.<clinit>(GenericObjectEditor.java:257)
        ... 58 more