Missing Logger in classpath - scala

I try to compile a Scala library in Bazel. This leads to an error:
error: Symbol 'type <none>.slf4j.Logger' is missing from the classpath.
This symbol is required by 'value com.typesafe.scalalogging.slf4j.Logger.underlying'.
Make sure that type Logger is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'Logger.class' was compiled against an incompatible version of <none>.slf4j.
logger.warn("Foo")
^
one error found
one error found
java.lang.RuntimeException: Build failed
at io.bazel.rulesscala.scalac.ScalacProcessor.compileScalaSources(ScalacProcessor.java:256)
at io.bazel.rulesscala.scalac.ScalacProcessor.processRequest(ScalacProcessor.java:76)
at io.bazel.rulesscala.worker.GenericWorker.runPersistentWorker(GenericWorker.java:45)
at io.bazel.rulesscala.worker.GenericWorker.run(GenericWorker.java:111)
at io.bazel.rulesscala.scalac.ScalaCInvoker.main(ScalaCInvoker.java:41)
My BUILD.bazel looks like this:
load("#io_bazel_rules_scala//scala:scala.bzl", "scala_library")
scala_library(
name = "foo",
srcs = [
"src/main/scala/Foo.scala",
],
deps = [
"#maven//:com_fasterxml_jackson_core_jackson_core",
"#maven//:com_fasterxml_jackson_core_jackson_databind",
"#maven//:com_fasterxml_jackson_module_jackson_module_scala_2_11",
"#maven//:com_typesafe_scala_logging_scala_logging_api_2_11",
"#maven//:com_typesafe_scala_logging_scala_logging_slf4j_2_11",
"#maven//:joda_time_joda_time",
"#maven//:org_scalaj_scalaj_http_2_11",
],
)
From what I have read this error usually stems from mixing 2.x and 2.y Scala versions. I cannot for the live of me figure out where I would do this, though.

Had to add org.sonarsource.sonarlint.core:sonarlint-slf4j-sonar-log:4.8.0.14729 as a dependency because it wants org.slf4j.Logger.
Had to look at the sourcecode to find this:
import org.slf4j.{ LoggerFactory, Marker, Logger => Underlying }

Related

The compiler show error message when using ProjectExplorer in Eclipse Kpler

I use the following code in Kepler:
ProjectExplorer projExplorer = (ProjectExplorer) PlatformUI.getWorkbench().getActiveWorkbenchWindow().
getActivePage().findView(IPageLayout.ID_PROJECT_EXPLORER);
And I have added org.eclipse.ui.navigator.resources.jar, however, when I compile my project, it shows an error message:
The type org.eclipse.ui.navigator.CommonNavigator cannot be resolved. It is indirectly referenced from required .class
files
CommonNavigator is in the org.eclipse.ui.navigator plugin so add that to your plugin's dependencies.
If you check that jar # docjar : http://docjar.com/jar_detail/org.eclipse.ui.navigator.resources_3.3.100.I20080606-1300.jar.html, you'll find that CommonNavigator is not there.
You probably need this one: http://docjar.com/jar_detail/org.eclipse.ui.navigator_3.3.100.I20080606-1300.jar.html

Adding artifact to play project using SBT - Native Packager Plugin

I'm trying to add artifact to my play project, I've looked in couple of forums and looks like this is the proper way to do it:
lazy val playProject = play.Project(myProjectName, myProjectVersion, path = file("."))
.settings(addArtifact(Artifact (myProjectName, "dist", "zip"), dist).settings: _*)
but then I'm getting compilation error:
"...project/Build.scala:26: not found: value dist"
where I need to define it? what am I missing here?
additional info: my "playProject" is a module inside scala project that contain some other scala modules.
It is difficult to be sure with such a limited extract of your build definition, but my guess would be you are in a scala build file and didn't import the dist key in scope.
Try adding the following import to your build file
import com.typesafe.sbt.packager.universal.UniversalKeys.dist
addArtifact has the following signature :
def addArtifact(a : sbt.Artifact, taskDef : sbt.TaskKey[java.io.File])
UniversalKeys.dist is defined as follows:
val dist = TaskKey[File]("dist", "Creates the distribution packages.")
So the types are correct at least :)

Failed to resolve class via deferred binding

