I have a webapp: grails + groovy + gradle (vscode 1.59 as editor)
I get these errors at runtime:
Caused by: java.lang.NoClassDefFoundError: org/jsoup/Jsoup
Caused by: java.lang.ClassNotFoundException: org.jsoup.Jsoup
build.gradle:
implementation 'org.jsoup:jsoup:1.13.1'
class file:
import org.apache.poi.ss.usermodel.*
import static org.apache.poi.ss.usermodel.Cell.*
import org.apache.poi.ss.usermodel.CellType
import java.io.File
import java.text.SimpleDateFormat
import groovy.sql.Sql
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.*
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
Error line:
Document doc = Jsoup.parse(file.getInputStream(), "UTF-8")
Things I tried (none worked):
Make a fat jar.
Disable gradle offline mode.
Copy jsoup jar to lib dir.
Any ideas?
Thanks a lot.
It seems like gradle files were corrupted.
I downloaded same version(5.1.1) for a "clean" install.
I set GRAILS_GRADLE_HOME system variable to the new clean gradle folder.
Now it works!
Related
I am following this tutorial.
I initialised my project and got the dependencies via
go mod init github.com/martin-helmich/kubernetes-crd-example
go get k8s.io/client-go#v0.17.0
go get k8s.io/apimachinery#v0.17.0
I have a Go file that uses import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1".
VS Code shows me could not import k8s.io/apimachinery/pkg/apis/meta/v1 (no required module provides package "k8s.io/apimachinery/pkg/apis/meta/v1"). What am I doing wrong here? Is my Go installation not correct?
I am getting the following error while running the maven command "mvn clean verify". I have placed the "feature" file at "C:/Users/304090/eclipse-workspace/evms-qa-testautomation/src/test/resources/". However, its unable to identify the file. Please suggest.
Apr 21, 2020 7:19:43 PM io.cucumber.core.runtime.FeaturePathFeatureSupplier get
WARNING: No features found at file:/C:/Users/304090/eclipse-workspace/evms-qa-testautomation/src/test/resources/
0 Scenarios
0 Steps
0m
0.000s
Folder structure:
check your test runner class where you have provided path to featch your feature files.currently its looking for C:/Users/304090/eclipse-workspace/evms-qa-testautomation/src/test/resources/ folder for a .feature files.
cucumber.api.CucumberOptions imports the #CucumberOptions annotation and it wwll tell where to look for feature files
You need to create features folder into the src/test/resources and past your .feature file in it. After that just update your runner class
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
#RunWith(Cucumber.class)
#CucumberOptions(
features = "src/test/resources/features/featurefileanme.feature",
glue={"path of glue package"}
)
public class TestRunner {
}
with serenity:
import cucumber.api.CucumberOptions;
import net.serenitybdd.cucumber.CucumberWithSerenity;
import org.junit.runner.RunWith;
#RunWith(CucumberWithSerenity.class)
#CucumberOptions(
features = "src/test/resources/CreatePreVioltReport.feature",
glue = "stepsDef"
)
public class RunTests {}
while i tried adding import config "./config" in main.go and try to save it and run then it remove the import config "./" section
my code structure is
-config/config.go
model/model.go
main.go
while running i got
[go] can't load package: package .: found packages config (config.go) and main (main.go) in /Users/Desktop/inventory-backend
In go we import modules by specifying the path as e.g.
import "gopath/projectName/config"
I have a generally understanding Problem with the Maven-Dependency in Grails 2.3.8.
I want to Import jsoup - functionality into my Project.
Therefore I did this in my BuildConfig.groovy:
dependencies {
.
.
/// jsoup
compile "org.jsoup:jsoup:1.7.3"
}
All is okay. Grails downloads the jar File into my local repo
C:\Users\xxx\.m2\repository\org\jsoup\jsoup\1.7.3
Now my confusion. I thougt all is done and i can write my code against Jsoup but this is wrong. I have to
copy the jar file into the Grails - lib Folder
set up the buildpath for Jsoup.jar
do a "grails compile"
Is this the right way? Why do i config dependencies when grails doesnt use them? It seems there is a plugin (compile ":html-cleaner:0.2") where Jsoup is included but when i need Jsoup i use Jsoup and not html-cleaner.
When i did this without my steps i got an Compiler Error:
package f
import grails.transaction.Transactional
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document
/***
*
* #author MG
*
*/
//#Transactional
class xyService {
def getXyFromIndex(String searchKeyword) {
def html = ""
Document doc = Jsoup.parse(html);
}
}
==> 'Groovy:unable to resolve class org.jsoup.nodes.Document' -GGTS 3.5.1
You don't need to copy jar it should automatically get copied either by ivy or maven. Maven is recommended so in BuildConfig.groovy change the resolver value to maven like below. Now when you start your application all jar will get copied to .m2 directory.
grails.project.dependency.resolver = "maven"
Did you try to import JSoup at the top of your file ?
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import org.jsoup.parser.Tag
#Transactional
class myClass {
}
Using Helios, spring 3.0.5 (TestContext Framework) and JUnit 4.7. I am getting an initialization error indicating that it cannot find the ContextConfiguration. I ran ProcMon in the background and determined it is not apparently looking at all. I have tried the logical locations for the xml file to no avail. I am unclear of what I am doing incorrectly. Here is the code:
package com.hwcs.veri.agg.dao;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractTransactionalJUnit4SpringContextTests;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;
import com.hwcs.veri.jpa.License;
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration(locations = { "/JpaIntegrationTests-context.xml" })
#TransactionConfiguration( transactionManager = "transactionManager",
defaultRollback = true )
#Transactional
public class JpaIntegrationTests
extends AbstractTransactionalJUnit4SpringContextTests
{
#Autowired
protected LicenseDao licenseDao;
#Test
public void getLicenses()
{
List<License> licenses = this.licenseDao.getLicenses();
assertEquals( "Expecting 1 license from the query",
super.countRowsInTable( "product_schema.license" ),
licenses.size() );
}
}
Is there some particular step that needs to be done to run this as a JUnit test inside Eclipse?
First and foremost, set the log level for org.springframework.test.context to DEBUG. That should tell you everything that the Spring TestContext Framework (TCF) is doing.
Note that with your above configuration, the TCF will attempt to load your application context from classpath:/JpaIntegrationTests-context.xml (i.e., in the root of your classpath). So make sure that the JpaIntegrationTests-context.xml file in fact exists in the root of the classpath (e.g., /src/test/resources/JpaIntegrationTests-context.xml for a Maven project layout). For the Maven project layout, you need to make sure that /src/test/resources is configured as a source folder in your IDE.
If this doesn't help you solve your problem, post the DEBUG output from the log.
Regards,
Sam (author of the Spring TestContext Framework)
Quoting Java Project: Failed to load ApplicationContext
"From the Sping-Documentation: A plain path, for example "context.xml", will be treated as a classpath resource from the same package in which the test class is defined. A path starting with a slash is treated as a fully qualified classpath location, for example "/org/example/config.xml".