- Issue
- Solution
- Saved searches
- Use saved searches to filter your results more quickly
- Exception in thread «main» java.lang.NoClassDefFoundError: javax/activation/DataSource #81
- Exception in thread «main» java.lang.NoClassDefFoundError: javax/activation/DataSource #81
- Comments
- Saved searches
- Use saved searches to filter your results more quickly
- Generation of JAXB objects fails with NoClassDefFoundError: javax/activation/DataSource #245
- Generation of JAXB objects fails with NoClassDefFoundError: javax/activation/DataSource #245
- Comments
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:\Users\Admin\AppData\Local\NetBeans\Cache\12.0\executor-snippets\run.xml:111: The following error occurred while executing this line: C:\Users\Admin\AppData\Local\NetBeans\Cache\12.0\executor-snippets\run.xml:68: Java returned: 1 BUILD FAILED (total time: 0 seconds)
(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:
jakarta.activation jakarta.activation-api 2.0.1
And if you do that, you should also replace JavaMail classes too — for example, you can replace this:
import jakarta.mail.Message;
And use a Jakarta Mail resource, for example:
com.sun.mail jakarta.mail 2.0.1
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception in thread «main» java.lang.NoClassDefFoundError: javax/activation/DataSource #81
Exception in thread «main» java.lang.NoClassDefFoundError: javax/activation/DataSource #81
Comments
I get the following error:
Exception in thread «main» java.lang.NoClassDefFoundError: javax/activation/DataSource
java -jar node_modules/jsonix-schema-compiler/lib/jsonix-schema-compiler-full.jar -d mappings -p PO purchaseorder.xsd
I’m trying to get the examples working before I try real data. Any help would be greatly appreciated.
The text was updated successfully, but these errors were encountered:
I updated to java version «9»
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
and i’m now getting the following error:
Exception in thread «main» java.lang.Error: java.lang.reflect.InvocationTargetException
at com.sun.tools.xjc.reader.Ring.get(Ring.java:113)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.(BGMBuilder.java:147)
at com.sun.tools.xjc.reader.xmlschema.BGMBuilder.build(BGMBuilder.java:117)
at com.sun.tools.xjc.ModelLoader.annotateXMLSchema(ModelLoader.java:425)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:174)
at com.sun.tools.xjc.ModelLoader.load(ModelLoader.java:119)
at org.hisrc.jsonix.JsonixMain.execute(JsonixMain.java:99)
at org.hisrc.jsonix.JsonixMain.main(JsonixMain.java:77)
With Java 9 it’s probably the new module system which does not load javax.activation . I don’t have Java 9 experience yet so not sure how to fix this.
I just ran into the same issue. From java 9 on, jaxb (and some other JEE modules are not provided on the default classpath anymore. —add-modules java.xml.bind should do the trick.
java —add-modules java.xml.bind -jar node_modules/jsonix/lib/jsonix-schema-compiler-full.jar -d mappings -p PO purchaseorder.xsd
I tried adding —add-modules java.xml.bind like @henkesn directed but now I’m hit with this:
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.sun.xml.bind.v2.runtime.reflect.opt.Injector (file:/Users/ghdna/jsonix-schema-compiler-full-2.3.9.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int) WARNING: Please consider reporting this to the maintainers of com.sun.xml.bind.v2.runtime.reflect.opt.Injector WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release
P.S. The conversion still went through.
@ghdna thank you so much , that’s was helpfull for me . it work (y)
I tried running an Arabic tokenizer/diacritizer and got the same error message:
Exception in thread «main» java.lang.NoClassDefFoundError: javax/activation/DataSource
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.(RuntimeBuiltinLeafInfoImpl.java:461)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.(RuntimeTypeInfoSetImpl.java:65)
.
Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
.
I have limited experience in Java. As instructed by the developer, I entered the following line via the terminal:
java -Xmx2500m -Xms2500m -XX:NewRatio=3 -jar MADAMIRA-release-20170403-2.1.jar -rawinput samples/raw/SampleTextInput.txt -rawoutdir . -rawconfig samples/sampleConfigFile.xml
Can anyone let what could be the cause of this error and how to fix it?
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
athrane / pineapple Public archive
Generation of JAXB objects fails with NoClassDefFoundError: javax/activation/DataSource #245
Generation of JAXB objects fails with NoClassDefFoundError: javax/activation/DataSource #245
Comments
INFO] ------------------------------------------------------------------------ [INFO] Building Pineapple API project 1.11.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ pineapple-api --- [INFO] Deleting C:\Users\Thrane\git\pineapple\modules\pineapple-api\target [INFO] [INFO] --- cxf-xjc-plugin:3.2.1:xsdtojava (generate-sources) @ pineapple-api --- [WARNING] The POM for com.sun.xml.bind:jaxb-xjc:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [WARNING] The POM for com.sun.xml.bind:jaxb-impl:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [WARNING] The POM for com.sun.xml.bind:jaxb-core:jar:2.2.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details [ERROR] C:\Users\Thrane\git\pineapple\null [-1:-1]: Failed to create model com.sun.istack.SAXParseException2; Failed to create model at com.sun.tools.xjc.ErrorReceiver.error(ErrorReceiver.java:94) at org.apache.cxf.maven_plugin.XSDToJavaRunner.loadModel(XSDToJavaRunner.java:232) at org.apache.cxf.maven_plugin.XSDToJavaRunner.run(XSDToJavaRunner.java:168) at org.apache.cxf.maven_plugin.AbstractXSDToJavaMojo.run(AbstractXSDToJavaMojo.java:350) at org.apache.cxf.maven_plugin.AbstractXSDToJavaMojo.execute(AbstractXSDToJavaMojo.java:252) at org.apache.cxf.maven_plugin.XSDToJavaMojo.execute(XSDToJavaMojo.java:41) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288) at org.apache.maven.cli.MavenCli.main(MavenCli.java:199) 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:566) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: java.lang.reflect.InvocationTargetException 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:566) at org.apache.cxf.maven_plugin.XSDToJavaRunner.loadModel(XSDToJavaRunner.java:230) . 26 more Caused by: java.lang.NoClassDefFoundError: javax/activation/DataSource at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.(RuntimeBuiltinLeafInfoImpl.java:470) at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.(RuntimeTypeInfoSetImpl.java:63) at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:128) at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:84) at com.sun.xml.bind.v2.model.impl.ModelBuilder.(ModelBuilder.java:162) at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.(RuntimeModelBuilder.java:92) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:444) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:292) at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:139) at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1138) at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:162) 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:566) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:262) at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:249) at javax.xml.bind.ContextFinder.find(ContextFinder.java:456) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:656) at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:599) at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getCustomizationContext(BindInfo.java:336)
Resolved by adding a provided dependency to the project:
com.sun.activation javax.activation provided
The text was updated successfully, but these errors were encountered: