Eclipse error - Cannot be resolved to type - eclipse

Created a Maven Project and have set the dependencies in the pom.xml. The import statement (com.splunk.*) seems to recognize the library included in the Maven Dependencies, however when I refer to the class (for e.g. ResultsReaderXml) within that library, it shows the "error message cannot be resolved to type". Can some please explain why Spring Tool Suite (Eclipse) is doing that?
https://i.stack.imgur.com/enCRW.png

Related

Liquibase resource found in both Maven target and Maven repository

I have Eclipse Maven GWT project and I added flowable-form-engine dependency that uses Liquibase. Liquibase is searching for changelog file org/flowable/form/db/liquibase/flowable-form-db-changelog.xml but finds two!
org.flowable.common.engine.api.FlowableException: Error initialising form data schema
at org.flowable.form.engine.impl.db.FormDbSchemaManager.initSchema(FormDbSchemaManager.java:58)
at org.flowable.form.engine.impl.cmd.SchemaOperationsFormEngineBuild.execute(SchemaOperationsFormEngineBuild.java:29)
at org.flowable.form.engine.impl.cmd.SchemaOperationsFormEngineBuild.execute(SchemaOperationsFormEngineBuild.java:24)
at org.flowable.common.engine.impl.interceptor.DefaultCommandInvoker.execute(DefaultCommandInvoker.java:10)
at org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor.execute(TransactionContextInterceptor.java:53)
at org.flowable.common.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:71)
at org.flowable.common.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:30)
at org.flowable.common.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:56)
at org.flowable.form.engine.impl.FormEngineImpl.<init>(FormEngineImpl.java:45)
at org.flowable.form.engine.FormEngineConfiguration.buildFormEngine(FormEngineConfiguration.java:172)
at org.flowable.form.engine.configurator.FormEngineConfigurator.initFormEngine(FormEngineConfigurator.java:83)
at org.flowable.form.engine.configurator.FormEngineConfigurator.configure(FormEngineConfigurator.java:63)
at org.flowable.common.engine.impl.AbstractEngineConfiguration.configuratorsAfterInit(AbstractEngineConfiguration.java:859)
at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.init(ProcessEngineConfigurationImpl.java:985)
at org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl.buildProcessEngine(ProcessEngineConfigurationImpl.java:887)
at sk.dominanz.coarui.server.services.WorkflowServiceAdditional.<clinit>(WorkflowServiceAdditional.java:64)
... 33 more
Caused by: liquibase.exception.ChangeLogParseException: Error Reading Migration File: Found 2 files that match org/flowable/form/db/liquibase/flowable-form-db-changelog.xml
at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:118)
at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:15)
at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:217)
at liquibase.Liquibase.update(Liquibase.java:190)
at liquibase.Liquibase.update(Liquibase.java:179)
at liquibase.Liquibase.update(Liquibase.java:175)
at liquibase.Liquibase.update(Liquibase.java:168)
at org.flowable.form.engine.impl.db.FormDbSchemaManager.initSchema(FormDbSchemaManager.java:52)
... 48 more
Caused by: java.io.IOException: Found 2 files that match org/flowable/form/db/liquibase/flowable-form-db-changelog.xml
at liquibase.util.StreamUtil.singleInputStream(StreamUtil.java:206)
at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:71)
... 55 more
So I debugged it and it finds one resource from target directory:
jar:file:/C:/work/git/coarui/target/Main-1.0-SNAPSHOT/WEB-INF/lib/flowable-form-engine-6.4.0.jar!/org/flowable/form/db/liquibase/flowable-form-db-changelog.xml
and other resource from maven repository:
jar:file:/C:/Users/Piro/.m2/repository/org/flowable/flowable-form-engine/6.4.0/flowable-form-engine-6.4.0.jar!/org/flowable/form/db/liquibase/flowable-form-db-changelog.xml
Is there a way to ignore one of them, or is my build path or dependency definition wrong?
My build path contains:
src/main/java sources
src/test/java sources
JRE System library
Maven dependencies (in C:/Users/Piro/.m2/repository...)
JUnit4
Looking at source code resources are read classLoader.getResources(path); where class loader is jetty class loader JettyLauncher$WebAppContextWithReload$WebAppClassLoaderExtension.
In my run/debug configuration I have classpath similar to build path plus GWT library gwt-dev-2.8.1.jar - C:\Users\Piro\.m2\repository\com\google\gwt\gwt-dev\2.8.1
In pom.xml dependency is defined as:
<dependency>
<groupId>org.flowable</groupId>
<artifactId>flowable-form-engine-configurator</artifactId>
<version>${flowableVersion}</version>
</dependency>
Maven GWT plugin groupId=net.ltgt.gwt.maven, artifactId=gwt-maven-plugin has configuration parameter classpathScope but I tested <classpathScope>compile+runtime</classpathScope>, <classpathScope>compile</classpathScope> and <classpathScope>runtime</classpathScope> and the same error occurs.
Searching the internet I found similar posts on flowable forum (1, 2) but no solution is provided.
This generally happens when you mix client and server code in the same Maven module, and given how GWT works there's no (easy) around that, besides splitting your code in separate client and server (and possibly shared) Maven modules.
You can have a look at https://github.com/tbroyer/gwt-maven-archetypes for examples (disclaimer: I'm the author, but also a member of GWT's Steering Committee)
it seems that for some reason your .m2 is in the classpath. If it really makes sense to you then you can try to use <scope>provided</scope> in a pom where you declare dependency to flowable-form-engine-configurator. However you may decide to exclude .m2 from classpath which is better I think.

