I am using Enunciate to generate documentation for RestEasy services inside multi-module Maven project.
I have some problems with doc generation when trying to get description of response object atributes.
For instance, if my service is defined as:
#GET
#Path("access/account")
#Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
Account getAccount(#Context HttpServletRequest hsr, #Context UriInfo info) throws RestApiException;
when the documentation is generated no atribute description is generated.
name type description
idProfile int (no documentation provided)
idLanguage int (no documentation provided)
idRegion int (no documentation provided)
userType string (no documentation provided)
In all response objects I get only (no documentation provided). One important think is that all response
classes are in different Maven module that the services are. The response classes are situated in the UTIL module. The services are situated in EJB module.
The reason for the problem is definitely multi-module Maven project, because if I define a response object
that class is in the EJB module too, the documentation is perfect (also the description is generated).
The reason and also the solution is described here:
https://github.com/stoicflame/enunciate/wiki/Multi-Module-Projects-%28Version-1%29
Despite all I still don't know what to do exactly and what to set inside different poms (EJB and UTIL) to solve my problem.
Any help is apreciated.
So have you tried to "import" the Account class as described in Multi-Module Projects?
<enunciate ...>
<api-import pattern="com.mycompany.Account" />
<api-import pattern="com.mycompany.*" />
...
</enunciate>
Problem solved !!!
I had to:
import the classes as Ryan said
add maven-source-plugin in the pom.xml of the UTIL class where all response objects are located
add description to get methods in reference class
The result is:
JSON
property type description
idProfile int Description B.
idLanguage int Description A.
idRegion int Description E.
userType string Description D.
Related
Running
val myAvroObject = MyAvroObject.newBuilder()
results in a compilation error:
Cannot access class 'MyAvroObject.Builder'. Check your module classpath for missing or conflicting dependencies
I am able to access other MyAvroObject variables. More precisely, methods such as
val schema = MyAvroObject.getClassSchema()
val decoder = MyAvroObject.getDecoder()
compiles fine. What makes it even stranger is that I can access newBuilder() in my test/ folder, but not in my src/ folder.
Why do I get a compile error when using newBuilder()? Is the namespace of the avro-schema used to generate MyAvroObject of importance?
Check your module classpath generally means, that your dependencies (which you didn't provide) are messed up. One of them should read implementation instead of testImplementation, in order to have the method available in the main source-set, instead of only the test source-set - but this may well have to do with the input classes, the output location of generated classes, or annotations alike #VisibleForTesting (just see what it even generates). Command gradlew can also list the dependencies per configuration. The builder seems to be called org.apache.avro.SchemaBuilder... there's only avro-1.11.0.jar & avro-tools-1.11.0.jar. With the "builder" design pattern, .newBuilder() tries to return inner class Builder.
had the same problem today and was able to solve it by adding the following additional source folder
<sourceDir>${project.basedir}/target/generated-sources/avro</sourceDir>
to the kotlin-maven-plugin.
When I added an includeFilter to #EnableEntityDefinedRegion, it still scanned the whole entity package and created all Region beans. How do I scan the specific Region class? For example, only "Address" Region.
package org.test.entity
#Getter
#Setter
#Region("Address")
public class GfAddress implements Serializable
package org.test.entity
#Getter
#Setter
#Region("CreditCard")
public class GfCreditCard implements Serializable
package org.test.package
public interface IAddressRepository extends GemfireRepository<GfAddress, String>
package org.test.package
public interface ICreditCardRepository extends GemfireRepository<GfCreditCard , String>
#Service
#ClientCacheApplication
#EnableGemfireRepositories(basePackages = IAddressRepository.class, includeFilters = #ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes=AddressRepository.class))
#EnableEntityDefinedRegion(basePackages = GfAddress.class, includeFilters = #ComponentScan.Filter(type = FilterType.REGEX, pattern="GfAddress*"))
public class AddressDataAccess
When I print all the beans that are loaded, I found out that the following beans are created.
Address
CreditCard
IAddressRepository
AddressDataAccess
Version
GemFire : 9.8.6
spring-data-gemfire : 2.1.0
Spring Boot : 2.1.0
Sorry for the delay.
First, have a look at the SDG JIRA ticket I filed, DATAGEODE-352 - "EnableEntityDefinedRegions.includeFilters are inappropriately overridden by framework provided include filters".
In this ticket, I describe a couple of workarounds to this bug (!) in the comments, starting here.
I'd also be careful about your REGEX. I am no Regular Expression expert, but I am certain "GfAddress*" will not properly match the application entity type you are searching for and trying to match even when you pick up the new SDG bits resolving the issue I filed.
I created a similar test, using REGEX, to verify the resolution of the issue, here. This is the REGEX I specified. Using "Programmer*" did not work, as I suspected! That is because the REGEX is not valid and does not match the FQCN as used in the Spring RegexPatternTypeFilter.
Technically, it would be better to be a bit more specific about your type matching and use a "ASSIGNABLE_TYPE" TypeFilter instead, as this test demonstrates.
Finally, while SDG 2.1.x is compatible with GemFire 9.8.x, SD[G] Lovelace, or 2.1.x (e.g. 2.1.18.RELEASE), is officially based on, and only "supports", VMware GemFire 9.5.x (currently 9.5.4).
SDG 2.2.x is officially based on, and "supports", VMware GemFire 9.8.x (currently at 9.8.8).
You can review the new SDG Version Compatibility Matrix for more details.
If you have more questions, please follow up here or in DATAGEODE-352.
I've been trying to inject an EJB into a JAX-RS resource via InitialContext()lookup() getting the following exception:
<javax.naming.NameNotFoundException: While trying to look up
comp/env/AServiceLocal
in /app/webapp/wcc/1377099157.; remaining name 'comp/env/AServiceLocal'>
My lookup in resource constructor:
try {
initialContext = new InitialContext();
String jndiSubcontext = "java:comp/env/";
aService = (AServiceLocal) initialContext.lookup(jndiSubcontext+AServiceLocal.class.getSimpleName());
eSService = (ESServiceLocal) initialContext.lookup(jndiSubcontext+ESServiceLocal.class.getSimpleName());
eService = (EServiceLocal) initialContext.lookup(jndiSubcontext+EServiceLocal.class.getSimpleName());
} catch (NamingException e) {
e.printStackTrace();
}
Here's the file structure taking into account that they are all maven projects:
global
|
--shared
|
|---src/main/java/com/x/y/z/AServiceLocal.java (ejb)
|
--war-project
|
|--src/main/java/comm/x/y/z/TheResource.java (jax-rs)
There are more maven projects related and they are all maven-configured through the global project in a hierarchical way.
There is also a resource in the same project as war-project that also performs lookups to the shared project and they do work.
I don't understand what the problem is.
edit
After adding ejb-local-ref to deployment descriptor:
<ejb-local-ref>
<ejb-ref-name>AServiceLocal</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>com.x.y.service.AdminXProfileServiceLocal</local>
<ejb-link>shared.jar#AdminXProfileService</ejb-link>
</ejb-local-ref>
I get the following error:
[J2EE:160101]Error: The ejb-link "shared.jar#AService"
declared in the ejb-ref or ejb-local-ref "AServiceLocal"
in the application module "xyz-99.1.0-SNAPSHOT.war" could not be
resolved. The target EJB for the ejb-ref could not be found. Ensure
that the link is correct.
The jar shared.jar is a dependency of the war project, but it seems that location is not correct. Must I add the packages also to the ejb-link ?
Something like: <ejb-link>shared.jar#com.x.y.ServiceImpl</ejb-link>
I aslo need to point out that there is a mix of hk2,cdi and lookups as part of the injection due to the fact the project is quite old and also it was migrated to weblogic 12c version recently so normal #Inject or #EJB don't appear to be working.
If I take into account all the variables I am seeing like Maven, project structure, JNDI lookup etc... the best way is to add an entry in the web.xml of the war project referencing your ejbs.
<ejb-local-ref>
<ejb-ref-name>ejb/adminXProfileService</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>com.myapp.ejb.AdminXProfileServiceLocal</local>
<ejb-link>YourEJBLibrary.jar#adminXProfileService</ejb-link>
</ejb-local-ref>
Then in your lookup you simply look for:
contenxt.lookup("java:comp/env/ejb/adminXProfileService");
I'm getting a bit frustrated trying to override the repository of my own Entity.
I need to create a custom repository method to get a list of my entities with special way. One queryBuilder with Having and OrderBy.
Te question is how can I setup my config to say Sylius, take my custom repositor, not the default.
I try this:
sylius_resource:
resources:
dinamic.category:
classes:
model: App\Bundle\SyliusBlogBundle\Entity\PostCategory
repository: App\Bundle\SyliusBlogBundle\Repository\PostCategoryRepository
This is my Repository:
<?php
namespace App\Bundle\SyliusBlogBundle\Repository;
use Doctrine\ORM\EntityRepository;
class PostCategoryRepository extends EntityRepository
{
public function findCategoriesMenu()
{
$queryBuilder = $this->createQueryBuilder('c');
return $queryBuilder
->addSelect('COUNT(p.id) as totalPosts')
->leftJoin('c.posts', 'p')
->andWhere('p.published = true')
->having('totalPosts > 0')
->addGroupBy('p.id')
;
}
}
When I try to use this method, Symfony throws me this error:
An exception has been thrown during the rendering of a template ("Undefined method 'findCategoriesMenu'. The method name must start with either findBy or findOneBy!")
Well you aren't subclassing the correct repository. The ResourceController expects a repository based on the Sylius\Component\Resource\Repository\RepositoryInterface. Since you are subclassing from Doctrine\ORM\EntityRepository that won't be the case.
Your repository should inherit from Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository (or implement the interface yourself).
I answer to the post to paste correctly the response of app/console debug:container dinamic.repository.category
Information for Service "dinamic.repository.category"
=====================================================
------------------ -------------------------------------------------------------------
Option Value
------------------ -------------------------------------------------------------------
Service ID dinamic.repository.category
Class Dinamic\Bundle\SyliusBlogBundle\Repository\PostCategoryRepository
Tags -
Scope container
Public yes
Synthetic no
Lazy no
Synchronized no
Abstract no
Autowired no
Autowiring Types -
------------------ -------------------------------------------------------------------
Since here all it's ok.
When i try to access to Posts list this error appears:
An exception has been thrown during the rendering of a template ("Catchable Fatal Error: Argument 4 passed to Sylius\Bundle\ResourceBundle\Controller\ResourceController::__construct() must implement interface Sylius\Component\Resource\Repository\RepositoryInterface, instance of Dinamic\Bundle\SyliusBlogBundle\Repository\PostCategoryRepository given, called in /Applications/XAMPP/xamppfiles/htdocs/rosasinbox-sylius/app/cache/dev/appDevDebugProjectContainer.php on line 2767 and defined")
The error of main post appears when the repository config wasn't set. Then my first post was wrong, on config.yml repository value wasn't set.
Now i set it another time and i got this error.
Sorry for the confusion.
I installed the grails currency plugin. I want to use the Money type in my grails domain class as such:
class FOO{
...
Money lunchCost = new Money(amount:0.00, currency:'USD')
Money dinnerCost = new Money(amount:0.00, currency:'USD')
...
}
I get an error when I compile saying "unable to resolve class Money". I traced the package heirchy of the Grails Money Plugin and tried to put in:
cr.co.arquetipos.currencies.Money breakfastCost = new cr.co.arquetipos.currencies.Money(amount:0.00, currency:'USD')
---- That didn't work either.
1) When I generated Foo, grails placed the domain class under "projectName.Foo" as it does for every domain class created.
2) I'm using Grails 1.3.5.
Do you have any ideas as to where the Currencies class is so I can include it in the
"import <....Money> and get rid of this compilation error?
Same here: The plugin does not integrate with the Grails project, at all. Nevertheless, it has been installed to ${user.home}/.grails/1.3.5/projects/${project.name}/plugins/currencies-0.3.
Since the plugin has been last updated in 2008 and doesn't cover too much functionality, I'd suggest to just copy the two domain classes (in the grails-app/domain folder) into your project.
For an evaluation, you may also want to have a brief look at grails-app/conf and test/integration in the plugin's installation folder.
Like ataylor says, don't use this plugin, it's broken. Instead use JScience. Checkout: Best practice to represent Money (value + currency) in Grails