Apache CXF Oauth2 Support In Tomee 8

2019-10-16 Thread chege

Hi,

I have been using apache cxf oauth2 module in using spring and tomcat.
Everything works fine. I can generate tokens and secure my services
using Bearer tokens.


Since Tomee 8 uses apache cxf to provide jaxrs functionalities, I
decided to test ouath2 with apache tomee 8. I first checked in tomee lib
folder and found out tomee ships with the supporting lib.


||
|||org.apache.cxf|
|||cxf-rt-rs-security-oauth2|
|3.3.2|||
||
|
|
|I am looking for help on how to use this ->
http://cxf.apache.org/docs/jax-rs-oauth2.html in a cdi environment.
|
|
|
|
|
|
|
|Thanks.
|
|
|
|
|


Apache Cxf Webclient Doen't Work As Expected in Tomee 8

2020-03-03 Thread chege

I am trying to get jwk keyset from google for use with Apache Cxf OIDC
and Jose Libs. The code works fine when I run it on a stand alone main
method.

|public class Main { /** * @param args the command line arguments */
public static void main(String[] args) { final WebClient client =
WebClient.create("https://www.googleapis.com/oauth2/v3/certs;,
Arrays.asList(new JsonWebKeysProvider()),
true).accept(MediaType.APPLICATION_JSON); JsonWebKeys keys =
client.get(JsonWebKeys.class); keys.getKeys().forEach(key -> {
System.out.println("");
System.out.println("ID." + key.getKeyId());
System.out.println("Alg" + key.getAlgorithm());
System.out.println("Key Type..." + key.getKeyType());
System.out.println("Use" + key.getPublicKeyUse()); }); } } |

The ID, algorithm, key type and use is printed properly meaning that the
keys are property populated.

Sample output:

|
ID.79c809dd1186cc228c4baf9358599530ce92b4c8 AlgRS256 Key
Type...RSA Usesig

ID.17d55ff4e10991d6b0efd392b91a33e54c0e218b AlgRS256 Key
Type...RSA Usesig |

pom.xml extract for Main class.

|  org.apache.cxf
cxf-rt-rs-client 3.3.5
  org.apache.cxf
cxf-rt-rs-security-sso-oidc
3.3.5   |

The same code however doesn't work when deployed in Tomee 8.

|@WebServlet(name = "NewServlet", urlPatterns = {"/x"}) public class
NewServlet extends HttpServlet { @Override protected void
doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException { PrintWriter writer =
response.getWriter(); final WebClient client =
WebClient.create("https://www.googleapis.com/oauth2/v3/certs;,
Arrays.asList(new JsonWebKeysProvider()),
true).accept(MediaType.APPLICATION_JSON); JsonWebKeys keys =
client.get(JsonWebKeys.class); keys.getKeys().forEach(key -> {
writer.println("");
writer.println("ID." + key.getKeyId());
writer.println("Alg" + key.getAlgorithm()); writer.println("Key
Type..." + key.getKeyType()); writer.println("Use" +
key.getPublicKeyUse()); }); } } |

The ID, algorithm, key type and use is null when this code runs in Tomee
8. I have added cxf oidc lib and jose jars are installed in tomee/lib
folder.

Sample output:

|
ID.null Algnull Key Type...null Usenull

ID.null Algnull Key Type...null Usenull |

pom.xml extract for the servlet.

|  org.apache.tomee
javaee-api 8.0-3
provided  
org.apache.cxf
cxf-rt-frontend-jaxrs
${cxf.version} provided 
 org.apache.cxf
cxf-rt-rs-security-sso-oidc
${cxf.version} provided 
 org.apache.cxf
cxf-rt-rs-client
${cxf.version} provided 
 |

What is causing this issue?



How do I disable JAXRS for a single war file

2020-02-22 Thread chege

Hi,

Ho do I go about disabling JAXRS auto configuration for a single war
file deployed in Tomee?


Thanks.



Tomee Maven Plugin - Download Transitive Dependecies

2020-04-11 Thread chege

Hi,

I have below set up for tomee maven plugin. It is not downloading
transitive dependencies for hibernate. Is is there a way to download
transitive dependencies without listing them one by one.


docker

accounts


org.apache.tomee.maven
tomee-maven-plugin
8.0.1


package

build




plume

true


org.hibernate:hibernate-entitymanager:${hibernate.version}

org.hibernate:hibernate-core:${hibernate.version}
remove:openjpa-
remove:eclipselink-








Thanks,
Chege.


JSON-B Adapter Not Invoked

2020-06-15 Thread chege

Hi,

I am facing a problem where jsonb adapter is not invoked.
Here is a simplified case.

jaxrs application
---

@ApplicationPath("/app")
public class App extends Application{

}

adapter


public class B implements JsonbAdapter {

@Override
public JsonObject adaptToJson(Book obj) throws Exception {
return Json.createObjectBuilder()
.add("customfield", obj.getId() + " " + obj.getTitle())
.build();
}

@Override
public Book adaptFromJson(JsonObject obj) throws Exception {
throw new UnsupportedOperationException("Not supported yet.");
//To change body of generated methods, choose Tools | Templates.
}

}

dto

public class Book {

private int id;
private String title;

public Book() {
}

public Book(int id, String title) {
this.id = id;
this.title = title;
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

}

resource
---

@Path("/r")
public class R {

@GET
@Produces({MediaType.APPLICATION_JSON})
public Response response() {
Book book = new Book(100, "Apache Tomee");
JsonbConfig config = new JsonbConfig()
.withFormatting(true)
.withAdapters(new B());
Jsonb jsonb = JsonbBuilder.create(config);
String toJson = jsonb.toJson(book);
return Response.ok(toJson).build();
}

}

What am i missing?

Thanks.



JMS Redelivery issue with Spring Framework

2021-08-18 Thread chege

Hi,

I have a sample project at https://github.com/chegeprogrammer/tomeetest
that shows that the set redelivery  policy is not respected.

What I am doing wrong?

Thanks.


Jaxrs Bean Validation - Tomee 8.0.10 - JDK 11 and JDK 8

2022-03-22 Thread chege

Hi,


I have the following resource where bean validation is not working.
What configuration is required to activate bean validation?


@Path("/product")
public class ProductApi {

    @GET
    public void demo(@NotNull @QueryParam("id") Integer id) {
  //do something with the id.
    }

}


The id is required. I expect a 4xx error when id is not passed.
Instead I am getting 204(no content).


Thanks.



Re: Logging Abandoned Connection

2023-09-27 Thread chege
On Wed, 2023-09-27 at 11:32 -0700, Kean Erickson wrote:
> Kean

Hi Kean,

Thanks for the response. Before removing abandoned connections I want
to log the event.



Logging Abandoned Connection

2023-09-27 Thread chege
Hi,

I using tomee 8.0.14. I want to see which code is not closing
connections. I have set logAbandoned true in my datasource.
However I don't see the any abandoned connection logged.


 

  DataSourceCreator tomcat
  JdbcDriver org.postgresql.Driver
  JdbcUrl jdbc:postgresql://localhost:5432/abc
   username ***
  password ***
  JtaManaged true
  InitialSize 10
  MaxActive 50
  MaxIdle 25
  MinIdle 10
  TestOnBorrow true
  TestWhileIdle true
  ValidationQuery select 1
  logAbandoned true



What else do I need to do to see connection leaks logged?


Chege.