I have been given a java app to modify with the following:
import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPMessage;
import javax.xml.soap.SOAPPart;
But When I run it from cmd it throws the error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/axis/SOAPP art
It seems to find the other imports without issue. Does 'NoClassDefFound' mean the class itself wasn't found? If so how can I check it is there and replace it if not? (I am using Eclipse)
Update: Okay I have found the class in 'JRE System Library>rt.jar>javax.xml.soap>SOAPPart.class' So if the class is there why do I get the error?
Turns out I needed to choose Export> 'Runnable JAR file' in eclipse instead of 'JAR file'
Related
My goal is to use the NCTOOLBOX (https://github.com/nctoolbox/nctoolbox/wiki/) in a compiled MATLAB app.
Currently, I'm able to use the toolbox as intended when I run my code NOT from the compiled app.
However, when I try to perform the same tasks in the compiled app, it seems my scripts are struggling to find the right java drivers.
I'm relatively familiar with compiling apps using MATLAB. There are other java drivers which I successfully use in the same compiled app. The approach I use for those java drivers is to add them in the 'settings' menu of the Application Compiler.
For example, in the field "Additional parameters passed to the mcc:" I have a series of .jar files which I add like so (this driver is not the one causing the issue, it is just an example):
-a "C:\someFilePath\postgresql-42.2.12.jar"
^^ when I run my app NOT in its compiled state, the same java driver is added like so (and successfully ):
javaaddpath('C:\someFilePath\postgresql-42.2.12.jar');
The NCTOOLBOX script which is erroring on me is "ncdataset.m" and the exact line of code I'm erroring out on is:
obj.netcdf = ucar.nc2.dataset.NetcdfDataset.openDataset(url)
Here is the rest of the error readout (the above line of code shared is line 87 referenced in the following error readout):
Error using ncdataset (line 87)
Java exception occurred:
java.io.IOException: java.lang.RuntimeException: java.lang.NoSuchMethodError: ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.emptyIntList()Lcom/google/protobuf/Internal$IntList;
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:401)
at ucar.nc2.dataset.NetcdfDataset.openProtocolOrFile(NetcdfDataset.java:831)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:479)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:461)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:442)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:426)
Caused by: java.lang.RuntimeException: java.lang.NoSuchMethodError: ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.emptyIntList()Lcom/google/protobuf/Internal$IntList;
at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1634)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:798)
at ucar.nc2.NetcdfFile.open(NetcdfFile.java:398)
... 5 more
Caused by: java.lang.NoSuchMethodError: ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.emptyIntList()Lcom/google/protobuf/Internal$IntList;
at ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.<init>(Grib2IndexProto.java:140)
at ucar.nc2.grib.grib2.Grib2IndexProto$GribIdSection.<clinit>(Grib2IndexProto.java:1395)
at ucar.nc2.grib.grib2.Grib2Index.makeIdProto(Grib2Index.java:334)
at ucar.nc2.grib.grib2.Grib2Index.makeRecordProto(Grib2Index.java:286)
at ucar.nc2.grib.grib2.Grib2Index.makeIndex(Grib2Index.java:243)
at ucar.nc2.grib.GribIndex.readOrCreateIndexFromSingleFile(GribIndex.java:94)
at ucar.nc2.grib.collection.Grib2CollectionBuilder.makeGroups(Grib2CollectionBuilder.java:84)
at ucar.nc2.grib.collection.GribCollectionBuilder.createMultipleRuntimeCollections(GribCollectionBuilder.java:128)
at ucar.nc2.grib.collection.GribCollectionBuilder.createIndex(GribCollectionBuilder.java:120)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:825)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromDataFile(GribCdmIndex.java:804)
at ucar.nc2.grib.collection.GribCdmIndex.openGribCollectionFromRaf(GribCdmIndex.java:774)
at ucar.nc2.grib.collection.GribIosp.open(GribIosp.java:201)
at ucar.nc2.NetcdfFile.<init>(NetcdfFile.java:1610)
... 7 more
Error in cfdataset (line 59)
Error in ncgeodataset (line 74)
Despite adding all the of .jar files supplied with the NCTOOLBOX, MATLAB appears to struggle to find / use them.
I notice that in the supplied NCTOOLBOX function called "ncugrid.m", there is a block of code which 'imports' various "ucar" related methods.
I wonder if I need to set something up in my app compilation project definition which can take the place of this 'import' block.
Example of 'import' block:
import ucar.ma2.Array;
import ucar.ma2.DataType;
import ucar.nc2.Attribute;
import ucar.nc2.Dimension;
import ucar.nc2.Variable;
import ucar.nc2.dataset.CoordinateSystem;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.VariableDS;
import ucar.nc2.dt.ugrid.Cell;
import ucar.nc2.dt.ugrid.Edge;
import ucar.nc2.dt.ugrid.Face;
import ucar.nc2.dt.ugrid.Node;
import ucar.nc2.dt.ugrid.UGridDataset;
import ucar.nc2.dt.ugrid.geom.LatLonPoint2D;
If anyone has insights / suggestions on what to try / solutions, they would be very much appreciated! Thank you in advance!
I have:
Oracle 19c
java 8 on its machine
What i did:
I write simple class with one method in Java 8.
package <mypackage>;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.networknt.schema.JsonSchema;
import com.networknt.schema.JsonSchemaFactory;
import com.networknt.schema.SpecVersion;
import com.networknt.schema.ValidationMessage;
import java.io.IOException;
import java.io.Reader;
import java.sql.Clob;
import java.sql.SQLException;
import java.util.Set;
import java.util.stream.Collectors;
public class <classname> {
<some simple validation function>
}
I compile my project with maven and maven-assembly-plugin to build .jar file with dependencies.
I upload it with loadtool: loadjava -f -r -v -synonym -oracleresolver -resolve -grant <user> -thin -user <credentials> <filename>.jar
There were 0 errors during upload. All uploaded classes (including dependencies) have 'VALID' status in dba_objects table.
I write PL/SQL wrapper over my Java function.
create FUNCTION <funcname>(P_IN_BODY_TEXT CLOB, P_IN_BODY_SCHEMA_TEXT CLOB)
RETURN VARCHAR2
AS LANGUAGE JAVA NAME '<packagename>.<classname>.<funcname>(java.sql.Clob, java.sql.Clob) return java.lang.String';
/
I use this function in my ORDS REST Service.
When doing request to ORDS i am getting this exception:
The request could not be processed because an error occurred whilst attempting to evaluate
the SQL statement associated with this resource.
Please check the SQL statement is correctly formed and executes without error. SQL Error Code: 29532,
Error Message: ORA-29532: Java call terminated by uncaught Java exception:
java.lang.NoClassDefFoundError ORA-06512: at <rest stacktrace that gives me nothing>
Quiestion is:
What is root of this problem? By -synonym flag tool creates synonyms for me, all classes is valid. Do i need some permisions to use java packages liike java.sql that in my class imports? I upload some others open sources java libraries into my Oracle, but they doesn't hava dependencies - is that the problem?
Problem was in slf4j library that throws this exception. slf4j was dependency of library that i used.
Didn't dig the problem, I just pick another labrary with less dependencies and its works.
I'm using following package for calling Weka functions from within Matlab https://github.com/NicholasMcCarthy/wekalab
and my code is
close all; clear all; clc;
dbstop if error
%%
javaclasspath('C:\Program Files (x86)\Weka-3-8\weka.jar');
javaaddpath('C:\Users\PC\wekafiles\packages\imageFilters\imageFilters.jar');
%%
import weka.filters.*
import weka.filters.Filter.*
import weka.filters.unsupervised.instance.imagefilter.*
import weka.filters.unsupervised.instance.imagefilter.BinaryPatternsPyramidFilter.*
import weka.classifiers.Classifier.*
import weka.classifiers.functions.SMO.*
import weka.classifiers.Evaluation.*
import weka.core.Attribute.*
import weka.core.FastVector.*
import weka.core.Instances.*
import weka.core.DenseInstance.*
import weka.classifiers.Classifier.*
import weka.classifiers.Evaluation.*
import weka.core.converters.ArffLoader.*
import weka.filters.unsupervised.instance.imagefilter.*
import weka.core.converters.ConverterUtils.*;
D = wekaLoadData('E:\pro\program\selectedPics\character\test.arff', 'ARFF');
myFilter = wekaFilter('weka.filters.unsupervised.instance.imagefilter.BinaryPatternsPyramidFilter');
filteredData = wekaApplyFilter(D, myFilter);
when i use the default filters of weka,
myFilter = wekaFilter('weka.filters.unsupervised.attribute.Standardize');
it works fine but when i use the installed package of weka (imageFilters) it give me this error
Error using javaObject
No class weka.filters.unsupervised.instance.imagefilter.BinaryPatternsPyramidFilter can be located on the Java class path
image filter (package) path: C:\Users\PC\wekafiles\packages\imageFilters
weka path: C:\Program Files (x86)\Weka-3-8
Environment variable & their paths:
CLASSPATH
C:\Program Files (x86)\Weka-3-8\weka.jar;
C:\Program Files(x86)\Weka-3-8\imageFilters\imageFilters.jar;
C:\Users\PC\wekafiles\packages\imageFilters\src\main\java;
C:\Users\PC\wekafiles\packages\imageFilters\src\main\java\filters\unsupervised\instance\imagefilter;
C:\Users\PC\wekafiles\packages\imageFilters\src\main\java\filters\unsupervised\instance;
java
C:\Program Files\Java\jre1.8.0_181\bin;
PATH
C:\Program Files\Java\jdk1.8.0_181\bin;
PATH_HOME
C:\Program Files\Java\jdk1.8.0_181;
You can use weka.Run in order to use additional packages in weka (weka.Run details)
On the Terminal:
Before using it you may want to add your weka.jar file into CLASSPATH:
export CLASSPATH=path_to_weka.jar
For example, a way to use this command:
java weka.Run weka.filters.unsupervised.instance.imagefilter.BinaryPatternsPyramidFilter -D "directory were files to filter are located" -i "input arff" -o "output arff"
For more info, check: Weka official documenation
In my case, I used the manual for Weka 3-7-8. The information mentioned is on the page 26 under Running installed learning algorithms. This could change from version to version.
Here you have a list of any manual you could need: Weka manuals for every version
About using it on Java, I don't have information about it. I wanted to answer this question because there might be people out there needing help with command line Weka.
I built *.jar file for my apache spark scala project using maven. When I try to execute the main class, at some line of the code it provides the error Exception in thread "main" java.lang.NoClassDefFoundError for the class org.apache.spark.ml.recommendation.ALS.
I run the spark-submit as follows:
sudo -u hdfs /usr/bin/spark-submit --class
org.apache.spark.examples.ml.MyTest spark-examples-*.jar --rank 10 --path
/home/ubuntu/data
It looks like it only cannot find org.apache.spark.ml.recommendation.ALS. I have the following import statements in the class:
package org.apache.spark.examples.ml
import java.util.Date
import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.examples.mllib.AbstractParams
import org.apache.spark.ml.recommendation.ALS
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.{Row, SQLContext}
import scopt.OptionParser
How to solve this issue?
UPDATE 1:
I added maven-assebly plugin to pom.xml and also assembly.xml into the folder resources. Then I successfully made mvn package, but again the same problem.
UPDATE 2:
jar -tvf spark-examples-1.5.3-SNAPSHOT-hadoop2.2.0.jar | grep "ALS"
2678 Mon May 23 13:11:44 CEST 2016 org/apache/spark/examples/ml/recommendation/MyFunc$ALSParams.class
First find out reason for failure. 1) Is class missing ? 2) or It is initialization problem.
To find out whether class is available run command jar -tvf <.jar> | grep "class name" by this way you can find out whether class file is present or not or its initialization issue.
I am using Eclipse based development environment - a Groovy/Grails Tool Suite. The issue seems to be that eclipse is not able to find some JARs. And I dont understand where to put those JARs. Below are the details.
I am trying to step through the code. However when I put watch on any variable it gives error, but the same variable evaluates correctly on Variables window. I did one obeservation, that when there are a lot of expressions in my Expressions window, the debugger slows down, it takes time to evaluate those expressions but gives error for all. When I remove all expressions it steps through without any slow down. Also similar error occur when I use Display window
Below is the screen shot of whats happening
I checked the eclipse error log file. There are many errors, but below seems to be relevant one:
!ENTRY org.grails.ide.eclipse.groovy.debug.core 4 0 2015-08-19 12:40:09.963
!MESSAGE Internal error logged from Groovy Core Debug:
!STACK 0
java.lang.Exception: (Groovy) Complete snippet:
/////start
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
println it
/////end
at org.grails.ide.eclipse.groovy.debug.core.evaluation.GroovyJDIEvaluator.performEvaluate(GroovyJDIEvaluator.java:202)
at org.grails.ide.eclipse.groovy.debug.core.evaluation.GroovyJDIEvaluator$1$1.run(GroovyJDIEvaluator.java:160)
at org.eclipse.jdt.internal.debug.core.model.JDIThread.runEvaluation(JDIThread.java:764)
at org.grails.ide.eclipse.groovy.debug.core.evaluation.GroovyJDIEvaluator$1.run(GroovyJDIEvaluator.java:165)
at org.eclipse.jdt.internal.debug.core.model.JDIThread$ThreadJob.run(JDIThread.java:3157)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
____Eval.groovy: 8: unable to resolve class org.slf4j.Logger
# line 8, column 18.
import org.slf4j.Logger;
^
____Eval.groovy: 9: unable to resolve class org.slf4j.LoggerFactory
# line 9, column 18.
import org.slf4j.LoggerFactory;
^
2 errors
at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:313)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:1040)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:647)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:596)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:279)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:258)
at org.grails.ide.eclipse.groovy.debug.core.evaluation.GroovyJDIEvaluator.convertSnippetToScript(GroovyJDIEvaluator.java:349)
at org.grails.ide.eclipse.groovy.debug.core.evaluation.GroovyJDIEvaluator.performEvaluate(GroovyJDIEvaluator.java:183)
... 5 more
Seems like it needs some jars, but which and where to put them? I tried adding the file slf4j-api-1.7.2.jar which contains these classes to %JAVA_HOME%/lib and %JAVA_HOME%\jre\lib and also to ggts' plugins folder, but it did not helped.