When I changed from Hibernate to JDBI, and tried to launch my application, error below occured
java.lang.NoClassDefFoundError: io/dropwizard/jetty/RequestLogFactory
Stack trace says, that the cause of this problem is in my configuration class, at the class definition. But i have no idea what's wrong. Anyone had this problem?
MyConfiguration.java
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
public class MyConfiguration extends Configuration {
#JsonProperty
#NotNull
private DataSourceFactory database;
#JsonProperty
#NotEmpty
private String someString;
public DataSourceFactory getDataSourceFactory() {
return database;
}
public String getSomeString() {
return someString;
}
}
EDIT
I'm using dropwizard 1.0.0 and RequestLogFactory is neither in the given package nor Intellij couldn't find that class.
You aren't using the RequestLogFactory directly, but it seems one of the classes you're importing is and that jar needs to be present on your classpath for these classes you're importing to work appropriately at runtime. You should track down the jar which you need to include on your classpath that includes the RequestLogFactory class.
My best guess would be you're missing an import statement for the RequestLogFactory class:
import com.fasterxml.jackson.annotation.JsonProperty;
import io.dropwizard.Configuration;
import io.dropwizard.db.DataSourceFactory;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
You probably need to include:
import io.dropwizard.jetty.RequestLogFactory;
or simply (if you have more classes inside of jetty):
import io.dropwizard.jetty.*;
Related
I have the following code and it generate the
java.lang.NoSuchMethodError: com.misyn.aia.camb.coims.common.dto.ManageReportDto.setAgencyTotals(Ljava/util/List;)V
error ONLY AFTER DEPLOYED IN THE SERVER (openSUSE Leap v15.0/ java 1.8).
I run the same .jar in the local environment (Windows 10/ jave 1.8)
and it works fine.
All other dtos with lombok annotated also works perfectly fine.
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
#Setter
#Getter
#AllArgsConstructor
#NoArgsConstructor
public class ManageReportDto implements Serializable {
private String row;
private String total;
private List<String> agencyTotals = new ArrayList<>();
private List<String> bancaTotals = new ArrayList<>();
private String percentage;
private List<String> courier = new ArrayList<>();
}
project versions is as,
maven v3.6.3
spring boot v2.1.6
lombok v1.18.8
Compile your code and then use a decompiler to find out if your code has GETTER and SETTER methods.
JAVA decompiler: http://java-decompiler.github.io/
It will help you to find out if GETTER and SETTER methods were generated or not.
Also, you can refer to below stackoverlow link too in regards to your IDE configuration.
Lombok is not generating getter and setter
I have a class named "OrderBy" localized on package "br.com.petrobras.sddi.domain.".
Groovy has a class named "OrderBy" too, on package "groovy.util"
I have the class above:
//.. something
import br.com.petrobras.sddi.domain.*
// other imports
abstract class BaseJPARepository {
protected OrderSpecifier getSortedColumn(OrderBy order) {
//..something
}
}
When I compiled my program and open BaseJPARepository.class the imports contains
import br.com.petrobras.sddi.domain.FindAllPredicate;
import br.com.petrobras.sddi.domain.IEntity;
import br.com.petrobras.sddi.domain.PagedList;
import br.com.petrobras.sddi.domain.Pagination;
import com.querydsl.core.types.Order;
// others
import groovy.util.OrderBy;
// others...
So, when compiling, my class OrderBy wasn't imported.
How can I fix that? (I want to use the "*" when importing)
AFAIK, groovy loads all groovy.util.* and java.lang.* etc classes automatically. So, in order to be able to use your class you have to use it's full name in the code:
protected OrderSpecifier getSortedColumn( br.com.petrobras.sddi.domain.OrderBy order) {
//..something
}
I'm getting below 2 compilation errors in Eclipse but I'm not understanding what may be the root cause
import io.appium.java_client.AppiumDriver; //ERROR 1
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.MobileElement;
import org.openqa.selenium.WebElement;
public class AppiumDriver {
private AppiumDriver<MobileElement> driver = null; //ERROR 2
}
Error 1:
The import io.appium.java_client.AppiumDriver conflicts with a type defined in the same file
Error 2:
The type AppiumDriver is not generic; it cannot be parameterized with arguments
You should rename your own class from
public class AppiumDriver
to
public class CustomAppiumDriver
The compiler is reporting errors based on the same name class as you are trying to import. The other way to access the classes from appium lib would be somewhat like:
public class AppiumDriver {
private io.appium.java_client.AppiumDriver<MobileElement> driver = null;
}
The problem is that you can't import two classes with the same name or have import of class of the same name as your class in which this import is. Compiler won't know which class you wan't to use in that line. There are two solutions:
Rename your class to something like CustomAppiumDriver
Remove import and every time you want to use external class type te whole name with package name: io.appium.java_client.AppiumDriver
I'm using json4s in a play project, and I'm also using a library called sbt-buildinfo which generates Scala source from your build definitions.
Now, in the sbt-buildinfo library the say you need to add some line of code: buildInfoOptions += BuildInfoOption.ToJson so you can use .toJson, but from some reason I can use .toJson.
this is how I do it:
import _root_.util.{AuthenticatedAction}
import buildinfo.BuildInfo
import com.google.inject.Inject
import org.json4s.BuildInfo
import play.api._
import play.api.mvc._
class AppInfo #Inject()(implicit configuration: Configuration) extends Controller {
def appVerion = AuthenticatedAction {
Ok(BuildInfo.toJson)
}
but the import buildinfo.BuildInfo stays gray....so it looks like I'm not using it. I refreshed the build.sbt and all, what could it be?
You have multiple imports to a BuildInfo object. org.json4s.BuildInfo will probably shadow your buildInfo.BuildInfo import and therefore, it does not have the required member. Try writing out the entire package name that you need:
Ok(buildinfo.BuildInfo.toJson)
In a JAVA bean that I am working on I want to pass a NotesXspDocument (could use a NotesDocument) to a method which looks like this:
public List<String> getReaders(NotesXspDocument thisXspDoc){
// do some stuff
}
But JAVA does not recognize the NotesXspDocument definition. I have imported the following packages:
import lotus.domino.NotesException;
import lotus.domino.Session;
import lotus.domino.Database;
import lotus.domino.View;
import lotus.domino.Document;
Is there a further package to import to make use the NotesXspDocument?
To elaborate on Jesses answer: in your case you need to do this to work with the XPages version of Document:
import com.ibm.xsp.model.domino.wrapped.DominoDocument;
public List<String> getReaders(DominoDocument thisXspDoc){
// do some stuff
}
NotesXspDocument is an SSJS-only alias; the real class is com.ibm.xsp.model.domino.wrapped.DominoDocument: http://public.dhe.ibm.com/software/dw/lotus/Domino-Designer/JavaDocs/DesignerAPIs/com/ibm/xsp/model/domino/wrapped/DominoDocument.html