Fitnesse java.lang.NoClassDefFoundError: javax/faces/validator/ValidatorException - java

I am trying to test java methods within a multiple package project that has numerous imports. It works fine until it gets to the javax imports. Tnen it complains that it cannot find the class definition for this import. Do I need to explicitly import a jar even though it was part of the maven dependencies when I complied the jars that this project is using?
This is the declarations section of my code package
package com.fietrade.swtf.swreconcilation.beans;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import javax.faces.application.FacesMessage;
import javax.faces.application.ViewHandler;
import javax.faces.component.UIComponent;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import javax.faces.validator.ValidatorException;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.xml.sax.SAXException;
import com.fietrade.swtf.persistance.factories.DBMgrFactory;
import com.fietrade.swtf.persistance.factories.ReconciliationDBMgr;
import com.fietrade.swtf.persistance.swapswire.Reconciliation;
public class ReconciliationEditor {
And this is the error:
__EXCEPTION__:java.lang.NoClassDefFoundError: javax/faces/validator/ValidatorException
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_40]
at java.lang.Class.forName(Class.java:190) [rt.jar:1.7.0_40]
at fitnesse.slim.SlimExecutionContext.getClass(SlimExecutionContext.java:139) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimExecutionContext.searchPathsForClass(SlimExecutionContext.java:129) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimExecutionContext.createInstanceOfConstructor(SlimExecutionContext.java:100) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimExecutionContext.create(SlimExecutionContext.java:42) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.StatementExecutor.create(StatementExecutor.java:75) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.instructions.MakeInstruction.executeInternal(MakeInstruction.java:26) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.instructions.Instruction.execute(Instruction.java:30) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.ListExecutor$Executive.executeStatement(ListExecutor.java:50) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.ListExecutor$Executive.executeStatements(ListExecutor.java:44) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.ListExecutor.execute(ListExecutor.java:84) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:106) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimServer.processTheInstructions(SlimServer.java:93) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:68) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:54) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimServer.serve(SlimServer.java:40) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimService.handle(SlimService.java:164) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimService.acceptOne(SlimService.java:172) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimService.accept(SlimService.java:134) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimService.startWithFactory(SlimService.java:65) [fitnesse-standalone-20140903.jar]
at fitnesse.slim.SlimService.main(SlimService.java:51) [fitnesse-standalone-20140903.jar]
Caused by: java.lang.ClassNotFoundException: javax.faces.validator.ValidatorException
Can someone explain what this error is and how to resolve it?
Thanks

Basically it says It is not able to find a dependancy for your project to work ..
include jsf-api
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.1</version>
</dependency>
Add this to your project and error will be resolved.

Related

The type java.sql.SQLException cannot be resolved. It is indirectly referenced from required type com.alibaba.druid.pool.DruidDataSource

package com.test.redis.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import javax.sql.DataSource;
import java.sql.SQLException;
IDEA SpringTooSuit4, maven pom.xml config jpa.
javax.sql.DataSource,java.sql.SQLException can not be resolved.
no idea ............
expect import success
try to import this maven library
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.32</version>
</dependency>
it should be jre compatibility issue, jre1.8 is ok

The import org cannot be resolved (under eclipse)

I use eclipese 2018-09 (4.9.0) I'm try to use jfreechart, I added the jars in the module path(jcommon,jfreechart), I do organize import
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.util.Rotation;
i get "The import org.jfree.chart cannot be resolved" for all imports and the consequential errors, what's the problem?Thanks

Failing JUnit tests for embedded Fongo DB

