How to resolve reference to twirl generated template class in Scala-IDE? - scala

Using twirl for generating template class. Everything is working fine with sbt and the webpages are rendering.
I am using Scala-IDE for development. And in the Scala-IDE the reference to the template class i.e. "html.test()", test is the template name, is showing as an error.
This is the error:
Description Resource Path Location Type
missing or invalid dependency detected while loading class file 'test.class'.
Could not access term api in value .twirl, because it (or its dependencies) are missing.
Check your build definition for missing or conflicting dependencies. (Re-run with -Ylog-classpath to see the problematic classpath.) A full rebuild may help if 'test.class' was compiled against an incompatible version of .twirl. ApiService.scala /api/src/main/scala/com/komma/api/rest line 97 Scala Problem.
I did a clean and it is giving "not found: value html" error now.
Is there any way to resolve this error in the scala IDE ?
Thanks.

Re-running sbt eclipse added target/scala-2.11/twirl/main as a source folder which resolved the compilation errors for me.

For my twirl configuration, sbt eclipse did not add the twirl output directory as a source folder. Adding
target/scala-2.11/twirl/main to the eclipse project build path through the Add Folder button, under Java Build Path, by hand, was my solution.

Related

scalac: missing or invalid dependency detected while loading class file 'CassandraSession.class'

I've been developing in Javadsl with Maven, but I haven't been able to compile the project in my intellij 2016 since I added Scaladsl libraries.
This is the error I am getting:
Error:scalac: missing or invalid dependency detected while loading
class file 'CassandraSession.class'. Could not access term session in
package akka.persistence.cassandra, because it (or its dependencies)
are missing. Check your build definition for missing or conflicting
dependencies. (Re-run with -Ylog-classpath to see the problematic
classpath.) A full rebuild may help if 'CassandraSession.class' was
compiled against an incompatible version of
akka.persistence.cassandra.
I tried the followings:
Invalidate Cache and Restart the Intellij
Maven Clean Install (failed)
Restart the PC
None of them worked.
Does anyone know how to fix this problem?
This is my POM.xml for the module which I am using both Scaladsl and Javadsl.
Thanks!

"Cannot be resolved to a type" after upgrading to GWT 2.7. and trying to compile a multi-project module

