java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory [duplicate] - java

This question already has answers here:
java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
(2 answers)
How to fix ClassNotFoundException: org.apache.commons.logging.LogFactory?
(5 answers)
Closed 6 years ago.
I am trying to send a notification using this class FCMHelper and im getting errors
errors leading me to an error in httpclient
this is my code ...
public void send() throws IOException{
JsonObject notificationObject = new JsonObject();
notificationObject.addProperty("data", "hello");
notificationObject.addProperty("to", "dSvX_cWo5iY:A......QQT-bkb8x0VO");
FireBase firebase = FireBase.getInstance();
firebase.sendNotification("to", "condition", notificationObject);
}
i got this error
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1783)
at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1633)
... 58 more
what the problem here or if someone could give any other way to do it
.. thanks for your help

It seems "org/apache/commons/logging/LogFactory" is missed.
Have you imported the library?

Related

Beginner Selenium code not understanding the error it is throwing [duplicate]

This question already has answers here:
java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap error using GeckoDriver Firefox through Selenium in Java
(1 answer)
Selenium Webdriver + Java - Eclipse: java.lang.NoClassDefFoundError
(7 answers)
Closed 2 years ago.
Hi i'm rather new to selenium and understand the basics but cant understand why my basic code it just open a web page is throwing the error its throwing. The error its throwing ill be listed at the bottom.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Selenium1 {
public static void main(String[] args) {
WebDriver Driver = new ChromeDriver ();
String web = "https://www.facebook.com/";
Driver.get(web);
System.out.println(Driver.getTitle());
}
}
Exception in thread "main" java.lang.NoClassDefFoundError:
com/google/common/collect/ImmutableMap at
org.openqa.selenium.remote.service.DriverService$Builder.(DriverService.java:259)
at
org.openqa.selenium.chrome.ChromeDriverService$Builder.(ChromeDriverService.java:101)
at
org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
at
org.openqa.selenium.chrome.ChromeDriver.(ChromeDriver.java:123)
at Selenium1.main(Selenium1.java:10) Caused by:
java.lang.ClassNotFoundException:
com.google.common.collect.ImmutableMap at
java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
at
java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 5 more

Avoiding NoClassDefFoundError when using JavaMail [duplicate]

This question already has answers here:
Replacements for deprecated JPMS modules with Java EE APIs
(11 answers)
Closed 4 years ago.
I keep getting the NoClassDefFoundError error. I am trying to send an email using the JavaMail API, but the error occurs when I'm creating an instance of Message using the SMTPMessage class.
I know I need the activation library, but it still doesn't work.
By the way, I'm using JDK 10.
The error happens on the first line of this code.
#Override
public void sendEmail(Mail mail) throws MessagingException
{
Message message = new SMTPMessage(this.session);
message.setSubject(mail.getHeader());
message.setFrom(mail.getFrom());
message.setSentDate(mail.getDateClone());
if (mail.getSignature() != null)
message.setText(mail.getText() + "\n\n" + mail.getSignature());
else
message.setText(mail.getText());
Transport.send(message);
}
Stacktrace
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource
at martin.mail.EmailHandler.sendEmail(EmailHandler.java:79)
at martin.Main.main(Main.java:22)
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:190)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
... 2 more
Solution
Just add the activation library to your own class path. You can put it in your own package.

Multiple Jar file not found issues with IBM watson personality Insights

I'm writing a watson program to fetch personality traits. However, I'm running into errors with jar file issues.
import com.ibm.watson.developer_cloud.personality_insights.v3.PersonalityInsights;
import com.ibm.watson.developer_cloud.personality_insights.v3.model.Profile;
public JSONArray getPersonalityTraitsFromWatson(String text) {
JSONArray retval = null;
PersonalityInsights service = new PersonalityInsights("2016-10-20", "xxxx", "yyyy");
Profile response = service.getProfile(text).execute();
System.out.println("profile: " + response);
return retval;
}
The first problem is with okhttp3. I get a classnotfound error with JavaNetCookieJar. I'm currently using okhttp3 and javanetcookiejar is missing in it. I picked up the okhttp3 from MVNRepository.
Exception in thread "main" java.lang.NoClassDefFoundError: okhttp3/JavaNetCookieJar
at com.ibm.watson.developer_cloud.service.WatsonService.configureHttpClient(WatsonService.java:137)
at com.ibm.watson.developer_cloud.service.WatsonService.<init>(WatsonService.java:117)
at com.ibm.watson.developer_cloud.personality_insights.v3.PersonalityInsights.<init>(PersonalityInsights.java:52)
at com.ibm.watson.developer_cloud.personality_insights.v3.PersonalityInsights.<init>(PersonalityInsights.java:70)
at com.xyz.social.Watson.getPersonalityTraitsFromWatson(Watson.java:20)
at com.xyz.Testing.UnitTester.startUnitTest(UnitTester.java:1720)
at com.xyz.Testing.UnitTester.main(UnitTester.java:1850)
Caused by: java.lang.ClassNotFoundException: okhttp3.JavaNetCookieJar
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
I tried using "org.apache.servicemix.bundles.okhttp-3.2.0_1.jar" with and with the okhttp3.jar which clears the JavaNetCookieJar error but throws an SSLSocketFactory error (given below)
okhttp3.OkHttpClient$Builder.sslSocketFactory(Ljavax/net/ssl/SSLSocketFactory;Ljavax/net/ssl/X509TrustManager;)
Found the problem, the okhttp-urlconnection-3.8.1.jar & logging-interceptor-3.8.1.jar were required to be added. This fixed the problem.

