I've been trying to send an email using the JavaMail API and Gmail SMTP. I am using IntelliJ IDEA Community Edition 2020.3.3. After following this tutorial and using this code (the one about Gmail SMTP with TLS), I keep getting the same error:
1st link - error
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataHandler
at mainPackage.JavaMailUtil.prepareMessage(JavaMailUtil.java:40)
at mainPackage.JavaMailUtil.sendMail(JavaMailUtil.java:28)
at mainPackage.JavaMail.main(JavaMail.java:5)
Caused by: java.lang.ClassNotFoundException: javax.activation.DataHandler
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 3 more
2nd link - error
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataHandler
at lukemaster06.emailPackage.SendEmailTLS.main(SendEmailTLS.java:30)
Caused by: java.lang.ClassNotFoundException: javax.activation.DataHandler
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:606)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:168)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 1 more
Since I'm fairly new to Java programming, I don't understand what I'm doing wrong. Thank you in advance for the help.
To see the IntelliJ IDEA projects, visit this GitHub page. If anything does wrong with them, let me know. You can also email me for more discussion-based conversations: public.lukemaster06#gmail.com
Which version of Java are you using? It's possible that since the DataHandler comes from JavaBeans Activation Framework you may not have it, since the last version of Java that included it was Java 1.8.
If that's the case you need to include this library in your project:
https://mvnrepository.com/artifact/com.sun.activation/javax.activation/1.2.0
Related
My OS = CentOS-7
Oracle 18.4 XE
Java 8 JDK + Tomcat 8
I facing the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/dms/console/DMSConsole
at oracle.jdbc.driver.DMSFactory.<clinit>(DMSFactory.java:46)
at oracle.jdbc.driver.PhysicalConnection.createDMSSensors(PhysicalConnection.java:1713)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:849)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:443)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:34)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:712)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at Test.main(Test.java:9)
Caused by: java.lang.ClassNotFoundException: oracle.dms.console.DMSConsole
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 9 more
I searched a lot but was unable to find any forum where I can see aforementioned error related to oracle 18.4.0.
I searched my whole server even unzipped all ojdbc*.jar but not found DMSConsole anywhere
I removed all previous jdbc jar drivers and downloaded latest ojdbc8-full.tar.gz driver form this LINK but nothing fixed the problem
Best Regards
What are you trying to do? If you are planning to use dms jar then you should use
ojdbc8dms.jar. Check out the question "What are the different JAR files on the 19.3 JDBC driver download page for?" in JDBC FAQ
You can get these jars from maven. Check out the blog for details. You can also download these from ojdbc8-debug.tar.gz from OTN. Make sure to have dms.jar in the classpath.
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8dms</artifactId>
<version>19.6.0.0</version>
This can be solved by adding a correct dms.jar but when not detailled log is needed the following jars are the minimum to include
ojdbc8.jar
orai18n.jar
I have been trying to run the archetype example and another project I am trying to upgrade from 6.5 to 7.0.0, but I have failed to do so.
The archetype example runs ok on jetty and the project I was trying to upgrade runs ok both in jetty and was 8.5.5.7, but after changing the dependencies I keep getting the exception below and I am not quite sure if it is a problem with configuration (as everything worked ok with 6.5), with wicket 7.0.0 as the exception comes from inside wicket or from WAS8.5.5.7.
[ERROR ] SRVE0271E: Uncaught init() exception created by servlet [wicket-servlet] in application [blahblah]: javax.servlet.ServletException: java.lang.ClassCastException: com.ibm.ws.artifact.url.internal.WSJarURLStreamHandler$WSJarURLConnectionImpl cannot be cast to java.net.JarURLConnection
at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:455)
at org.apache.wicket.protocol.http.WicketServlet.init(WicketServlet.java:271)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
at [internal classes]
Caused by: java.lang.ClassCastException: com.ibm.ws.artifact.url.internal.WSJarURLStreamHandler$WSJarURLConnectionImpl cannot be cast to java.net.JarURLConnection
at org.apache.wicket.Application.collectWicketProperties(Application.java:503)
at org.apache.wicket.Application.initializeComponents(Application.java:593)
at org.apache.wicket.Application.initApplication(Application.java:918)
at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:429)
... 4 more
[ERROR ] SRVE0315E: An exception occurred: java.lang.Throwable: javax.servlet.ServletException: java.lang.ClassCastException: com.ibm.ws.artifact.url.internal.WSJarURLStreamHandler$WSJarURLConnectionImpl cannot be cast to java.net.JarURLConnection
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:4900)
at [internal classes]
Caused by: javax.servlet.ServletException: java.lang.ClassCastException: com.ibm.ws.artifact.url.internal.WSJarURLStreamHandler$WSJarURLConnectionImpl cannot be cast to java.net.JarURLConnection
at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:455)
at org.apache.wicket.protocol.http.WicketServlet.init(WicketServlet.java:271)
at javax.servlet.GenericServlet.init(GenericServlet.java:244)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.init(ServletWrapper.java:332)
... 1 more
Caused by: java.lang.ClassCastException: com.ibm.ws.artifact.url.internal.WSJarURLStreamHandler$WSJarURLConnectionImpl cannot be cast to java.net.JarURLConnection
at org.apache.wicket.Application.collectWicketProperties(Application.java:503)
at org.apache.wicket.Application.initializeComponents(Application.java:593)
at org.apache.wicket.Application.initApplication(Application.java:918)
at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:429)
... 4 more
UPDATE------------ as of wicket 7.1.0 there isn't an issue anymore.
As mentioned in #klopfdreh answer there was a compatibility issue, I am accepting that answer, because I think the discussion in the comments may have helped the wicket team fix/pinpoint the issue in the 7.1.0 release.
It is only an assumption, but it appears that the problem seems to be close to this one:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=430180
As of one comment, can you try to set the following options at your "jvm.options":
-Dcom.ibm.websphere.persistence.DisableJpaFormatUrlProtocol=true
To implement it without disable the "wsjar" protocol we need more input about the implementation of "WSJarURLConnectionImpl" - the only method called from the "JarURLConnection" is "getJarFile()", so the question here is: Does "WSJarURLConnectionImpl" also provide this method and returns it a JarFile? Then we may use reflections at this place.
I am trying to run RestClient .From this code I deleted all Loggers related code.But I kept classpath for log4j same. Then run the application ,it gives following two exceptions
java.lang.NoClassDefFoundError: org/apache/log4j/Level
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Level
Please give reason for those exceptions.
Other jars that you use most likely will use log4j. Also, make sure you remove imports of log4j, not just the code that uses it.
Help me on this exception , Occurs during calling wcf webservice
Log by netbeans
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:107)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107)
at $Proxy32.logon(Unknown Source)
at newtestclient.NewTestClient.main(NewTestClient.java:92)
Caused by: java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.internal.bind.api.JAXBRIContext
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.<clinit>(SOAPFaultBuilder.java:533)
... 5 more
Java Result: 1
The exception says :
java.lang.ClassCastException: com.sun.xml.bind.v2.runtime.JAXBContextImpl cannot be cast to com.sun.xml.internal.bind.api.JAXBRIContext.
It's a common error that appears when there is a conflict between libraries and its dependencies. You should try to execute your code in a test project with only the libraries from JAX-RPC, and then add one by one the rest of your app libraries.
Also, you should check your server libraries to discard any kind of conflict for having the same library (or its dependencies) in your app and in your server with different versions.
I have a big problem according to the bluecove library which I am trying to use in an ANT project.
My project is a platform which receive messages from different agents, such as TCP agents, SunSpot agents (which use UDP), and now I'm trying to set bluetooth agents.
For this purpose is required the bluecove library, but result in conflict with javax.microedition.io used for example in the UDP classes that I'm implementing.
I guess that it's a library conflict, I have tried to put the bluecove-2.1.1 jar into the jdk1.6_xx/jre/lib/ext but this throws an exception in the UDP classes:
Error checking for shared basestation: javax.microedition.io.ConnectionNotFoundException: radiogram
javax.microedition.io.ConnectionNotFoundException: udp
javax.microedition.io.ConnectionNotFoundException: udp
at com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:185)
at com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:162)
at javax.microedition.io.Connector.open(Connector.java:83)
at org.sunspotworld.SunSpotListener.run(SunSpotListener.java:48)
However if I remove from the content of bluecove2.1.1 jar the folder javax/microedition the error thrown is completely different:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/microedition/io/Connection
Exception in thread "main" java.lang.NoClassDefFoundError: javax/microedition/io/Connection
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.intel.bluetooth.Utils.class$(Utils.java:44)
at com.intel.bluetooth.Utils.<clinit>(Utils.java:44)
at javax.bluetooth.UUID.<init>(UUID.java:224)
at org.sunspotworld.BTListener.<clinit>(BTListener.java:28)
at org.sunspotworld.SunSpotHostApplication.run(SunSpotHostApplication.java:67)
at org.sunspotworld.SunSpotHostApplication.main(SunSpotHostApplication.java:342)
Caused by: java.lang.ClassNotFoundException: javax.microedition.io.Connection
Caused by: java.lang.ClassNotFoundException: javax.microedition.io.Connection
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 8 more
... 8 more
I have read some solution involving xbootclasspath/a but I have no any idea what is that o how I can manage it...
Edit: I have used Xboothclasspath/a and /p to add the bluecove jar route, and the only thing I got was the chance to remove the jar import from my NetBeans project. Still not working. =(
Thank you very much in advance !!
I don't know why you decided this error is caused by a conflict between the two libs as i don't see any mention to this in the error.
The second error (after removing the lib) simply states that it can't find the required classes (which is logical since you removed them :) ).
I'd suggest you check that the firewall is not blocking you.