I created the TomEEOpenAPIExtension that wrapper the
GeronimoOpenAPIExtension.

My question is, how can I shut down the GeronimoOpenAPIExtension extension?

I tried to append this value at system.properties:
openejb.classloader.forced-skip=org.apache.geronimo.microprofile.openapi.cdi
But it does not work.

I need to ignore the GeronimoOpenAPIExtension, to avoid the duplicated
creation of Bean at CDI.



On Fri, Mar 29, 2019 at 9:52 AM Otávio Gonçalves de Santana <
[email protected]> wrote:

> Unfortunately, this approach does not work.
>
>
> ProxyFactory proxyFactory = new ProxyFactory();
> proxyFactory.setSuperclass(Application.class);
> proxyFactory.setFilter(new MethodFilter() {
>     public boolean isHandled(Method m) {
>         return !m.getName().equals("finalize");
>     }
> });
> Class aClass = proxyFactory.createClass();
>
> MethodHandler mi = new MethodHandler() {
>     public Object invoke(Object self, Method m, Method proceed,
>                          Object[] args) throws Throwable {
>         //wrap the getClass()
>         return proceed.invoke(self, args);
>     }
> };
> Application foo = (Application)aClass.newInstance();
> ((ProxyObject)foo).setHandler(mi);
> Class<? extends Application> aClass1 = foo.getClass();
>
>
> I'll try another strategy.
>
>
> On Thu, Mar 28, 2019 at 2:39 PM Otávio Gonçalves de Santana <
> [email protected]> wrote:
>
>> One possible solution is the Javassist <http://www.javassist.org/>.
>> Therefore, I can create a proxy on a class.
>>
>> ProxyFactory factory = new ProxyFactory();
>> factory.setSuperclass(Application.class);
>> factory.setFilter(
>>     new MethodFilter() {
>>         @Override
>>         public boolean isHandled(Method method) {
>>             return true;
>>         }
>>     }
>> );
>>
>> MethodHandler handler = new MethodHandler() {
>>     @Override
>>     public Object invoke(Object self, Method thisMethod, Method proceed, 
>> Object[] args) throws Throwable {
>>       //the logic here
>>     }
>> };
>>
>> Application application = (Application) factory.create(new Class<?>[0], new 
>> Object[0], handler);
>>
>>
>> That is possible, but it does not look good. I'll try another option.
>> Also, we need to include this library on the Server.
>>
>> Thoughts?
>>
>> On Thu, Mar 28, 2019 at 10:45 AM Otávio Gonçalves de Santana <
>> [email protected]> wrote:
>>
>>> The InternalApplication is required, because, at RESTService it needs to
>>> add classes as a wrapper.
>>> My first thought is to create a proxy, however, Application is a class
>>> and not an interface.
>>>
>>> On Thu, Mar 28, 2019 at 9:43 AM Otávio Gonçalves de Santana <
>>> [email protected]> wrote:
>>>
>>>> Yes, there is this line that does not do this verification:
>>>>
>>>>  application = !InternalApplication.class.isInstance(application) ? new 
>>>> InternalApplication(application) : application;
>>>>
>>>>
>>>>
>>>> https://github.com/apache/tomee/blob/master/server/openejb-rest/src/main/java/org/apache/openejb/server/rest/RESTService.java#L224
>>>>
>>>> On Thu, Mar 28, 2019 at 1:07 AM Daniel Cunha <[email protected]>
>>>> wrote:
>>>>
>>>>> It is not injecting the config values for
>>>>> org.microprofileext.openapi.swaggerui.Templates and yes,
>>>>> using openejb.cxf-rs.cache-application=false the issue still happening.
>>>>> Interesting..
>>>>>
>>>>> Em qua, 27 de mar de 2019 às 18:24, Otávio Gonçalves de Santana <
>>>>> [email protected]> escreveu:
>>>>>
>>>>> > My maven configuration:
>>>>> >
>>>>> > <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
>>>>> > http://maven.apache.org/xsd/maven-4.0.0.xsd";>
>>>>> >     <modelVersion>4.0.0</modelVersion>
>>>>> >
>>>>> >     <groupId>org.superbiz</groupId>
>>>>> >     <artifactId>env-tomee</artifactId>
>>>>> >     <packaging>war</packaging>
>>>>> >
>>>>> >     <name>OpenEJB</name>
>>>>> >     <description>OpenEJB :: Web Examples</description>
>>>>> >     <version>0.0.1-SNAPSHOT</version>
>>>>> >     <url>http://tomee.apache.org</url>
>>>>> >
>>>>> >     <properties>
>>>>> >
>>>>>  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
>>>>> >         <tomee.version>8.0.0-M2</tomee.version>
>>>>> >     </properties>
>>>>> >
>>>>> >     <build>
>>>>> >         <finalName>env-tomee</finalName>
>>>>> >         <plugins>
>>>>> >             <plugin>
>>>>> >                 <groupId>org.apache.maven.plugins</groupId>
>>>>> >                 <artifactId>maven-compiler-plugin</artifactId>
>>>>> >                 <version>3.5.1</version>
>>>>> >                 <configuration>
>>>>> >                     <source>1.8</source>
>>>>> >                     <target>1.8</target>
>>>>> >                 </configuration>
>>>>> >             </plugin>
>>>>> >             <plugin>
>>>>> >                 <groupId>org.apache.maven.plugins</groupId>
>>>>> >                 <artifactId>maven-war-plugin</artifactId>
>>>>> >                 <version>3.1.0</version>
>>>>> >             </plugin>
>>>>> >         </plugins>
>>>>> >     </build>
>>>>> >
>>>>> >     <repositories>
>>>>> >         <repository>
>>>>> >             <id>apache-m2-snapshot</id>
>>>>> >             <name>Apache Snapshot Repository</name>
>>>>> >             <url>
>>>>> https://repository.apache.org/content/groups/snapshots
>>>>> > </url>
>>>>> >             <snapshots>
>>>>> >                 <enabled>true</enabled>
>>>>> >             </snapshots>
>>>>> >         </repository>
>>>>> >     </repositories>
>>>>> >
>>>>> >     <pluginRepositories>
>>>>> >         <pluginRepository>
>>>>> >             <id>apache.snapshots</id>
>>>>> >             <url>http://repository.apache.org/snapshots/</url>
>>>>> >         </pluginRepository>
>>>>> >     </pluginRepositories>
>>>>> >
>>>>> >     <dependencies>
>>>>> >         <dependency>
>>>>> >             <groupId>org.apache.tomee</groupId>
>>>>> >             <artifactId>javaee-api</artifactId>
>>>>> >             <version>8.0</version>
>>>>> >             <scope>provided</scope>
>>>>> >         </dependency>
>>>>> >         <dependency>
>>>>> >             <groupId>org.eclipse.microprofile.openapi</groupId>
>>>>> >             <artifactId>microprofile-openapi-api</artifactId>
>>>>> >             <version>1.1.2</version>
>>>>> >             <scope>provided</scope>
>>>>> >         </dependency>
>>>>> >         <dependency>
>>>>> >             <groupId>org.microprofile-ext.openapi-ext</groupId>
>>>>> >             <artifactId>swagger-ui</artifactId>
>>>>> >             <version>1.0.1</version>
>>>>> >         </dependency>
>>>>> >     </dependencies>
>>>>> > </project>
>>>>> >
>>>>> >
>>>>> > My code:
>>>>> >
>>>>> > @ApplicationPath("api")@OpenAPIDefinition(info = @Info(
>>>>> >         title = "Example application",
>>>>> >         version = "1.0.0",
>>>>> >         contact = @Contact(
>>>>> >                 name = "Otavio",
>>>>> >                 email = "[email protected]",
>>>>> >                 url = "http://www.otaviojava.com.br";)
>>>>> > ),
>>>>> >         servers = {
>>>>> >                 @Server(url = "/example", description = "localhost")
>>>>> >         }
>>>>> > )public class MVCApplication extends Application {
>>>>> > }
>>>>> >
>>>>> >
>>>>> @Path("envs")@Produces(MediaType.APPLICATION_JSON)@Consumes(MediaType.APPLICATION_JSON)@Tag(name
>>>>> > = "Config Retrieval service", description = "Get the value for a
>>>>> > certain config")public class EnvironmentResource {
>>>>> >
>>>>> >     @GET
>>>>> >     @Operation(description = "Get the envs")
>>>>> >     @APIResponses({
>>>>> >             @APIResponse(responseCode = "200", description =
>>>>> > "Successful, returning the value")
>>>>> >     })
>>>>> >     public Map<String, String> getEnvs() {
>>>>> >         return System.getenv();
>>>>> >     }
>>>>> >
>>>>> >     @GET
>>>>> >     @Path("/{key}")
>>>>> >     @Operation(description = "Get the value for this key")
>>>>> >     @APIResponses({
>>>>> >             @APIResponse(responseCode = "200", description =
>>>>> > "Successful, returning the value")
>>>>> >     })
>>>>> >     @Produces(MediaType.TEXT_PLAIN)
>>>>> >     public Response getConfigValue(@PathParam("key") String key) {
>>>>> >         return Response.ok(key).build();
>>>>> >     }
>>>>> >
>>>>> > }
>>>>> >
>>>>> >
>>>>> > On Wed, Mar 27, 2019 at 5:11 PM Daniel Cunha <[email protected]>
>>>>> > wrote:
>>>>> >
>>>>> > > Can you guys push your sample?
>>>>> > >
>>>>> > > On Wed, Mar 27, 2019, 4:58 PM Otávio Gonçalves de Santana <
>>>>> > > [email protected]> wrote:
>>>>> > >
>>>>> > > > Hey Ivan.
>>>>> > > > I tried something, and I saw the same issue. It seems this
>>>>> by-pass does
>>>>> > > not
>>>>> > > > work.
>>>>> > > >
>>>>> > > > On Mon, Feb 11, 2019 at 11:18 AM Ivan Junckes Filho <
>>>>> > > [email protected]
>>>>> > > > >
>>>>> > > > wrote:
>>>>> > > >
>>>>> > > > > It didn't seem to work for me adding the property to
>>>>> > system.properties.
>>>>> > > > Any
>>>>> > > > > ideas what I am doing wrong?
>>>>> > > > >
>>>>> > > > > On Sat, Feb 9, 2019 at 10:21 AM Roberto Cortez <
>>>>> [email protected]>
>>>>> > > > > wrote:
>>>>> > > > >
>>>>> > > > > > Hi Ivan,
>>>>> > > > > >
>>>>> > > > > > Yes Romain is right, you should set
>>>>> > openejb.cxf-rs.cache-application
>>>>> > > =
>>>>> > > > > > false and it should work. We had to set that for the TCK to
>>>>> pass,
>>>>> > but
>>>>> > > > the
>>>>> > > > > > config never reached the final distribution. I did notice
>>>>> that and
>>>>> > > I’ve
>>>>> > > > > > added it in case a MP app is detected, but it was after M2
>>>>> was
>>>>> > > > released.
>>>>> > > > > >
>>>>> > > > > > Cheers,
>>>>> > > > > > Roberto
>>>>> > > > > >
>>>>> > > > > > On 8 Feb 2019, at 21:06, Ivan Junckes Filho <
>>>>> [email protected]
>>>>> > >
>>>>> > > > > wrote:
>>>>> > > > > >
>>>>> > > > > > I will take a look thanks again Romain
>>>>> > > > > >
>>>>> > > > > > On Fri, Feb 8, 2019 at 4:38 PM Romain Manni-Bucau <
>>>>> > > > [email protected]
>>>>> > > > > >
>>>>> > > > > > wrote:
>>>>> > > > > >
>>>>> > > > > >> Hey, just recalled we had a flag about it,
>>>>> > > > > >>
>>>>> > > > > >> you can skip it setting
>>>>> openejb.cxf-rs.cache-application=false
>>>>> > > > > >>
>>>>> > > > > >> Romain Manni-Bucau
>>>>> > > > > >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>>>>> > > > > >> <https://rmannibucau.metawerx.net/> | Old Blog
>>>>> > > > > >> <http://rmannibucau.wordpress.com> | Github <
>>>>> > > > > >> https://github.com/rmannibucau> |
>>>>> > > > > >> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
>>>>> > > > > >> <
>>>>> > > > > >>
>>>>> > > > >
>>>>> > > >
>>>>> > >
>>>>> >
>>>>> https://www.packtpub.com/application-development/java-ee-8-high-performance
>>>>> > > > > >> >
>>>>> > > > > >>
>>>>> > > > > >>
>>>>> > > > > >> Le ven. 8 févr. 2019 à 19:01, Ivan Junckes Filho <
>>>>> > > > [email protected]
>>>>> > > > > >
>>>>> > > > > >> a
>>>>> > > > > >> écrit :
>>>>> > > > > >>
>>>>> > > > > >> > Interesting, ok thanks Romain.
>>>>> > > > > >> >
>>>>> > > > > >> > On Fri, Feb 8, 2019 at 3:29 PM Romain Manni-Bucau <
>>>>> > > > > >> [email protected]>
>>>>> > > > > >> > wrote:
>>>>> > > > > >> >
>>>>> > > > > >> >> Hi Ivan,
>>>>> > > > > >> >>
>>>>> > > > > >> >> In a few cases - don't recall out of my head if it is
>>>>> all -
>>>>> > TomEE
>>>>> > > > > wraps
>>>>> > > > > >> >> user application in InternalApplication. IIRC it was for
>>>>> > caching
>>>>> > > > > >> reason -
>>>>> > > > > >> >> TomEE not being super cleanly aligned on CDI + to avoid
>>>>> to get
>>>>> > > > > multiple
>>>>> > > > > >> >> instances between runtime and deployment which can break
>>>>> user
>>>>> > > code.
>>>>> > > > > >> >> Enhancing TomEE to no do it anymore or not use a wrapper
>>>>> when
>>>>> > not
>>>>> > > > > >> needed
>>>>> > > > > >> >> can be a first step fixing that.
>>>>> > > > > >> >>
>>>>> > > > > >> >> Romain Manni-Bucau
>>>>> > > > > >> >> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
>>>>> > > > > >> >> <https://rmannibucau.metawerx.net/> | Old Blog
>>>>> > > > > >> >> <http://rmannibucau.wordpress.com> | Github
>>>>> > > > > >> >> <https://github.com/rmannibucau> | LinkedIn
>>>>> > > > > >> >> <https://www.linkedin.com/in/rmannibucau> | Book
>>>>> > > > > >> >> <
>>>>> > > > > >>
>>>>> > > > >
>>>>> > > >
>>>>> > >
>>>>> >
>>>>> https://www.packtpub.com/application-development/java-ee-8-high-performance
>>>>> > > > > >> >
>>>>> > > > > >> >>
>>>>> > > > > >> >>
>>>>> > > > > >> >> Le ven. 8 févr. 2019 à 18:14, Ivan Junckes Filho <
>>>>> > > > > >> [email protected]>
>>>>> > > > > >> >> a écrit :
>>>>> > > > > >> >>
>>>>> > > > > >> >>> The @OpenAPIDefinition is not being picked up by the CDI
>>>>> > > extension
>>>>> > > > > >> >>> because it is only getting InternalApplication instead
>>>>> of
>>>>> > > picking
>>>>> > > > up
>>>>> > > > > >> my
>>>>> > > > > >> >>> custom Application config. Any ideas why?
>>>>> OpenAPIDefinition
>>>>> > > > configs
>>>>> > > > > >> are
>>>>> > > > > >> >>> therefore not showing up in the openapi doc.
>>>>> > > > > >> >>>
>>>>> > > > > >> >>>
>>>>> > > > > >> >>> @OpenAPIDefinition(info =
>>>>> > > > > >> >>>         @Info(
>>>>> > > > > >> >>>                 title = "TEST",
>>>>> > > > > >> >>>                 version = "2.0",
>>>>> > > > > >> >>>                 description = "Pet Store App API",
>>>>> > > > > >> >>>                 license = @License(
>>>>> > > > > >> >>>                         name = "Apache 2.0",
>>>>> > > > > >> >>>                         url = "
>>>>> > > > > >> http://www.apache.org/licenses/LICENSE-2.0.html";),
>>>>> > > > > >> >>>                 contact = @Contact(
>>>>> > > > > >> >>>                         name = "PetStore API Support",
>>>>> > > > > >> >>>                         url = "
>>>>> > > > > >> https://github.com/eclipse/microprofile-open-api";,
>>>>> > > > > >> >>>                         email = "[email protected]")
>>>>> > > > > >> >>>         ),
>>>>> > > > > >> >>>         security = @SecurityRequirement(name =
>>>>> "oauth2"),
>>>>> > > > > >> >>>         servers = @Server(url = "/test/"))
>>>>> > > > > >> >>> @ApplicationPath("/api")
>>>>> > > > > >> >>> @LoginConfig(authMethod = "MP-JWT")
>>>>> > > > > >> >>> public class ApplicationConfiguration extends
>>>>> Application {
>>>>> > > > > >> >>>
>>>>> > > > > >> >>>
>>>>> > > > > >>
>>>>> > > > > >
>>>>> > > > > >
>>>>> > > > >
>>>>> > > >
>>>>> > >
>>>>> >
>>>>>
>>>>>
>>>>> --
>>>>> Daniel "soro" Cunha
>>>>> https://twitter.com/dvlc_
>>>>>
>>>>

Reply via email to