I wrote a JAVA class in Eclipse:
package sample123;
public class sample2 {
}
Same way, I created a file in my GITHUB repository:
package sample123;
public class sample2 {
}
When I commit that JAVA class from eclipse to GITHUB:
How to solve this error in Eclipse?
Related
I ran into the following error after my .net core project and its dependencies to the latest framework version (version 6+) when I was running any CLI command (such as dotnet ef add for instance):
Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Storage. TypeMappingSourceDependencies' while attempting to activate 'MySql.EntityFrameworkCore.Storage.Internal. MySQLTypeMappingSource'.
I found this article which helped solved the issue: https://www.svrz.com/unable-to-resolve-service-for-type-microsoft-entityframeworkcore-storage-typemappingsourcedependencies/
Adding this class to the project:
public class MysqlEntityFrameworkDesignTimeServices : IDesignTimeServices
{
public void ConfigureDesignTimeServices(IServiceCollection serviceCollection)
{
serviceCollection.AddEntityFrameworkMySQL();
new EntityFrameworkRelationalDesignServicesBuilder(serviceCollection)
.TryAddCoreServices();
}
}
Adding this class solved for me.
i want to know that if "MethodOrderer" class is available in JUnit5 Library FOR ECLIPSE or not, because i am unable to find it.
If not, how can i shift jupiter.api_5.3.1 to jupiter.api_5.4.2 in eclipse JUnit5 library?
Will be thankful to see your reply.
I downloaded JUnit5 jar file from "https://search.maven.org/artifact/name.remal.tools.test/junit5/1.26.97/jar" and this jar does have "MethodOrderer" class but when i add this to project dependency and run the testclass, eclipse shows up this error "No tests found with test runner 'JUnit5'."
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
#TestMethodOrder(MethodOrderer.OrderAnnotation.class)
class JunitCalculatorV4 {
#BeforeAll
static void setUpBeforeClass() throws Exception {
System.out.println("Before All");
}
#AfterAll
static void tearDownAfterClass() throws Exception {
System.out.println("After All");
}
#Test
#Order(1)
void addTest() {
System.out.println("Add test");
}
#Test
#Order(2)
void divideTest() {
System.out.println("Divide Test");
}
}
Actually this annotation #TestMethodOrder(MethodOrderer.OrderAnnotation.class) is from jupiter.api_5.4.2 which i added as an external jar, and that might be causing conflict with the existing JUnit5 library.
My problem would be solved if the JUnit5 library is updated as a whole, or atleast the jarfile inside the library is updated.
Project > Properties: Java Build Path, tab Libraries:
You are using Eclipse 2018-12 (4.10) with JUnit 5.3.1 instead of Eclipse 2019-03 (4.11) with JUnit 5.4.0 (the screenshot shows JAR file names containing _5.3.1.v20181005- instead of _5.4.0.v20190212-).
Please upgrade.
Building on the example here: https://github.com/Pentadrago/spring-boot-example-wicket
And taking into account the jar-to-war guide here: https://spring.io/guides/gs/convert-jar-to-war/
I'd like to convert my existing Wicket + Spring (using data-jpa and security) to Spring Boot. It's been fairly easy to get the fat-jar setup to work, but it has so far proved impossible for me to convert this setup into a .war file to deploy in Tomcat.
The issue stems from the conflicting instructions to:
on the one hand extends org.springframework.boot.context.web.SpringBootServletInitializer from a non-#Configuration class for the jar-to-war conversion guide,
while on the other implements org.springframework.boot.context.embedded.ServletContextInitializer for a #Configuration marked class for the fat-jar Wicket example.
I've not been able to align the two such that I get a working application both when debugging with the embedded container, and when deployed as .war in Tomcat.
Can anyone tell me how I can setup a spring-boot enabled wicket application that I can deploy as a .war file?
What I did and got the application to work was the following:
I checked out the example project https://github.com/Pentadrago/spring-boot-example-wicket that you posted.
Then following the code on the https://spring.io/guides/gs/convert-jar-to-war/ guide all I did was to make the following changes:
Change build.gradle to:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.2.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'spring-boot'
apply plugin: 'war'
jar {
version = '0.0.1'
}
repositories {
mavenCentral()
}
configurations {
providedRuntime
}
dependencies {
compile(
"org.springframework.boot:spring-boot-starter",
"org.springframework.boot:spring-boot-starter-logging",
"org.springframework:spring-web:4.0.3.RELEASE",
"org.apache.wicket:wicket-spring:6.15.0",
)
testCompile(
"org.springframework.boot:spring-boot-starter-test",
)
providedRuntime("org.springframework.boot:spring-boot-starter-tomcat")
}
Add the following class:
HelloWebXml.java
package spring.boot.example.wicket;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
public class HelloWebXml extends SpringBootServletInitializer {
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(WicketWebApplication.class);
}
}
Those where the only changes I made and deployed to Tomcat 7 without any problems.
Here is the excerpt from the log that shows that wicked got started
2014-08-27 20:57:41.396 INFO 2708 --- [on(3)-127.0.0.1] org.apache.wicket.Application : [wicket-filter] init: Wicket core library initializer
I am not sure what your source of confusion is but you have to understand that SpringBootServletInitializer and ServletContextInitializer serve different purposes.
I am trying to connect my application with facebook. I copied the code from
http://spring.io/guides/gs/accessing-facebook/
Added all the stated dependencies but the error doesn't seem to go. Code given below screenshot attached. Can anyone suggest what might be the issue.
The error is #EnableInMemoryConnectionRepository cannot be resolved.
UserIdSource cannot be resolved.
package controllers;
import org.springframework.context.annotation.Bean;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.social.connect.web.ConnectController;
import org.springframework.social.facebook.config.annotation.EnableFacebook;
#EnableFacebook(appId="someAppId", appSecret="shhhhhh!!!")
#EnableInMemoryConnectionRepository
public class FacebookConfig {
#Bean
public ConnectController connectController(ConnectionFactoryLocator connectionFactoryLocator, ConnectionRepository connectionRepository) {
return new ConnectController(connectionFactoryLocator, connectionRepository);
}
#Bean
public UserIdSource userIdSource() {
return new UserIdSource() {
#Override
public String getUserId() {
return "testuser";
}
};
}
}
Try adding spring-social-config .jar file to your lib. This link will help you to download. Use spring-social-core-1.1.0.M4.jar instead of spring-social-core-1.0.0.Release.jar. Here, you can download from here
I found another way to fix this problem.
Clone the repo that site tell you to clone.
Import the project as existing maven project.
Then go to the .m2 folder and get all the jar file needed for this project
I've been trying for some time to learn Java EE but I could never run an EJB example. Oracle's guide uses netbeans but I must learn how to do it in Eclipse. Neither did books did any help or youtube videos.
I can run servlets, jsp, jsf without problems but I always had problems with EJBs. What am I missing?
The problem is configuration within Eclipse I think.
My Project Structure in Eclipse is the following:
The code of HelloWorld.java file:
package helloworld.ejb;
import javax.ejb.Remote;
#Remote
public interface HelloWorld {
public String outputHelloWorld();
}
Code of the HelloWorldBean.java file
package helloworld.ejb;
import javax.ejb.Stateless;
#Stateless
public class HelloWorldBean implements HelloWorld {
public String outputHelloWorld() {
return "Hello World!";
}
}
Code of the HelloWorldClient.java
package helloworldprojectclient;
import javax.ejb.EJB;
import helloworld.ejb.HelloWorld;
public class HelloWorldClient {
#EJB
private static HelloWorld helloWorld;
public static void main (String[] args) {
System.out.println(helloWorld.outputHelloWorld());
}
}
I am using Glassfish 4.0 as a server. The HelloWorldProject is an "EJB Project" while "helloworldprojectclient" is a regular Java Project and i've added javaee.jar (from the glassfish directory) to the buildpath.
When I try to run the HelloWorldClient.java I get the following exception:
Exception in thread "main" java.lang.NullPointerException
at helloworldprojectclient.HelloWorldClient.main(HelloWorldClient.java:10)
which is the following line: System.out.println(helloWorld.outputHelloWorld());
What is the problem? I mention i'm a total beginner at EJBs. Thank you!
Just in case you are still intrested in this:
The first version doesn´t work because you are trying to inject an ejb reference in a class that is not managed by a Container. When you execute the main method, the #EJB annotation is ignored, thus 'HelloWorld' class member is never initialized.
In order to execute this code without modification, you need execute the class in a Application Client Container that will inject the ejb reference.
Your second version runs because instead of to delegate to Container, you are getting the ejb reference through the JNDI service. This is the suggested way when Container injection is no available.
I've managed to make it work. I don't know if this is the correct way but in the "helloworldprojectclient" if you set the buildpath's Project tab and add HelloWorldProject then on the Libraries tab add appserv-rt.jar and javaee.jar (both from glassfish lib folder)
then the client should look like this:
package helloworldprojectclient;
import javax.naming.InitialContext;
import helloworld.ejb.HelloWorld;
public class HelloWorldClient {
public static void main(String[] args) {
try {
InitialContext ic = new InitialContext();
HelloWorld thing = (HelloWorld) ic.lookup("helloworld.ejb.HelloWorld");
System.out.println("It seems it runs: " + thing.outputHelloWorld());
} catch (Exception e) {
e.printStackTrace();
}
}
}