My Entity has a property,
#Embedded
#XmlTransient
private ReleaseTraits traits;
#XmlTransient
public ReleaseTraits getTraits() {
return traits;
}
But RestEasy (in JBoss AS 7.1) keeps putting it to the JSON.
Also, the null values are not omitted.
Any idea why and how to achieve the property to be left out?
#JsonIgnore works. It seems that the docs is wrong about which provider is the default in JBoss AS 7.
I filed https://issues.jboss.org/browse/AS7-5604 and https://issues.jboss.org/browse/AS7-5605 to target this.
This related question discusses some options for configuring your JBoss deployment to use Jettison rather than Jackson for JSON marshalling: Set JSON provider at RESTEasy on JBoss 7.1.1
For the benefit of others, #XmlTransient works correctly for me in WildFly 8.0, which is using RestEasy 3.0.x.
Related
There are two similar questions asked here and here but no adequate answers are given.
I found that I can use Enunciate to create WADL for a RestEasy service. So I tried it.
In one of my services I have a method mapped to HTTP GET which I am using like below
...
import org.jboss.resteasy.annotations.Form;
...
#GET
#Produces({MediaType.APPLICATION_JSON})
#Transactional(readOnly = true)
public WebServicePageResponse<D> find(#Form WebServicePageRequest<E> wsPageRequest)
{
...
}
Enunciate performs a validation on the service methods before it generates the WADL, and throws this error and fails
"A resource method that is mapped to HTTP GET must not specify an entity parameter."
#Form is a RestEasy specific annotation, while Enunciate can only parse JSR-311 annotations.
Has anyone done something similar? Has anyone successfully used Enunciate to generate documentation for a RestEasy service? Are there any alternatives?
Looks like a great suggestion for a new feature. Tracking it here.
It might be an awkward workaround, but have you tried using the signature override?
The best solution I found to this was to remove #Form annotation and use the individual annotations instead (enter link description hereatleast till Enunciate start supporting this).
It seems like the official MongoDB C# driver is not supported in SilverLight. I want to use MongoDB on the server side and communicate the data via WCF to the silverlight client.
The problem is the Id property in my POCO - Since I can't import a non-silverlight project into the silverlight - I can't use [BsonId] or ObjectId in my POCO which should be used by both the server and the client.
I've seen questions here on SO about having the Id member as string, but represented as ObjectId in the DB, but I haven't seen solutions.
What's the best way to have
public string Id { get; set; }
in my class, but still enjoy the benefits of ObjectId on the server-side of things?
I've seen this page, I tried using SetIdMember and MapIdProperty, the _id was null on the inserted documents.
Checkout the documentation here for representation options: http://www.mongodb.org/display/DOCS/CSharp+Driver+Serialization+Tutorial#CSharpDriverSerializationTutorial-RepresentationSerializationOptions
Alternatively, you could use a Guid in both your code and in the database and not need to do mental translations when querying.
I am using Objectify as a data access layer in my GoogleAppEngine hosted application.
The problem comes when I try to persist a map. My bean looks like this:
#Entity
#Cached
class MyBean{
#Id
private Long id;
#Embedded
Map<String, String> parameters = new HashMap<String, String>();
public MyBean(){}
//getters and setters below
}
First of all note that the map 'parameters' is not private, it was throwing a JRE exception.
When saving the map everything goes well. When retreiving it from the DataStore it fails.
My workaround is to use the #Serialized annotation. This is just a workaround since what I want to acheive is to use the expando feature of GAE Datastore.
According to the objectify doc I'm doing the right operations.
Exception details:
Caused by: java.lang.NullPointerException at
com.googlecode.objectify.impl.Transmog.loadSingleValue(Transmog.java:364)
at
com.googlecode.objectify.impl.load.EmbeddedMapSetter.safeSet(EmbeddedMapSetter.java:65)
at
com.googlecode.objectify.impl.load.CollisionDetectingSetter.set(CollisionDetectingSetter.java:37)
at
com.googlecode.objectify.impl.Transmog.loadSingleValue(Transmog.java:359)
at com.googlecode.objectify.impl.Transmog.load(Transmog.java:340) at
com.googlecode.objectify.impl.ConcreteEntityMetadata.toObject(ConcreteEntityMetadata.java:203)
at
com.googlecode.objectify.impl.QueryImpl$ToObjectIterator.translate(QueryImpl.java:668)
at
com.googlecode.objectify.impl.QueryImpl$ToObjectIterator.translate(QueryImpl.java:657)
at
com.googlecode.objectify.util.TranslatingIterator.next(TranslatingIterator.java:35)
Embedded maps were poorly supported in Objectify3, and should not have been publicly announced. The section on #Embedded Map has been removed from the Objectify3 documentation.
Objectify4 supports maps extensively, including these expando-style maps:
Map (or any primitive)
Map (key references)
Map (embedded classes
In addition, there is a #Mapify annotation that lets you take a normal collection of objects, pick one property out as a key, and store that as a Map.
Unfortunately Objectify4's documentation is not ready at this time. However, the source code is in active use by several parties. If you feel daring, build from trunk.
I also recommend using Objectify 4 - I've upgraded my app and found it fairly easy to do. I much prefer the support for fields of the type Map in particular.
To answer the question, you should never put #Embedded onto an array containing only primitives. So you don't need to specify #Embedded on your map because String is primitive in the Google App Engine Datastore.
Is there a way to access webservicecontext in the following format
SomeUtil.getWebserviceContext() instead of
#Resource
private WebServiceContext wsContext;
Thanks
You can actually just do:
new org.apache.cxf.jaxws.context.WebServiceContextImpl()
and use that. That's the object that is injected and it just wraps a thread local.
Migrating from old CXF 2.2 to 2.7.0, I was unable to access to the WebServiceContext, this line works fine:
new org.apache.cxf.jaxws.context.WebServiceContextImpl()
I'm trying to use Guice to inject properties of a JSF managed bean. This is all running on Google App Engine (which may or may not be important)
I've followed the instructions here:
http://code.google.com/docreader/#p=google-guice&s=google-guice&t=GoogleAppEngine
One problem is in the first step. I can't subclass the Servlet module and setup my servlet mappings there because Faces is handled by the javax.faces.webapp.FacesServlet which subclasses Servlet, not HttpServlet. So, I tried leaving my servlet configuration in the web.xml file and simply instantiating a new ServletModel() along with my business module when creating the injector in the context listener described in the second step.
Having done all that, along with the web.xml configuration, my managed bean isn't getting any properties injected. The method is as follows
#ManagedBean
#ViewScoped
public class ViewTables implements Serializable
{
private DataService<Table> service;
#Inject
public void setService( DataService<Table> service )
{
this.service = service;
}
public List<Table> getTables()
{
return service.getAll();
}
}
So, I'm wondering if there is a trick to get Guice injecting into a JSF managed bean? I obviously can't use the constructor injection because JSF needs a no-arg constructor to create the bean.
Check the following JSF-Guice integration framework/advice:
http://code.google.com/p/jsf-sugar/
http://notdennisbyrne.blogspot.com/2007/09/integrating-guice-and-jsf.html
http://cagataycivici.wordpress.com/2007/03/26/integrating_guice_and_jsf/
http://snippets.dzone.com/posts/show/7171
You can also create an HTTP servlet that then simple delegates the request on to a FacesServlet (like a wrapper). This should give you the same effect using Guice Servlet.
How about this approach, works well for us:
http://uudashr.blogspot.com/2008/12/guicing-jsf-with-guice.html
being the developer of jsf sugar I really would like to know the problem you had using it. We are already using it in production here so there shouldn't be any "show stoppers", maybe something is just not well documented? Just drop me a mail: murbanek(at)gmx_net (replace the _ with a .) .
check out http://code.google.com/p/guice2jsf/, and website starchu.blogspot.com, it has excellent library that provides Guice and JSF 2.0 integration
As information in this post are getting out of date but the question is still relevant, I'd like to share my findings about this topic. I wrote a little tutorial including a runnable sample project on how to setup a fully guice powered web stack. You can find it here: https://github.com/skuzzle/guice-jsf