Javafx NullPointerException when Playing Sounds [duplicate]

This question already has an answer here:
How do I determine the correct path for FXML files, CSS files, Images, and other resources needed by my JavaFX Application?
(1 answer)
Closed 2 years ago.
I am working on a Javafx game and have been attempting to implement some sound using the following code:
URL laserResource = getClass().getResource("LaserBlast.wav");
AudioClip laserPlayer = new AudioClip(laserResource.toString());
This code is instantiated in the main class before any methods. I have a module called JavaFxImages which contains all my resources including my sounds and I have been successfully able to access images for ImageView from the folder through code such as Image asteroid = new Image("Asteroid.png");.
However, when I run my game I get a NullPointerException at the line for my audio clip. I have spent the past many hours researching and trying every different way to access this resource. I've tried many permutations of the URL ("JavaFxImages/LaserBlast.wav", Desktop/JavaFxImages/LaserBlast.wav", etc.), but every time it has the same error. I'm really at a loss for what is wrong with the code. I would greatly appreciate any help that can be given.
Thanks in advance!
The full error message is given below.
Error Message:
Exception in Application constructor
Exception in thread "main" java.lang.RuntimeException: Unable to construct Application instance: class sample.Main
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:907)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$156(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:819)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Caused by: java.lang.NullPointerException
at sample.Main.<init>(Main.java:76)
... 10 more
Your error mostly happens on Itellij IDEA - Javafx Project
Instead of:
URL laserResource = getClass().getResource("LaserBlast.wav");
AudioClip laserPlayer = new AudioClip(laserResource.toString());
Use:
//By default your Package_NAME is: sample
File laserResource = new File("src/Package_NAME/LaserBlast.wav");
AudioClip laserPlayer = new AudioClip(laserResource.toURI().toString());

Infinispan MongoDb CacheStore Exception [duplicate]

This question already has an answer here:
Exception using mongodb as infinispan cache store
(1 answer)
Closed 8 years ago.
I want to use MongoDb as cachestore for Infinispan but getting following exception
It is different form the question Exception using mongodb as infinispan cache store
since the method b.loader() is not availabe in infinispan 7.0 jar i just figured out the turn around by using b.persistence.addStore() but still getting the exception as mentioned in the question
Code--
ConfigurationBuilder b = new ConfigurationBuilder();
b.loaders().addStore(
MongoDBCacheStoreConfigurationBuilder.class).host( "localhost" )
.port( 27017 )
.timeout( 1500 )
.acknowledgment( 0 )
.username( "mongoDBUSer" )
.password( "mongoBDPassword" )
.database( "infinispan_cachestore" )
.collection( "entries" );
final Configuration config = b.build();
MongoDBCacheStoreConfiguration store = (MongoDBCacheStoreConfiguration) config.loaders().cacheLoaders().get(0);
EmbeddedCacheManager cacheManager=new DefaultCacheManager();
cacheManager.defineConfiguration("usersCache", config);
//DefaultCacheManager manger=new DefaultCacheManager(config);
Cache<String, String> usersCache = cacheManager.getCache("usersCache");
Exception:--
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.infinispan.CacheException: Unable to invoke method public void org.infinispan.loaders.CacheLoaderManagerImpl.start() on object of type CacheLoaderManagerImpl
at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:207)
at org.infinispan.factories.AbstractComponentRegistry$PrioritizedMethod.invoke(AbstractComponentRegistry.java:889)
at org.infinispan.factories.AbstractComponentRegistry.invokeStartMethods(AbstractComponentRegistry.java:658)
at org.infinispan.factories.AbstractComponentRegistry.internalStart(AbstractComponentRegistry.java:647)
at org.infinispan.factories.AbstractComponentRegistry.start(AbstractComponentRegistry.java:550)
at org.infinispan.factories.ComponentRegistry.start(ComponentRegistry.java:221)
at org.infinispan.CacheImpl.start(CacheImpl.java:691)
at org.infinispan.manager.DefaultCacheManager.wireAndStartCache(DefaultCacheManager.java:685)
at org.infinispan.manager.DefaultCacheManager.createCache(DefaultCacheManager.java:648)
at org.infinispan.manager.DefaultCacheManager.getCache(DefaultCacheManager.java:544)
at com.infini.demo.DemoWithInfi5.main(DemoWithInfi5.java:31)
Caused by: org.infinispan.CacheException: Unable to start cache loaders
at org.infinispan.loaders.CacheLoaderManagerImpl.start(CacheLoaderManagerImpl.java:163)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.infinispan.util.ReflectionUtil.invokeAccessibly(ReflectionUtil.java:205)
... 10 more
Caused by: java.lang.IllegalArgumentException: Cannot load null class!
at org.infinispan.util.Util.getInstance(Util.java:224)
at org.infinispan.loaders.CacheLoaderManagerImpl.createCacheLoader(CacheLoaderManagerImpl.java:346)
at org.infinispan.loaders.CacheLoaderManagerImpl.createCacheLoader(CacheLoaderManagerImpl.java:336)
at org.infinispan.loaders.CacheLoaderManagerImpl.start(CacheLoaderManagerImpl.java:149)
... 15 more
Download infinispan-cachestore-mongodb-5.3.0.final.jar and import it into your project and be sure to import the package inside the class that uses it.

Categories

Resources