This is the code :
Session session = Session.getDefaultInstance(props, null);
Store store = session.getStore("imaps");
store.connect("imap.gmail.com", "****@gmail.com", "****");
System.out.println(store);
Folder folder = store.getDefaultFolder();
folder = folder.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
System.out.println("Message Count: "+folder.getMessageCount());
System.out.println("Unread Message Count: "+folder.getUnreadMessageCount());
Message[] messages = folder.getMessages(); --> here the code stops.
FetchProfile fp = new FetchProfile();
fp.add(FetchProfile.Item.ENVELOPE);
folder.fetch(messages, fp);
for (int i = 0; i< messages.length; i++)
{
System.out.println("From:"+ messages[i].getFrom());
}
The code gives out the following excption and stops at the point shown.
Exception in thread «main» java.lang.NoClassDefFoundError: javax/activation/DataSource
at com.google.code.com.sun.mail.imap.MessageCache.getMessage(MessageCache.java:129)
at com.google.code.com.sun.mail.imap.IMAPFolder.getMessage(IMAPFolder.java:1394)
at openReports.OpenReports.main
Martin
36.2k15 gold badges72 silver badges82 bronze badges
asked Nov 18, 2011 at 17:26
1
In case you use maven you can add manually
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
vorburger
3,35429 silver badges38 bronze badges
answered May 28, 2018 at 5:22
jedizjediz
4,3775 gold badges34 silver badges41 bronze badges
3
I added activation.jar to buildpath and the problem is solved.
So i used 2 jars java-mail-ima.** .jar, activation.jar (for further referebces).
answered Nov 19, 2011 at 4:06
RaviKiranRaviKiran
5552 gold badges7 silver badges16 bronze badges
5
On jdk 1.8 I solved this problem by reinstalling jdk and check path in JAVA_HOME and JRE_HOME
answered Nov 11, 2021 at 12:59
i’m trying to generate class stubs for a wsdl with Intellij-Idea 2017.2.5 (Webservices -> Generate code from wsdl…) using JDK-9
I’m getting this exception and i wonder how to tell intellij to pass «—add-modules java.activation» to complete the operation.
(i guess i should run wsimport from the command line…)
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(RuntimeBuiltinLeafInfoImpl.java:461)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(RuntimeTypeInfoSetImpl.java:65)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:133)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:85)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.<init>(ModelBuilder.java:156)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:93)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:455)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:303)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:142)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1174)
at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getJAXBContext(BindInfo.java:335)
at com.sun.tools.xjc.reader.internalizer.SCDBasedBindingSet.apply(SCDBasedBindingSet.java:235)
at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:541)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:269)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:95)
at com.sun.tools.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:142)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2244)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:191)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:137)
at com.sun.tools.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:391)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:204)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:179)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.sun.tools.ws.Invoker.invoke(Invoker.java:135)
at com.sun.tools.ws.WsImport.main(WsImport.java:57)
Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 28 more
asked Oct 24, 2017 at 21:38
![]()
4
Based on your error message, you need to add the following dependency in your pom.xml
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
From SDK 9, for JAXB to work for web services you need to also have the following dependencies if you do not already have them as they are not part of the SDK.
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
answered Apr 23, 2018 at 4:40
3
I guess it can be useful. I have these additional packages in my soap project when switch from Java 8 to 10. Gradle:
compile "javax.xml.bind:jaxb-api:2.3.0"
compile "javax.activation:activation:1.1"
compile "com.sun.xml.bind:jaxb-impl:2.3.0"
compile "com.sun.xml.bind:jaxb-core:2.3.0"
compile "com.sun.xml.ws:rt:2.3.0"
compile "com.sun.xml.ws:jaxws-rt:2.3.0"
answered Aug 23, 2018 at 13:40
![]()
SvetopolkSvetopolk
3373 silver badges14 bronze badges
0
Just for other people with the same exception coming here:
This problem can also occur if you use a web server such as tomcat and if you need the activation jar to be present there as well. One possible solution is to put it in the lib folder of tomcat (or to use the common.loader functionality).
answered Dec 3, 2018 at 16:21
2
I had the same problem. After changing the project jdk, it works for me.
Change project jdk to 8.
![]()
Ardent Coder
3,6879 gold badges28 silver badges51 bronze badges
answered Jun 11, 2020 at 15:47
![]()
2
Issue
I’m trying to send Mail using SMTP on netbean when I get the error message:
run: Exception in thread «main» java.lang.NoClassDefFoundError:
javax/activation/DataSource at
SendMail.createMessage(SendMail.java:45) at
SendMail.main(SendMail.java:59) Caused by:
java.lang.ClassNotFoundException: javax.activation.DataSource 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)
… 2 more
C:UsersAdminAppDataLocalNetBeansCache12.0executor-snippetsrun.xml:111:
The following error occurred while executing this line:
C:UsersAdminAppDataLocalNetBeansCache12.0executor-snippetsrun.xml:68:
Java returned: 1 BUILD FAILED (total time: 0 seconds)
How do i need to fix it?
(I use Apache NetBeans IDE 12.0;
Java: 15; Java HotSpot(TM) 64-Bit Server VM 15+36-156)
Solution
For classes such as javax.activation.DataSource you need the JAR file for the JavaBeans Activation Framework.
You can download the JAR from Maven Central here — click on the jar link there.
If you are using a dependency management tool such as Maven, Gradle, etc. then use the related configuration (also available in that same page). Using a dependency management tool is strongly recommended over just downloading JAR files one-by-one.
You should also consider replacing your javax imports with jakarta imports, since that is now where these packages are maintained, going forward.
If you do that, then you need to use the Jakarta Activation API, available here. For example:
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>2.0.1</version>
</dependency>
And if you do that, you should also replace JavaMail classes too — for example, you can replace this:
import javax.mail.Message;
with this:
import jakarta.mail.Message;
And use a Jakarta Mail resource, for example:
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>2.0.1</version>
</dependency>
Answered By — andrewJames
Answer Checked By — Gilberto Lyons (JavaFixing Admin)
Если Hadoop завершил нормальный запуск, мы должны увидеть следующие пять процессов с JPS:
NameNode、SecondaryNameNode、DataNode、NodeManager、ResourceManager
Но нашел NodeManager, ResourceManager, эти два процесса не пришли.
Просмотр журналов нашел следующую ошибку:
Caused by: java.lang.NoClassDefFoundError: javax/activation/DataSource
Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource
Есть несколько решений:
1. Переустановите JDK, используйте версию версии 1.8.
2. Методы, предоставленные онлайн: изменить Yarn-env.sh, добавьте следующий контент (я пытаюсь его использовать »:
export YARN_RESOURCEMANAGER_OPTS="--add-modules=ALL-SYSTEM"
export YARN_NODEMANAGER_OPTS="--add-modules=ALL-SYSTEM"
3, загрузите Activation-1.1.1.jar в каталог lib или загрузите его на $ {hadoop_home} / Share / hadoop / lib / lib каталог, перезапустить start-ynarn.sh:
cd ${HADOOP_HOME}/share/hadoop/yarn/lib
wget https://repo1.maven.org/maven2/javax/activation/activation/1.1.1/activation-1.1.1.jar