Closed nikkisingh111333 closed 5 years ago
If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample that reproduces the problem.
Okk I will send you code
On Wed, 11 Sep 2019, 11:10 a.m. Mark Paluch, notifications@github.com wrote:
If you would like us to spend some time helping you to diagnose the problem, please spend some time describing it and, ideally, providing a minimal sample https://stackoverflow.com/help/mcve that reproduces the problem.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/spring-projects/spring-data-r2dbc/issues/179?email_source=notifications&email_token=AL3BT7HJBG4KPAFQ24V7CE3QJCAGRA5CNFSM4IVLGEPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6NKH5Q#issuecomment-530228214, or mute the thread https://github.com/notifications/unsubscribe-auth/AL3BT7DV4TFKLOKLKSRWHVTQJCAGRANCNFSM4IVLGEPA .
hey there i m getting this error while starting and configuring springboot with r2bdc auto-configuration experimental: Description:
Field rr in GamOney2.GamOney2.H2controller required a bean named 'databaseClient' that could not be found.
The injection point has the following annotations:
Action:
Consider defining a bean named 'databaseClient' in your configuration. here what i have: `<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.8.BUILD-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>GamOney-2</groupId>
<artifactId>GamOney-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>GamOney-2</name>
<description>Demo project for Spring Boot</description>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
heres my connectionfactory `@Configuration public class PostgresConnection extends AbstractR2dbcConfiguration{
// @Bean
// public DatabaseClient db() {
//
// return DatabaseClient.create(conn);
// }
@Override @Bean
public ConnectionFactory connectionFactory() {
PostgresqlConnectionFactory h2c=new PostgresqlConnectionFactory(PostgresqlConnectionConfiguration.builder()
.schema("public")
.host("localhost")
.username("postgres")
.password("nikkibro0") //Recative method chaining for PostgresSQL DB connection and configuration
.port(5432)
.database("postgres")
.build());
R2dbcTransactionManager tm = new R2dbcTransactionManager(h2c);
//TransactionalOperator rxtx = TransactionalOperator.create(tm);
// ConnectionPool c=new ConnectionPool( ConnectionPoolConfiguration.builder(cf).maxAcquireTime(Duration.ofSeconds(1000)).initialSize(25).build());
// TODO Auto-generated method stub
return h2c;
}
heres my properties (please tell me if im wrong here): `server.port=8087 spring.h2.console.path=/h2-console spring.h2.console.enabled=true spring.h2.console.settings.trace=true
heres my table pojo and repository: `package GamOney2.GamOney2;
import java.util.List;
import org.springframework.data.r2dbc.repository.R2dbcRepository; import org.springframework.data.r2dbc.repository.query.Query; import org.springframework.data.repository.reactive.ReactiveCrudRepository; import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux; import reactor.core.publisher.Mono;
@Repository
public interface ReactiveREPO extends R2dbcRepository<testdb2,Long> {
@Query(value="select * from testdb2 where name=$1")
public Flux &
package GamOney2.GamOney2;
import javax.annotation.Generated;
import org.springframework.data.annotation.Id; import org.springframework.data.relational.core.mapping.Table;
import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.Getter; import lombok.Setter; @Builder @Data @Table("testdb2") public class testdb2 { @Id // @GeneratedStrategy() public Long id; public String name; public Long getId() { return id; }
public String getName() { return name.strip();//strip() will remove all the whitespaces '' from string and return it. } public void setId(Long id) { this.id=id; } public void setName(String name) { this.name=name; }
and heres my controller: `package GamOney2.GamOney2;
import java.util.ArrayList; import java.util.List; import java.util.Properties;
import org.reactivestreams.Publisher; import org.springframework.beans.factory.annotation.Autowired; //import org.springframework.data.r2dbc.function.DatabaseClient; import org.springframework.data.r2dbc.repository.support.SimpleR2dbcRepository; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.ModelAndView; import org.springframework.data.r2dbc.core.DatabaseClient; import org.springframework.data.r2dbc.core.TransactionalDatabaseClient;
import io.r2dbc.spi.Connection; import io.r2dbc.spi.ConnectionFactory; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono;
@RestController
public class H2controller {
@Autowired
ReactiveREPO rr;
@Autowired
ConnectionFactory conn;
@Autowired
H2repo hr;
@Autowired
DatabaseClient dc;
@GetMapping(value="/Set",produces=MediaType.APPLICATION_JSON_VALUE)
public Flux
Please refrain from pasting all code into the comment. The pasted code is unusable that way. Instead, please attach a zip file. Thank you.
GamOney2Application - Copy.TXT H2connection - Copy.TXT H2controller - Copy.txt PostgresConnection - Copy.TXT ReactiveREPO - Copy.TXT testdb2 - Copy.TXT PLZ SEE ABOVE FILES. HERES POM.XML
server.port=8087 spring.h2.console.path=/h2-console spring.h2.console.enabled=true spring.h2.console.settings.trace=true vaadin.compatibilityMode=true spring.r2dbc.url=r2dbc:postgresql://localhost:5432/postgres spring.r2dbc.username=postgres spring.r2dbc.password=nikkibro0 spring.r2dbc.name=mydatabase spring.r2dbc.initialization-mode=always spring.r2dbc.continue-on-error spring.r2dbc.generate-unique-name=true
ERROR REPORTING: FIRST ERROR IS: `Description:
Field rr in GamOney2.GamOney2.H2controller required a bean named 'databaseClient' that could not be found.
The injection point has the following annotations:
Action:
SECOND ERROR IS:
Caused by: java.lang.NoClassDefFoundError: org/springframework/transaction/reactive/AbstractReactiveTransactionManager at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na] at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016) ~[na:na] at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) ~[na:na] at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802) ~[na:na] at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700) ~[na:na] at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623) ~[na:na] at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) ~[na:na] at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na] at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na] at GamOney2.GamOney2.PostgresConnection.connectionFactory(PostgresConnection.java:47) ~[classes/:na] at GamOney2.GamOney2.PostgresConnection$$EnhancerBySpringCGLIB$$6f178af0.CGLIB$connectionFactory$0(<generated>) ~[classes/:na] at GamOney2.GamOney2.PostgresConnection$$EnhancerBySpringCGLIB$$6f178af0$$FastClassBySpringCGLIB$$136d6d0b.invoke(<generated>) ~[classes/:na] at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.9.RELEASE.jar:5.1.9.RELEASE] at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.9.RELEASE.jar:5.1.9.RELEASE] at GamOney2.GamOney2.PostgresConnection$$EnhancerBySpringCGLIB$$6f178af0.connectionFactory(<generated>) ~[classes/:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na] at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na] at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.9.RELEASE.jar:5.1.9.RELEASE] ... 146 common frames omitted Caused by: java.lang.ClassNotFoundException: org.springframework.transaction.reactive.AbstractReactiveTransactionManager
Thanks.
Please learn how to properly format code and logs.
Caused by: java.lang.NoClassDefFoundError: org/springframework/transaction/reactive/AbstractReactiveTransactionManager at
indicates that the used Spring Framework version isn't compatible with the one you're using. Please upgrade to Spring Framework 5.2 RC2 and Spring Data R2DBC 1.0.0.BUILD-SNAPSHOT.
thanks for your reply you saved my another day.and what about "couldn't resolve databaseClient dependency error "as i've described above as i have tried manually creating bean of databaseClient but didn't work. i think r2dbc is not stable yet for production . Am i right? but i really loved the concept and wanna continue r2dbc as it grows.
You should not immediately use it in production but for testing, it's perfectly suitable. The more folks test Spring Data R2DBC and R2DBC drivers, the more bugs we can catch and make it more stable.
as far as i know i ve already ugraded my spring framework .all spring core,context,aop,and other stuffs are operating at 5.1.9 release and as you said i ve updated r2dbc to 1.0.0 build snapshot.but the classnotfound reactivetransaction is not found error is still there what can i do ? how can i upgrade so that i can get rid of it.
as you describe upograding to springframework 5.2 RC2 i m unable to find it please specify where i can find it and use it. i have used spring r2dbc 1.0.0 M7 and it was working fine databaseclient was smooth but yesterday when i tried to enhanched r2dbc to 1.0.0 M2 with 0.8.0 M8 auto configuration accuator all started to messing up.
Description:
Field rr in GamOney2.GamOney2.H2controller required a bean named 'databaseClient' that could not be found.
The injection point has the following annotations:
Action:
Consider defining a bean named 'databaseClient' in your configuration.
Hello there,as i trying m working with new r2dbc release on my production project. there are several things i need to ask about: 1.please solve this error as i m completely new in r2dbc world i m using project database configurations based on application.properties configuration(as described in docs) and updated almost every dependency based on r2dbc if im missing something please let me know. 2.is it safe to implement this api into my production app NOW ?. beacuse i really like the concept of "subscribers and publishers" way of data fetching/inserting .
HERES MY DEPENDENCIES `<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
`