// ...some imports
public class Menu {
final MenuMaker myClass = GWT.create(MenuMaker.class); // ERROR
My ...gwt.xml:
...
<generate-with class="com.gwt.rebind.MenuGenerator">
<when-type-assignable class="com.gwt.client.MenuMaker" />
</generate-with>
...
All work perfectly when I run compile in DevMode but when I "Build the project with the GWT compiler" I get this error:
[ERROR] Line 15: Failed to resolve 'com.gwt.client.MenuMaker' via deferred binding
Scanning for additional dependencies: jar:file:/C:/eclipse/plugins/com.google.gwt.eclipse.sdkbundle_2.4.0.v201208080121-rel-r42/gwt-2.4.0/gwt-user.jar!/com/google/gwt/dom/client/DOMImpl.java
[WARN] For the following type(s), generated source was never committed (did you forget to call commit()?)
[WARN] com.gwt.client.MenuMakerGen
[ERROR] Cannot proceed due to previous errors
At the end of com.gwt.rebind.MenuGenerator:
sourceWriter.commit(logger);
Check if all your client classes have default, zero-parameter constructor. I had the same "deferred binding" issue, and it turned out that one of my classes hadn't had default constructor. It was strange, because this class wasn't even mentioned in GWT compiler log.
Check for gwt-compile problems. The message
[ERROR] Line 15: Failed to resolve '...' via deferred binding
can result from compile problems in your gwt code. In my case it was a class, which was only available on the server side of the application, but was referenced in a class belonging to 'shared' part of the application.
In Java it compiled well, so I had no error in eclipse. The above error-message only showed up when building it with maven. Still it remained somewhat difficult to find the real problem, as the message text was not very helpful.
It turned out, that running the app on com.google.gwt.dev.DevMode would produce a more detailed logfile of the gwt-compilation (probably one could configure maven to do the same?).
Right at the beginning of this more detailed log, there were entries, which pointed me to the problem described above. After correcting these problems, the "Failed to resolve ... via deferred binding"-error was gone.
Check your model/ Pojo Class should implements Serializable
interface and also
Class have default constructor(No argument constructor).
In my case, some of the model classes were not implementing com.google.gwt.user.client.rpc.IsSerializable, that's why I got the error mentioned in the question.
In my case, a key in Resource Bundle properties file which corresponds the method name was missing and the problem resolved after adding it.

play framework file missing needed by Diff

I get this error when trying to use the lift-json library with scala play: "The file could not be compiled. Error raised is : error while loading Diff, class file needed by Diff is missing. reference type Serializable of package scala refers to nonexisting symbol."
I added "- net.liftweb -> lift-json 2.9.0-1-2.4" in my dependencies.yml file. I'm not sure what's producing this error.
Do play dependencies --sync, and redo play netbeansify or play eclipsify.

GWT program run problem, please help GWT masters?

I try to run a example code from a book and it gives errors like:
[DEBUG] [rpc] - Validating newly compiled units
[ERROR] [rpc] - Errors in 'file:/D:/UserData/ge000001/workspace/RPC/src/rpc/client/HelloService.java'
[ERROR] [rpc] - Line 8: No source code is available for type rpc.server.Person; did you forget to inherit a required module?
[ERROR] [rpc] - Errors in 'file:/D:/UserData/ge000001/workspace/RPC/src/rpc/client/HelloServiceAsync.java'
[ERROR] [rpc] - Line 9: No source code is available for type rpc.server.Person; did you forget to inherit a required module?
[ERROR] [rpc] - Errors in 'file:/D:/UserData/ge000001/workspace/RPC/src/rpc/client/RPC.java'
[ERROR] [rpc] - Line 106: No source code is available for type rpc.server.Person; did you forget to inherit a required module?
[TRACE] [rpc] - Finding entry point classes
[ERROR] [rpc] - Unable to find type 'rpc.client.RPC'
[ERROR] [rpc] - Hint: Previous compiler errors may have made this type unavailable
[ERROR] [rpc] - Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly
[ERROR] [rpc] - Failed to load module 'rpc' from user agent 'Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1' at localhost:1802
these type errors occurs tomany times with tdifferent project and I cannot get the reason why?
Do you have any idea or suggestion?
It means that for some reason GWT cannot find a class you're including in your code.
These errors usually occurs, and can be quite confusing, when something is fundamentally wrong with the configuration; usually something small and silly that breaks everything.
As the error message suggest it may be because its not included using <inherits name="com.yourcompany.project.SomeClass"/> or because java cannot find it (it's in a different path and not in the classpath or something like that).
It could also be that the classes include other classes/packages that cannot be converted to GWT code, and is ignored by GWT (stuff not in the core java packages). (Also if you use eclipse: it has an annoying habit of automatically add java import statements for stuff you mistype, see the problems tab and see if there are unused imports. You may have to change the preferences; setting "Unused imports" to "Warning", if it's not on by default.)
Try commenting out some of the includes and recompile, it may narrow down where the problem is. Use an IDE like Eclipse, and see if it reports errors. (I cannot give you any more specific help with the current data)