I am trying to compile a java file, which uses package com.sun.xml.internal.messaging.saaj.soap.dynamic, using ANT-1.9.3 but I'm receiving error
package com.sun.xml.internal.messaging.saaj.soap.dynamic does not
exist
I tried compiling both JDK7 and JDK 8 and getting the same error.
I can see the package exist inside rt.jar of both JDK. I have set JAVA_HOME also properly.
Can someone help me to resolve this issue?
Unfortunately for you, this behaviour is probably intentional and your usage is deliberately unsupported. If your code used to compile under Java6 and now doesn't under Java7 or Java8 then you've basically fallen foul of
From one release to another, these classes may be removed, or they may be moved from one package to another
http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html
See also http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6778491 for a technical description of a possible cause of not being able to compile a class which references a 'com.sun.*' class but which throws the same compiler error you're seeing despite the fact that the referenced class exists in rt.jar. Also for the kind of response which Oracle give to bug reports relating to it;)
Unfortunately, using undocumented, unsupported APIs often has this kind of 'bite you in the posterior' kind of effect.
Please add the line, < compilerarg line="-XDignore.symbol.file" compiler="modern"/ > for < javac > tag in your build.xml. This should solve your problem. It solved for me.
For reference you can view the forum link
http://www.icesoft.org/JForum/posts/list/19871.page#sthash.srrN9Ijk.dpbs
Related
I've been on a project where I build tetris that has multiplayer, and it's been working for a couple of days with no problem, but now suddenly there's this exception:
Exception in thread "main" java.lang.NoClassDefFoundError: Game/Piece
This basically means it can't find the .class of my class called Piece, but whenever I do a "clean and build" the .class file appears, then instantly disappears when I run the project.
This is my project structure (running with JDK 16, in netbeans):
Is there a reason for this exception?
My JAVA_HOME variable: jdk1.8.0_131.
While it's possible that this is due to a classpath mismatch between compile-time and run-time, it's not necessarily true.
It is important to keep two or three different exceptions straight in our head in this case:
java.lang.ClassNotFoundException This exception indicates that the class was not found on the classpath. This indicates that we were trying to load the class definition, and the class did not exist on the classpath.
java.lang.NoClassDefFoundError This exception indicates that the JVM looked in its internal class definition data structure for the definition of a class and did not find it. This is different than saying that it could not be loaded from the classpath. Usually this indicates that we previously attempted to load a class from the classpath, but it failed for some reason - now we're trying to use the class again (and thus need to load it, since it failed last time), but we're not even going to try to load it, because we failed loading it earlier (and reasonably suspect that we would fail again). The earlier failure could be a ClassNotFoundException or an ExceptionInInitializerError (indicating a failure in the static initialization block) or any number of other problems. The point is, a NoClassDefFoundError is not necessarily a classpath problem.
And this question has been asked before.
This type of error can appear for multiple reasons :
Because the compiler is too different than the JVM, specially with new Java syntax.
Personally, I had this type of error by running Java 16 code with Java 8 JRE, and I fix it by removing the package with the Java 16 code.
Because you were using deprecated class, which have been removed since this date.
So, to fix your issue, there is multiple ways:
Use same Java in Netbeans and in your project config (to prevent change)
Upgrade your Java JRE installed (instead of old Java 8 version) to have both Java 16
Downgrade Netbeans JDK to Java 8 to have both Java 8
The objective is to use the same JVM than JDK, to see all warns/error that are linked to your current code.
So apperantly I had a warning (not an error) when compiling, it said something was depracated, so I had to add a compiler option name -Xlint:(something here I can't remember), so when I compiled it the issue was obvious, JFrame.hide() is a depracated function so I just had to remove it. It's weird that the runtime error was "NoClassDefFoundError" which has nothing to do with the issue.
This is my first post on stackoverflow, please be indulgent.
Within my project, I use the library commons-digester-1.8.
Following a need, I now use the library gwt-dev-2.3.0.
When launching the application I get this error :
Exception caught while initializing context java.lang.NoSuchMethodError: org/apache/commons/digester/xmlrules/DigesterLoader.createDigester(Lorg/xml/sax/InputSource;)Lorg/apache/commons/digester/Digester;
at fr.cnasea.commons.webfwk.util.config.lecture.XMLDigesterReader.getConfig(XMLDigesterReader.java:157)
at fr.cnasea.commons.webfwk.util.config.CnaseaAppConfigurator.configure(CnaseaAppConfigurator.java:76)
at fr.cnasea.osiris.commons.gwt.server.Config.contextInitialized(Config.java:47)
It turns out that the two libraries have the same class in the same package with the same method:
Same class
Since the use of gwt-dev, it is the method of this library which is called.
I tried to use newer versions of gwt-dev but the environment makes it not possible
How can I fix it?
Thanks for your help :)
(From my answer to your same question on the github project)
The gwt-dev.jar should not be on your server classpath - it is only used to compile your application. The same is true for gwt-user.jar. Only gwt-servlet.jar (and possibly requestfactory-server.jar) should end up on your server classpath, the others are intended only to be present when compiling, either to do the work of compiling, or to provide the compiler the classes you need.
I am working on moving code from R2007a to R2013a. I am getting a java.lang.NoClassDefFoundError during my run in R2013a which does not appear in R2007a. It occurs when I call.
feval('get',fname,jevent);
Where fname is a product.ProxyField object for an Object Filter and jevent is a product.format.java.internal.JavaEvent.
The class is in a jar file on the path and is being accessed by another class in the same jar file. The stack trace does not leave the realm of the product if that helps.
I do not have access to the original code for the jar file. I do have access to code derived from that original code and both classes are in the same package. I'm guessing this has something to do with differences in the java version but I'm not sure what to do since I don't have the original code to recompile.
Unfortunately I can't provide actual source or full detail but a google search only yielded results for MATLAB startup issues. Any thoughts?
Seems like the difference between R2007a and R2013a is that the first uses 1.5 jre and second uses 1.6 jre. It would be easier to help you if you provided the stack trace showing the exception. Sometimes classes get moved around in between jvm versions, so having the actual missing classes would help in determining if the missing class is a class that was just moved around to a different package. You could take the missing class, google it adding the same exception message as you put above and seeing who else ran into similar issues.
I want to debug a static inner class, which is actually a Callable. Whenever I try to set a conditional breakpoint in Eclipse I get the breakpoint error:
The type com.sun.source.tree.Tree$Kind cannot be resolved. It is
indirectly referenced from required .class files.
What is causing this error? Is it a bug in the class/package that uses com.sun.source.tree.Tree$Kind but does not provide it? How do I find out which class it is? How do I resolve it?
An example expression which should be correct is: return mRtx.getNode().getNodeKey() == 74;
I have changed it to mRtx.getNode().getNodeKey() == 74 but still the same error. Recently I've found the bug and simply used:
if (mRtx.getNode().getNodeKey() == 74) {
System.out.println("bla");
}
and set a "normal" breakpoint on the "sysout" statement just in case someone has the same problem.
I am not sure on how I would reproduce it as your description is not exactly telling much.
The com.sun.source.tree package is included in tools.jar, which is part of JDK but not of JRE, so make sure you run your Eclipse in JDK (JAVA_HOME variable?), maybe try setting projects JRE to a JDK folder.
I also think that the Compiler API was introduced in Java 6, so check if you are not using a lower version.
Maybe you should try to edit the debugger's source lookup.
To do this, go to debug perspective, in the debug view (where the stack is normally shown) right click on the terminated run, and choose 'Edit Source Lookup...'.
Then you can add a lookup place. In this case you should maybe add the tools.jar that is in the jre folder.
The compiler can't find the type, that is the root issue, but in my thinking, this should only be a compile time error, but by implication from what I read, it's a run time error. Is that correct?
Here is are some tips:
http://java.syntaxerrors.info/index.php?title=Cannot_resolve_type
Indirectly referenced from required .class file
Maybe you could post more code or use "control + T" in Eclipse on the class to look at the type hierarchy, I would like to know what other classes are referenced.
HTH,
James
While compiling my project I get:
The system is out of resources.
Consult the following stack trace for details.
java.lang.StackOverflowError
at com.sun.tools.javac.code.Type$WildcardType.isSuperBound(Type.java:435)
at com.sun.tools.javac.code.Types$1.visitWildcardType(Types.java:102)
at com.sun.tools.javac.code.Types$1.visitWildcardType(Types.java:98)
at com.sun.tools.javac.code.Type$WildcardType.accept(Type.java:416)
at com.sun.tools.javac.code.Types$MapVisitor.visit(Types.java:3232)
at com.sun.tools.javac.code.Types.upperBound(Types.java:95)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2986)
at com.sun.tools.javac.code.Types.adapt(Types.java:3016)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2977)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2986)
at com.sun.tools.javac.code.Types.adapt(Types.java:3016)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2977)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2986)
at com.sun.tools.javac.code.Types.adapt(Types.java:3016)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2977)
at com.sun.tools.javac.code.Types.adaptRecursive(Types.java:2986)
at com.sun.tools.javac.code.Types.adapt(Types.java:3016)
...
How do you find the root of the problem?
I have found a bug report...
The bug report you linked to indicates that the bug was fixed in JDK 6. Which version of the JDK are you using to build?
If you can't identify the part of your source that is causing the problem, perhaps you could try compiling with JDK 6 to see if it can identify the problem without crashing.
Otherwise, I would use the "divide and conquer" approach: Remove half your source code, compile, and see if it still crashes. Depending on whether it does or not, you will know which half the problem is in. Repeat.
I would start by running javac with the -verbose option to see which .java file was causing the problem.
What about trying a different compiler, like the one in Eclipse? It's error messages are at least different, in my experience often more to the point. Also I haven't seen compilation failures like this yet.