I have a Spring Boot application which use MongoDB. I would like to use the embedded FongoDB for my JUnit tests. I follow some articles, for example:
http://dontpanic.42.nl/2015/02/in-memory-mongodb-for-unit-and.html
My Fongo test configuration looks like
package com.myproject.rest;
import com.github.fakemongo.Fongo;
import com.mongodb.Mongo;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
#Profile("test")
#ComponentScan(basePackages = "com.myproject.service.data")
#EnableMongoRepositories(basePackages = "com.myproject.service.data.repository")
#Configuration
public class MongoTestConfig extends AbstractMongoConfiguration {
#Override
protected String getDatabaseName() {
return "demo-test";
}
#Bean
#Override
public Mongo mongo() {
return new Fongo("mongo-test").getMongo();
}
}
I have this dependency for that:
<dependency>
<groupId>com.github.fakemongo</groupId>
<artifactId>fongo</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
I would like to test my services which autowired a repository interface which extends MongoRepository
package com.myproject.service.data.repository;
import com.myproject.service.data.entity.JournalData;
import org.springframework.data.mongodb.repository.MongoRepository;
import java.util.List;
public interface JournalRepository extends MongoRepository<JournalData, String> {
#Override
public List<JournalData> findAll(Iterable<String> ids);
}
My tests class are inherited from the class below:
package com.myproject.rest;
import com.lordofthejars.nosqlunit.mongodb.MongoDbRule;
import cz.csas.services.commons.api.RequestMetadata;
import org.junit.Before;
import org.junit.Rule;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTest;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.MockMvc;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mockStatic;
import static com.lordofthejars.nosqlunit.mongodb.MongoDbRule.MongoDbRuleBuilder.newMongoDbRule;
#RunWith(PowerMockRunner.class)
#PowerMockRunnerDelegate(SpringJUnit4ClassRunner.class)
#SpringBootTest
#AutoConfigureMockMvc
#PowerMockIgnore({"javax.xml.*", "org.xml.*", "org.w3c.*", "javax.management.*", "javax.net.ssl.*"})
#PrepareForTest({RequestMetadata.class})
#ActiveProfiles("test")
public class EndpointTestContext {
#Autowired
protected MockMvc mockMvc;
//#Rule
//public MongoDbRule mongoDbRule = newMongoDbRule().defaultSpringMongoDb("demo-test");
#Before
public void setup() {
mockStatic(RequestMetadata.class);
when(RequestMetadata.builder()).thenCallRealMethod();
RequestMetadata m = RequestMetadata.builder()
.workingMode("TEST")
.build();
when(RequestMetadata.getMetadata()).thenReturn(m);
}
}
But when I run the Maven tests I recieve the following:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.mongodb.MongoClientOptions
at com.mongodb.MockMongoClient.create(MockMongoClient.java:42)
at com.github.fakemongo.Fongo.createMongo(Fongo.java:175)
at com.github.fakemongo.Fongo.<init>(Fongo.java:88)
at com.github.fakemongo.Fongo.<init>(Fongo.java:75)
at com.github.fakemongo.Fongo.<init>(Fongo.java:67)
at com.myproject.rest.MongoTestConfig.mongo(MongoTestConfig.java:30)
at com.myproject.rest.MongoTestConfig$$EnhancerBySpringCGLIB$$bf18b1d4.CGLIB$mongo$1(<generated>)
at com.myproject.rest.MongoTestConfig$$EnhancerBySpringCGLIB$$bf18b1d4$$FastClassBySpringCGLIB$$3ab8bfd7.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
at com.myproject.rest.MongoTestConfig$$EnhancerBySpringCGLIB$$bf18b1d4.mongo(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 115 common frames omitted
Can anyone suggest how to fix it? Thank you in advance.
Fongo can't find class from mongo-java-driver artifact. It declares
<!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.4.2</version>
</dependency>
as provided dependency. You should have mongo-java-driver on your test classpath. Most probably
<scope>runtime</scope>
or test will be enough for you.
Check if you have multiple version of mongo java driver (version conflicts). To check this, you can use mvn dependency tree to trace the path from where each jar is coming to your project.
mvn dependency:tree
Just need to find out the right version on mongo java driver and make sure you are not having version conflicts. I have used spring data and used fongo to write in-memory test case for mongodb queries.
<fongo-version>1.6.3</fongo-version>
<spring-data-mongodb-version>1.7.2.RELEASE</spring-data-mongodb-version>
<spring-framework-version>4.1.5.RELEASE</spring-framework-version>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${spring-data-mongodb-version}</version>
</dependency>
<dependency>
<groupId>com.github.fakemongo</groupId>
<artifactId>fongo</artifactId>
<version>${fongo-version}</version>
<scope>test</scope>
</dependency>
Version conflict can come from may source (can confirm using above mvc dependency:tree command, one such source is mongobee, so if you are using it, please exclude mongo-java-drive by using exclusion
<dependency>
<groupId>com.github.mongobee</groupId>
<artifactId>mongobee</artifactId>
<version>${mongobee-version}</version>
<exclusions>
<exclusion>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
</exclusion>
</exclusions>
</dependency>

Apache Ant: java.lang.ClassNotFoundException:

I am trying to run a selenium test case file written in java using Apache Ant. To setup this configuration, i followed this tutorial.
below is my ant config in build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="Hello World Project" default="info">
<target name="info">
<junit printsummary="yes" haltonfailure="yes">
<classpath>
<pathelement path="lib\junit-4.10.jar" />
</classpath>
<test name="com.lo.test.selenium.AssignCampaignTestCase" haltonfailure="no" outfile="result">
<formatter type="plain"/>
<formatter type="xml"/>
</test>
</junit>
</target>
</project>
But it is showing error like :
Testsuite: com.lo.test.selenium.AssignCampaignTestCase
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
Caused an ERROR
com.lo.test.selenium.AssignCampaignTestCase
java.lang.ClassNotFoundException: com.lo.test.selenium.AssignCampaignTestCase
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:270)
Test case code in AssignCampaignTestCase.java
package com.lo.test.selenium;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Properties;
import java.util.ResourceBundle;
import javax.mail.Flags;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.NoSuchProviderException;
import javax.mail.Session;
import javax.mail.Store;
import javax.ws.rs.core.MediaType;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
import com.sun.jersey.multipart.FormDataMultiPart;
import com.sun.jersey.multipart.impl.MultiPartWriter;
/**
* #author Ashutosh
*
*/
public class AssignCampaignTestCase {
private static ResourceBundle rb = ResourceBundle.getBundle("global-messages");
static WebDriver driver = new FirefoxDriver(); //Make it static in order to make one instance of this class(helps to avoid opening of 2 browsers at once)
#Test
public void campaignEmailTestCase() throws InterruptedException {
AssignCampaignTestCase emTesObj=new AssignCampaignTestCase();
// CommonMethods commonMethods=new CommonMethods();
String fName="test LO";
Integer LeadId=570903;
String campaignName="2GetMoreLeads";
String SubjName="Welcome to your 5-day challenge and tips"; //NOTE: No problem,Type without double quotes. It will work for you
doLogin(driver);
emTesObj.goToLeadsListPage();
emTesObj.searchByFirstName(fName);//without this also,it will work but Gives you the correct navigation on UI
emTesObj.waitBeforePageLoads(LeadId.toString()); //pass the Id attribute which you aspect to see after the page is loaded
emTesObj.assignCampaign(LeadId, campaignName);
emTesObj.readRecentEmail(SubjName);
}
//shows you the leads List Page
public void goToLeadsListPage(){
driver.get("http://www.xxxxx.com/orderManagement/xxxx.action");
}
.................
.................
.................
Here is my project structure::::
Please help me to run my project using Ant.
Try adding selenium jar file in you classpath. Currently you only added junit.

Cannot compile and run Android Market API

I am sorry for the very basic question but I feel truly lost here. What I am trying to do is to compile and run this code:
package com.gc.android.market.api;
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.io.InputStream;
import com.gc.android.market.api.MarketSession;
import com.gc.android.market.api.MarketSession.Callback;
import com.gc.android.market.api.model.Market.AppType;
import com.gc.android.market.api.model.Market.AppsRequest;
import com.gc.android.market.api.model.Market.AppsRequest.OrderType;
import com.gc.android.market.api.model.Market.AppsRequest.ViewType;
import com.gc.android.market.api.model.Market.AppsResponse;
import com.gc.android.market.api.model.Market.CommentsRequest;
import com.gc.android.market.api.model.Market.GetAssetResponse.InstallAsset;
import com.gc.android.market.api.model.Market.GetImageRequest;
import com.gc.android.market.api.model.Market.GetImageResponse;
import com.gc.android.market.api.model.Market.ResponseContext;
import com.gc.android.market.api.model.Market.GetImageRequest.AppImageUsage;
public class Fetcher
{
public static void main(String[] args) {
MarketSession session = new MarketSession(true);
System.out.println("Login:");
}
}
I am following the instructions from here: https://code.google.com/p/android-market-api/wiki/HowDownloadApps
The import and package lines I got from here: https://code.google.com/p/android-market-api/source/browse/trunk/AndroidMarketApi/src/com/gc/android/market/api/Main.java
I am doing this on OS X. In my current directory I have three files:
Fetcher.java (the code above)
AndroidMarketApi.jar
protobuf-java-2.2.0.jar
I compile using this command:
$ javac -classpath ".:/Users/ephracis/fetcher/*" Fetcher.java
I then try to run:
$ java Fetcher
Exception in thread "main" java.lang.NoClassDefFoundError: Fetcher (wrong name: com/gc/android/market/api/Fetcher)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
$ java com.gc.android.market.api.Fetcher
Exception in thread "main" java.lang.NoClassDefFoundError: com/gc/android/market/api/Fetcher
Caused by: java.lang.ClassNotFoundException: com.gc.android.market.api.Fetcher
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
I've also tried to add the classpath to the java command but it doesn't change anything.
To execute you need the fully qualified class name (package + class name). Try:
java -classpath ".:/Users/ephracis/fetcher/*" com.gc.android.market.api.Fetcher
Also, you still need to include the appropriate classes/jars on the classpath.

Categories