I´ve been having trouble getting the Super-Dev-Mode to work with GWT 2.7. and GXT 3.1.x The classical Dev-Mode starts without trouble, but the Super-Dev-Mode and GWT-compile the project won`t work.
I am currently working with Eclipse 4.4.2 with Java 1.7_2 on Windows.
So let´s pretend we have 2 GWT/GXT projects (no Maven) with GWT 2.6 and GXT 3.1.x (Projects are backuped on a repository).
One is called A and the other project is called B. Project A has many packages and no entrypoint (to just work as a library/framework), just an abstract entrypoint every other project has to extend. The other one is called B and inherits from A, the entrypoint extends the entrypoint of A.
When starting the project under GWT 2.6 in classical Dev-Mode the project works fine. When upgrading to GWT 2.7. it will work fine with the classical Dev-Mode, an even in Super-Dev-Mode the Codeserver starts to run, but when compiling the module i get an error that some code seems not to live under a package 'client' so i migrated it into a own package and added the sourcepath to the A.gwt.xml.
After fixing this error and starting the Super-Dev-Mode again (and when trying to GWT-compile) I get errors like this:
Ignored 15 units with compilation errors in first pass.
Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
Finding entry point classes
Tracing compile failure path for type 'com.example.b.client.B'
[ERROR] Errors in 'file:/C:/Workspace/ProjectB/src/com/example/b/client/B.java'
[ERROR] com.example.a.client.A cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/view/ExampleLayout.java'
[ERROR] com.example.a.view.ILayout cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/client/service/ExampleServiceAsync.java'
[ERROR] com.example.a.model.Examplemodel cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectA/src/com/example/a/model/OtherExampleModel.java'
[ERROR] com.example.a.hibernate.model.ComOtherExampleModel cannot be resolved to a type
[ERROR] Errors in 'file:/C:/Workspace/ProjectB/src/com/example/b/client/service/OtherExampleServiceAsync.java'
[ERROR] com.example.a.model.NewExampleModel cannot be resolved to a type
...
(and many more)
Project A is included in the buildpath of the project B, when creating a custom run configuration where the project is added to "user entries" and adding source folders to "user" entries wont work. For the custom run configuration i used something like the following arguments:
"-src src/ -src ${workspace_loc:ProjectA} com.example.b.B"
And even:
"-src src/ -src ${workspace_loc:ProjectA} com.example.b.B com.example.a.A"
I widely searched for solutions and even tried to set up the workspace again, checkout the projects from the repository again, organize imports and even adding every package to the buildpath of A.
I also tried to add this to the .gwt.xml files didn´t work:
<add-linker name="xsiframe"/>
How can I solve the "cannot be resolved to a type" error?
I would really appreciate every form of help to get this problem done! Thanks!
One possible problem could be your version of GXT. If you are using GXT 3.1.1 (which was the latest GPL-release), then you can not use GWT 2.7.0.
Take a look at the version table:
GXT versions
As you can see, Sencha GXT 3.1.1 does not support GWT 2.7.0. The first GXT release which will support GWT 2.7.0 is GXT 3.1.2.

build paths eclipse java j2ee

I have imported a project (I am very new at this) and I get the following errors:
Project cannot be built until build path errors are resolved
Project FST is missing required library: 'C:program Files/Apache Group/Tomcat 4.1/common/lib/servlet.jar'
Project FST is missing required library: 'C:program Files/Apache Group/Tomcat 4.1/common/lib/struts.jar'
The project cannot be built until build path errors are resolved
Unbound classpath variable: 'TOMCAT_HOME/common/lib/jasper-runtime.jar' in project
Unbound classpath variable: 'TOMCAT_HOME' in project FST
I create a variable called TOMCAT_HOME and give it the proper directory ,but Also, we should change the project classpath to use TOMCAT_HOME rather than the absolute path.
i dont know how to do it (change the project classpath and the absolute path)
thanks !
To answer somewhat indirectly, if you configure your project build with something like Maven or Gradle, so that you can successfully build the project using the corresponding command-line tool, then it should be quite straightforward to import the project into eclipse using the Maven or Gradle eclipse plugin. I think doing so will be worth whatever trouble it causes you in the short run--just take care to make your project structure conform to the usual project structure that Maven expects or you'll be asking for trouble (it should be no problem to do so for greenfield work).

scala & intellij : difficulties to create a runnnable jar

I can't launch a scala jar; when I launch it I get the error "Exception in thread "main" java.lang.NoClassDefFoundError: scala/collection/immutable/List" which seems to mean the scala library is not loaded...
this is a screenshot showing a lot of informations on the artifact window.
here is the manifest:
Manifest-Version: 1.0
Class-Path: libs/scala-library-2.10.0.jar libs/commons-logging-1.1.1.j
ar libs/jcip-annotations-1.0.jar libs/jwnl-1.4_rc3.jar libs/laf-plugi
n-7.2.1.jar libs/laf-widget-7.2.1.jar libs/miglayout-core-4.2.jar lib
s/miglayout-swing-4.2.jar libs/scala-actors.jar libs/scala-library.ja
r libs/scala-swing.jar libs/slf4j-api-1.6.4.jar libs/slick_2.10-1.0.0
.jar libs/sqlite-jdbc-3.7.2.jar libs/substance-7.2.1.jar libs/trident
-7.2.1-swing.jar
Main-Class: Fenetre
and when I enter "java xf myJar.jar", there are extracted files in the directory:
- .class files
- in the libs folder, there are the libraries INCLUDING scala-library.jar & scala-library-2.10.0.jar(I specified only one of these two files in the manifest to avoid conflicts)
can you help me?
I'm new to Scala and don't know what the problem is however I've been compiling "fat jars" which include all the required libs.
I've been using https://github.com/sbt/sbt-assembly to do this successfully.
Despite what your manifest is telling you, when you run the application you either do not have the scala-library included in your class path or there's some confusion when you attempt to import List. Scala should automatically import the immutable collection classes in your project with the root Predef implementation.
Predef provides type aliases for types which are commonly used, such as the immutable collection types scala.collection.immutable.Map, scala.collection.immutable.Set, and the scala.collection.immutable.List constructors (scala.collection.immutable.:: and scala.collection.immutable.Nil). The types Pair (a scala.Tuple2) and Triple (a scala.Tuple3), with simple constructors, are also provided.
Predef in core Scaladocs
Try printing the classpath from within your app to confirm.
Although not pertinent to your question, I would recommend using SBT for dependency management now that IntelliJ IDEA 13 has full SBT integration support. Your collaborators not using IntelliJ will also be happier because SBT gives them more options for build technologies, editors, and other tooling when working on the project.

import lift mapper caught an error missing jar file

hi im creating a lift scala application
this is my problem
when i import net.liftweb.mapper._ package the compiler gives me error...
i tried to add lift-mapper_2.9.1-2.4-M4.jar jar file to build path ,but the error exists..!
the compiler shows..
bad symbolic reference. A signature in package.class refers to term db in package net.liftweb which is not available. It may be completely missing from
the current classpath, or the version on the classpath might be incompatible with the version used when compiling package.class.
Try to add the mapper via SBT or maven configuration?
Anyway, Scala-2.9.1 and Lift 2.4-M4 are very-very out of date. Better use something like that for a good start: https://github.com/lift/lift_25_sbt/
It works out of the box, and you'll only have to add 1 line to add the mapper support for it. (After that, all dependencies would be downloaded and added to the project automatically, by SBT.)