I am creating a new application for TomEE 9.0. I have a simple JPA application that needs to connect to the database. I get the following error:
Nov 17, 2021 10:51:22 AM jakarta.persistence.spi.PersistenceProviderResolverHolder$DefaultPersistenceProviderResolver log
WARNING: jakarta.persistence.spi::No valid providers found.
What must the provider in the persistence.xml be for TomEE 9.0-targeted projects?
As stated in a comment, you want to use EclipseLink as JPA Provider. The required provider class can be found in the documentation of Eclipse Link 3.0 and is
org.eclipse.persistence.jpa.PersistenceProvider
Therefore, you need to add the related dependency:
<!-- https://mvnrepository.com/artifact/org.eclipse.persistence/eclipselink -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>3.0.2</version>
</dependency>
In addition, you need to specific the JPA provider class via in your persistence.xml:
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
Related
I have the following in my pom, im not sure i need to have both of these. Since i get an error on application start up that only one SnsWebConfiguration.class bean can be registered. I recently upgraded the aws dependencies to 2.3
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-starter-aws</artifactId>
</dependency>
<dependency>
<groupId>io.awspring.cloud</groupId>
<artifactId>spring-cloud-starter-aws-messaging</artifactId>
</dependency>
error:
defined in class path resource [io/awspring/cloud/autoconfigure/messaging/SnsAutoConfiguration$SnsWebConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [io/awspring/cloud/messaging/config/annotation/SnsWebConfiguration.class] and overriding is disabled.\n\nAction:\n\nConsider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true\
So i found the problem. It was related to having #EnableX annotations from previous versions. Once i removed them, it started working fine.
I wrote a simple JAX-RS REST service (which is working as expected) and I'm trying to generate the OpenAPI documentation using microprofile. Therefore I added the following dependency to my pom.xml:
<dependency>
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-api</artifactId>
<version>2.0</version>
</dependency>
When I deploy the application on TomEE 9.0.0 M7 Microprofil everything works as expected and the OpenAPI schema is reachable under http://localhost:8080/openapi. But when I deploy the same artifact to TomEE 9.0.0. M7 Plume/Webprofile/Plus the schema / endpoint is not available. What am I missing here? Is this a configuration issue? According to https://www.tomitribe.com/blog/tomee-webprofile-vs-tomee-microprofile-vs-tomee-vs-tomee-plume/ MicroProfile should be part of the other distributions of TomEE too...
Thanks a lot!
Yes! MP implementation is available on the others TOMEE Profiles, but you will need to add a flag.
-Dtomee.mp.scan=all
if you are running it trough maven plugin you should put the flag like this.
<plugin>
<groupId>org.apache.tomee.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>${tomee.version}</version>
<configuration>
<context>ROOT</context>
<args>-Dtomee.mp.scan=all</args>
<tomeeVersion>${tomee.version}</tomeeVersion>
<tomeeClassifier>plus</tomeeClassifier>
</configuration>
</plugin>
I was following short tutorial on creating REST api using JAX-RS. I am using Tomcat server v7.0. When I run the application on the server I get error 404-requested resource is not available.
The project is Maven based, and my pom.xml file includes the following line
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
I do not have web.xml file as a result. That was how the tutorial was achieved. I do not have index.html/jsp file. I have created two classes RESTconfig.java and BookResources.java
...import statements
#ApplicationPath("api")
public class RESTconfig extends Application {
}
...import statements
#Path("books")
public class BookResources {
#GET
#Produces(MediaType.TEXT_PLAIN)
public String books() {
return "Hello world";
}
}
My pom.xml file looks like this
<groupId>com.dere</groupId>
<artifactId>myrest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<failOnMissingWebXml>false</failOnMissingWebXml>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
Once I run the application on the server and go to http://localhost:9090 I am able to see Tomcat home page, but if try to get data http://localhost:9090/myrest/api/books I get the 404 error, i.e requested resource is not available, I mentioned above.
Most of the examples or usage I saw online involve using web.xml and providing root of the application and using a servlet. This is my first exposure to building REST api. I may have misunderstood the whole thing or I skipped some step. I look forward for your help.
I am using Eclipse Photon for Java EE
Look at this
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>
This is nothing more than basically a bunch of interfaces for the EE spec. There is no implementation. Java EE servers will have the implementation. Tomcat is not an EE server. The only part of the EE spec it will definitely have the implementation for is Servlets and JSP (the web profile). If you want an EE server, checkout Glassfish or Wildfly.
You are trying to work with the JAX-RS spec, where Tomcat for sure by default does not have an implementation for. So you need to add that implementation. The easiest implementation, IMO to get started with, is Jersey. You can simply add this dependency
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.25.1</version>
</dependency>
and it will get you up and running. Keep the Jersey User Guide handy. It will come in use.
i am workign on a jboss-4.2.3.GA project. Its a old project but we cant upgrade to new server.
I am trying to use Arquillian for JPA..
We are using folliwng entry in pom for JPA
<dependency>
<groupId>com.jboss</groupId>
<artifactId>ejb3-persistence.jar</artifactId>
<version>4.2.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>hibernate</groupId>
<artifactId>hibernate3</artifactId>
<version>3.2.4.SP1</version>
<scope>provided</scope>
</dependency>
I am trying to configure Arquillian but i am getting some issue like nosuchmethod found or some time no default container set.
Anyone help me what container i need to set and any dependency settings ?
Add the arquillian-bom to the dependencyManagement section of your pom, see the Getting Started Guide: http://arquillian.org/guides/getting_started/#add_the_arquillian_apis
That will update the version of the dependencies the jbossas adapter has on arquillian core. Without it you will be running a mix of Core 1.0.1.Final and Core X (what ever the adapter happens to be compiled against currently which may or may not be compatible with the 1.0.1.Final Core artifacts).
I'm using Apache CXF version 2.4.0. I'm trying to create a Restful service.
The below example works in 2.3.4 but does not work in 2.4.0. What should I do different in beans config file?
When I include the below xml line in my bean config file.
<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
I get the following stacktrace error:
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Failed to
import bean definitions from URL
location
[classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml]
Offending resource: ServletContext
resource [/WEB-INF/beans.xml]; nested
exception is
org.springframework.beans.factory.BeanDefinitionStoreException:
IOException parsing XML document from
class path resource
[META-INF/cxf/cxf-extension-jaxrs-binding.xml];
nested exception is
java.io.FileNotFoundException: class
path resource
[META-INF/cxf/cxf-extension-jaxrs-binding.xml]
cannot be opened because it does not
exist at
org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
My POM dependency is below. This will work for 2.3.4 but not for 2.4.0. Any suggestions? Is that xml extension line deprecated or included in another jar?
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle-jaxrs</artifactId>
<version>2.3.4</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
</exclusions>
</dependency>
It's no longer needed. With 2.4.x, most of the META-INF/cxf files are no longer needed and can be removed. Really, the cxf.xml one is the only one needed.
Here is the CXF information about embedding cxf inside spring in version 2.4 and above.
http://cxf.apache.org/docs/embedding-cxf-inside-spring.html