Imported library 'ExcelLibrary' contains no keywords

Have created maven project and done robot framework setup in eclipse using jython.
Getting "Imported library 'ExcelLibrary' contains no keywords." warning message while running the script and ExcelLibrary keywords have not been recognized.
Any help to resolve this issue?
Specifying the path of ExcelLibrary explicitly in the POM xml resolved this issue.
<extraPathDirectory>C:\Python\Python36-32\Lib\site-packages\ExcelLibrary</extraPathDirectory>

How do I find the correct Maven archetype project for developing with Scala in Eclipse?

I'm having problems trying to just create a Maven project using Scala (v2.11.6) within Eclipse (Luna). The instructions here says to install both plugins below.
Maven Integration in Eclipse
m2eclipse-scala connector
Both plugins can be installed by using the m2eclipse-scala update site. So here's what I did in my first attempt.
Download Eclipse Luna (for JavaEE developers)
Install "both" plugins above by using the m2eclipse-scala update site.
When Eclipse loads up, I attempt to create a Maven project, and the archetype I want to use is Group Id=net.alchim31.maven, Artifact Id=scala-archetype-simple, Version=1.5. However, this archetype never shows up when I enter in "scala-arch" in the filter text field.
The only project I see is the one with Group Id=org.scala-tools.archetypes, Artifact Id=scala-archetype-simple, Version=1.2. When I select this archetype to use, I get a bunch of error messages in Eclipse.
error while loading ConsoleRunner, Scala signature ConsoleRunner has wrong version expected: 5.0 found: 4.1 in ConsoleRunner.class
error while loading JUnit4, Scala signature JUnit4 has wrong version expected: 5.0 found: 4.1 in JUnit4.class
error while loading Specification, Scala signature Specification has wrong version expected: 5.0 found: 4.1 in Specification.class
In my second attempt, I try to download the pre-packaged bundle (Scala IDE for Eclipse). Again, when I attempt to create a Scala Maven project, I don't see the Maven archetype for Group Id=net.alchim31.maven (only for Group Id=org.scala-tools.archetypes).
Any ideas on what I'm doing wrong here? Or where I can find a vanilla Scala Maven project to import/modify and use for my own purpose?
Here's how I got it to work. It seems all the archetypes aren't available, so based on this answer, I created a remote catalog
Before
So do this
Go to [Windows] → [Preferences] → [Maven] → [Archetypes] → Add Remote Catalog and create the catalog, then Apply
For copy-pasting:
Catalog File: http://repo1.maven.org/maven2/archetype-catalog.xml
Description: Remote Archetypes
Go back to creating a new Maven project. Select the Remote Catalog from the dropdown. It will take a few moments to gather all the archetypes. You can see the progress at the very bottom right of the IDE. When it's done, you should be able to see the archetypes
After
Create your project with groupId and artifactId and such.
Right click the project, then from the context menu [Run As] &rarr [Maven Build]. In the dialog, type clean package into the goals. The run. The project should build and run the tests.
For me at first I got an error on the build. It was because my default environment is using Java 8. I'm pretty new to Scala, so I'm not sure is there is a problem with Scala and Java 8 or not (I think it's the Scala version in the pom (2.10.0)). But what I did to get it to work was just change the Java version used in the IDE to Java 7.
Basically just go to [Windows] → [Preferenes] → [Java] → [Installed JREs] → Add → [System VM] → Next → Directory → Find the directory of the Java home (version 7) → Finish → Then in the list tick Java 7.
Then build again. It should work. Good Luck!
One point I want to add, If you are getting following error while installing the archetype showed in image 1
Can't resolve Archetype
org.glassfish.jersey.archetypes:jersey-quickstart-webapp:2.21
org.eclipse.core.runtime.CoreException: Could not resolve artifact
org.glassfish.jersey.archetypes:jersey-quickstart-webapp:pom:2.21
Image 1:
Then before procedding with the solution specified above, try to complete these steps in eclipse.
I faced the same problem and chanced upon this SO question, as well as the answer, given by #peeskillet (many thanks). I am using:
Maven 3.3.3
Eclipse Luna Scala IDE 4.0.0.-vfinal-20150305-1644-Typesafe
Scala 2.11.6
JDK 1.8
After following the steps exactly as given here, I hit a wall. When I chose the right archetype (net.alchim31.maven), I was greeted with this error:
Could not resolve artifact net.alchim31.maven:scala-archetype-simple:pom:1.5
Suspecting that the maven embedded in eclipse was acting funny, I visited [Windows] -> [Maven] -> [Installations] and added local installation of maven (whatever is set to M2_HOME in my shell). But, no luck!
Exasperated, I visited this site: Scala Doc and switched back to command-line as this page instructs. Surprisingly (to me, at least), it worked. A maven-Scala project was created in the present directory, which I could import into Eclipse.
Just so that I am not misunderstood, I am not suggesting that #peeskillet's answer is wrong. Just wanted to share another way of creating a maven-scala project on Eclipse, in case it helps someone. I have not yet understood, why Eclipse-Scala-IDE is yet to give that 'Aha' feeling.
After you have successfully created the scala-maven project as described above, you will probably see an error "Type not found: type JUnitRunner specs.scala". In that case, manually add the following XML snippet to your pom.
<dependency>
<groupId>org.specs2</groupId>
<artifactId>specs2-junit_${scala.compat.version}</artifactId>
<version>2.4.16</version>
<scope>test</scope>
</dependency>
Moreover, to avoid errors when running mvn test,
[ERROR] scalac error: bad option: '-make:transitive'
You also need to delete the following line from the pom.xml file:
<arg>-make:transitive</arg>

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

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.

Unable to generate metamodel definitions using DataNucleus JPACriteriaProcessor from Eclipse

I'm trying to generate the metamodel definitions in Eclipse as documented on:
http://www.datanucleus.org/products/accessplatform/jpa/jpql_criteria.html
My project compiler level is set to 1.6 and the mentioned datanucleus jars are added to the factory path.
When the project builds I get the following error:
Errors occurred during the build.
Errors running builder 'Java Builder' on project 'X'.
Could not initialize class org.datanucleus.jpa.query.JPACriteriaProcessor
When using mvn compile the metamodel definitions are generated successfully, so it's probably related to Eclipse annnotation processing.
I'm using latest Spring Tool Suite 3.1.0.RELEASE based on Eclipse 4.2.1
Not put persistence-api.jar (or equivalent, such as Geronimo specs JPA2) in the Factory Path? Either way one of the deps is missing