Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

Couldn't find grammar element for class #18

Open
budjb opened this issue Mar 31, 2016 · 17 comments
Open

Couldn't find grammar element for class #18

budjb opened this issue Mar 31, 2016 · 17 comments

Comments

@budjb
Copy link
Owner

budjb commented Mar 31, 2016

From @confile on September 8, 2014 20:26

In my production environment I get the following error:

Sep 08, 2014 10:08:24 PM com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator attachTypes
INFO: Couldn't find grammar element for class test.dto.UserDto

What does this mean?

Copied from original issue: krasserm#57

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @davidecavestro on September 9, 2014 7:4

I've never seen it. It seems an info message more than an error, however googling for it I've found http://stackoverflow.com/questions/15767973/jersey-what-does-couldnt-find-grammar-element-mean
Could it be that test.dto.UserDto doesn't have a default constructor?

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 9, 2014 9:6

I checked this. All my classes have a public default constructor and may be a second parameterized constructor:

class UserDto {

    String id
    String firstName
    String lastName

public UserDto() { }

public UserDto(User user, User currentUser) {
... 
}

}

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 11, 2014 22:4

@davidecavestro Do you have any idea how to fix this?

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @davidecavestro on September 12, 2014 7:47

No idea. If I had time I'd debug the relevant jersey code. However I guess we are talking about an info message that you can safely ignore

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 18, 2014 14:33

In my Config.groovy I use:

org.grails.jaxrs.doreader.disable=true
org.grails.jaxrs.dowriter.disable=true

Is there any other config you recommend to prevent these INFO messages?

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @davidecavestro on September 18, 2014 15:25

No idea, did you tried debugging com.sun.jersey.server.wadl.generators.AbstractWadlGeneratorGrammarGenerator.attachTypes(ApplicationDescription)?
Since the relevant INFO message is generated at the end of that method, maybe debugging it could be of some help.

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 18, 2014 15:34

Sorry I did not get your point. Could you give me a little help please. How do I debug this?

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 18, 2014 15:38

I also get the following output after server startup:

Sep 18, 2014 3:18:19 PM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
  groovy.util.ConfigObject@6ea2bfd9
Sep 18, 2014 3:18:20 PM com.sun.jersey.spi.spring.container.servlet.SpringServlet getContext
INFO: Using default applicationContext
Sep 18, 2014 3:18:20 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans
INFO: Registering Spring bean, stickerPositionListDtoReader, of type test.StickerPositionListDtoReader as a provider class
Sep 18, 2014 3:18:20 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans
INFO: Registering Spring bean, org.grails.jaxrs.provider.DomainObjectWriter, of type org.grails.jaxrs.provider.DomainObjectWriter as a provider class
Sep 18, 2014 3:18:20 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans
INFO: Registering Spring bean, loginRequestDtoReader, of type test.LoginRequestDtoReader as a provider class
Sep 18, 2014 3:18:20 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans
INFO: Registering Spring bean, org.grails.jaxrs.provider.XMLReader, of type org.grails.jaxrs.provider.XMLReader as a provider class
Sep 18, 2014 3:18:20 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans
INFO: Registering Spring bean, stickerGroupListResource, of type test.StickerGroupListResource as a root resource class
Sep 18, 2014 3:18:20 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans
INFO: Registering Spring bean, userDetailsResource, of type test.UserDetailsResource as a root resource class
Sep 18, 2014 3:18:20 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans

Do you have any idea what to do?

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 18, 2014 15:41

In this post: http://stackoverflow.com/questions/15767973/jersey-what-does-couldnt-find-grammar-element-mean

A possible solution is to put the following in my web.xml:

<init-param>
         <param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
         <param-value>true</param-value>
     </init-param>

Where do I have to put this init param to? Is there a config in your plugin to disable WADL?

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @davidecavestro on September 19, 2014 8:8

The grails-jaxrs plugin simply uses jersey (the jaxrs reference implementation), embedding it into the grails web application.
So almost any jersey configuration applies, it being understood that the jersey servlet is not directly configured into the web.xml: its features are exposed through a dedicated controller.
I'd go for disabling wadl generation through jersey api or perhaps setting the param into a map and passing it as jaxrsInitParameters attribute of the jaxrsContext using resources.groovy.

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 19, 2014 9:1

@davidecavestro Thank you very much for your help. I would go with the resources.groovy solution.

Could you please tell me what I do have to set in resources.groovy?

I think it would be something like

import org.grails.jaxrs.web.JaxrsContext

beans = {
myJaxrsContext(JaxrsContext);
Map<String, String> jaxrsProviderInitParameters = new HashMap<String, String>();
jaxrsProviderInitParameters.put("com.sun.jersey.config.feature.DisableWADL", "true");

myJaxrsContext.setJaxrsInitParameters(jaxrsProviderInitParameters);
}

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @davidecavestro on September 19, 2014 9:7

Keep in mind you can put groovy code into resources.groovy
BTW I guess it should be fine... try it

2014-09-19 11:01 GMT+02:00 Confile [email protected]:

@davidecavestro https://github.com/davidecavestro Thank you very much
for your help. I would go with the resources.groovy solution.

Could you please tell me what I do have to set in resources.groovy?

I think it would be something like

import org.grails.jaxrs.web.JaxrsContext

beans = {
myJaxrsContext(JaxrsContext);
Map<String, String> jaxrsProviderInitParameters = new HashMap<String, String>();
jaxrsProviderInitParameters.put("com.sun.jersey.config.feature.DisableWADL", "true");

myJaxrsContext.setJaxrsInitParameters(jaxrsProviderInitParameters);
}


Reply to this email directly or view it on GitHub
krasserm#57 (comment)
.

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 19, 2014 13:37

It does not work this way. I get the following error:


2014-09-19 15:36:44,037 [localhost-startStop-1] ERROR spring.GrailsRuntimeConfigurator  - [RuntimeConfiguration] Unable to load beans from resources.groovy
Message: null
    Line | Method
->>   65 | doCall                    in resources$_run_closure1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    754 | invokeBeanDefiningClosure in grails.spring.BeanBuilder
|    584 | beans . . . . . . . . . . in     ''
|    460 | checkExternalBeans        in grails.plugin.hibernate3.HibernatePluginSupport
|    135 | doCall . . . . . . . . .  in grails.plugin.hibernate3.HibernatePluginSupport$__clinit__closure1
|    754 | invokeBeanDefiningClosure in grails.spring.BeanBuilder
|    584 | beans . . . . . . . . . . in     ''
|    527 | invokeMethod              in     ''
|    334 | innerRun . . . . . . . .  in java.util.concurrent.FutureTask$Sync
|    166 | run                       in java.util.concurrent.FutureTask
|   1145 | runWorker . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
|    615 | run                       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . . . . . . . . . in java.lang.Thread

What do I have to change?

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 25, 2014 14:8

@davidecavestro I still have this problem could you please give me some advice how to disable WADL?

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @davidecavestro on September 29, 2014 6:56

Sorry, even last weekend I had no time to give it a try
BTW if I were you, I'd continue with the resources.groovy approach: try commenting the entire closure contents, then uncomment just one line at time in order to find the error cause.
There could be other (probably better) ways I am not aware of and it would be very interesting taking time to investigate.

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on September 29, 2014 11:43

What should I put in resources.groovy?

@budjb
Copy link
Owner Author

budjb commented Mar 31, 2016

From @confile on October 8, 2014 12:19

@davidecavestro Could the answer in this question be a solution?

http://stackoverflow.com/questions/25915049/jersey-couldnt-find-grammar-element-for-class

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant