[EJB 3.0] New message: "Define injected persistence unit outside the ejb.jar"
by Thomas Goettlich
User development,
A new message was posted in the thread "Define injected persistence unit outside the ejb.jar":
http://community.jboss.org/message/531349#531349
Author : Thomas Goettlich
Profile : http://community.jboss.org/people/ThomasGo
Message:
--------------------------------------------------------------
Hi,
I have a question regarding the injection of persistence units/entity managers:
Consider the following setup:
ear
+- ejb_a.jar
| +- DAO_A
| +- Entity_A
+- ejb_b.jar
| +- DAO_B
| +- Entity_B
+- ejb_c.jar
| +- DAO_C
| +- Entity_C
+- persistence.jar
+- persistence.xml
+- orm.xml
ejb_a.jar and ejb_b.jar are components that are independent of the application. However, since the application might require some specific setup, the components only define some default settings via annotations, e.g. @Table(...) etc.
The project-specific persistence.jar contains a persistence.xml that references the orm.xml which in turn defines application specific overrides.
This works so far.
The problem I'm facing now is the following:
Each of the DAOs currently references a persistence unit by name (@PersistenceContext(unitName = "XXX")), which is defined in the persistence.xml. If DAO_B needs to load instances of Entity_A it should use the same persistence unit.
However, if Entity_A and Entity_B are independent and sometimes need to be stored in different databases, I need to specify different persistence units. If I now have a case where Entity_C and DAO_C need access to both Entity_A and Entity_B (in which case they can't be in different databases) I'd need to create another persistence unit which references all 3 entities (resp. all 3 jars via the <jar-file> tag). Since the jar's generally are independent components, changing the unitName in the source isn't an option.
This now would lead to 3 persistence units being defined, PU_A, PU_B and PU_C.
Each of those reference one or more jars with PU_C referencing all 3 whereas PU_A and PU_B just reference ejb_a.jar/ejb_b.jar.
If you extend that example you can see that there would be an explosion of persistence units that are required.
So finally, here's the actual question:
I'd like to inject the persistence unit into the DAOs via a deployment descriptor external to the ejb.jar.
AFAIK ejb-jar.xml isn't an option, since it needs to be included in the jar file, doesn't it?
The next thing I found was <persistence-context-ref> which seemed like a viable option: define a persistence context with a given name for the DAO and map that context to a persistence unit externally. The mapping needs to be put in a deployment descriptor, so application.xml seems to be fine.
However, this didn't work, with JBoss 4.2.3.GA complaining about no default persistence unit being found (which indicates the mapping is either ignored or wrong).
Another thing I found is that most sites on the net give examples for putting that mapping inside the servlet definition in web.xml, so it might only work for non-ejb classes. Is that true?
Thanks for reading my quite lengthy post and even more thanks for your answers.
Regards,
Thomas
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/531349#531349
16 years, 3 months
[JBoss Web Services] New message: "Re: How can I force a particular WS implementation? How to ensure Metro over Native?"
by Alessio Soldano
User development,
A new message was posted in the thread "How can I force a particular WS implementation? How to ensure Metro over Native?":
http://community.jboss.org/message/531343#531343
Author : Alessio Soldano
Profile : http://community.jboss.org/people/alessio.soldano@jboss.com
Message:
--------------------------------------------------------------
What you example is doing is basically leveraging classloading isolation in the war; the Sun libraries you include in the web application take over to the corresponding ones installed in the server (the jaxws impl, etc.)
The application server "knows to use Metro" in that case just because of the web.xml you're providing:
> <listener>
> <listener-class>com.sun.xml.ws.transport.http.servlet.WSServletContextListener</listener-class>
> </listener>
>
> <servlet>
> <servlet-name>MyWebService</servlet-name>
> <servlet-class>com.sun.xml.ws.transport.http.servlet.WSServlet</servlet-class>
> </servlet>
>
> <servlet-mapping>
> <servlet-name>MyWebService</servlet-name>
> <url-pattern>/FooService</url-pattern>
> </servlet-mapping>
>
As you can see there's no reference to a jaxws annotated class here above; on the countrary, you're refferring to the Metro's servlet and specifying it's servlet context listener. At that point, the Metro specific descriptor (sun-jaxws.xml) enter the game and the rest of the setup is up to the Sun libs.
In the case above, the web app is like another other web app to JBoss.
The problem with your solution is in the fact you need to bundle a stack implementation with your own application.
When you install JBossWS-Metro (the same could be said about JBossWS-CXF, of course) to the application server, instead, you get a proper integration to the AS. For example, besides slimming down the size of you app archive, you no longer need to provide the proprietary sun-jaxws descriptor in your deployment (it's automatically generated by JBossWS-Metro), you get access to the common JBossWS features (centralized endpoint registry, for instance). Also, I did not try your sample (need to mangle with my maven repository setup ;-) to make it build), but can you use EJB3 endpoints with your solution? what about webservice context injection in ejb3 endpoints? what about webservicerefs?
I'm not saying what you did is wrong, it's a nice way of having a single app running on Metro on a JBWS-Native configured application server. Unfortunately it's going to suffer from some issues, that's all ;-)
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/531343#531343
16 years, 3 months
[JBoss Microcontainer Development] New message: "Re: JBREFLECT-5 - Implementing generics in JavassistClassInfo"
by Ales Justin
User development,
A new message was posted in the thread "JBREFLECT-5 - Implementing generics in JavassistClassInfo":
http://community.jboss.org/message/531337#531337
Author : Ales Justin
Profile : http://community.jboss.org/people/alesj
Message:
--------------------------------------------------------------
>
>
>
>
> I have not added caching yet, and adding this simple test passes with the introspection implementation, but fails with the Javassist implementation
>
> *public* Comparable<String> signatureCachedParameterizedClassInfo()
> {
> *return* *null*;
> }
>
> *public* *void* testCachedParameterizedClassInfo() *throws* Throwable
> {
> Type type = getGenericReturnType("signatureCachedParameterizedClassInfo");
> TypeInfo typeInfo1 = getTypeInfoFactory().getTypeInfo(type);
> TypeInfo typeInfo2 = getTypeInfoFactory().getTypeInfo(getGenericReturnType("signatureCachedParameterizedClassInfo"));
> assertEquals(typeInfo1, typeInfo2);
> assertSame(typeInfo1, typeInfo2); // <-- FAILS
>
> //Also check the results of repeated calls to getGenericSuperClass/-Interfaces() etc.
> }
>
>
>
>
> Is this object equality a requirement? My fear is that working out the key will be costly
My first answer is yes, but you can convince we otherwise. ;-)
As all of the stuff in Reflect works this was, why is this here a problem?
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/531337#531337
16 years, 3 months
[JBoss Microcontainer] New message: "Re: MultipleVFSParsingDeployer on HornetQ"
by Ales Justin
User development,
A new message was posted in the thread "MultipleVFSParsingDeployer on HornetQ":
http://community.jboss.org/message/531334#531334
Author : Ales Justin
Profile : http://community.jboss.org/people/alesj
Message:
--------------------------------------------------------------
> If this is what you eventually need, you can go back to your previous 2-copy deployers.
> As that is not wrong, specially when you're targeting suffix matching,
Thinking about it a bit more, just noticed you need to be careful here not to override the attachment info.
e.g.
* you're matching -a.xml and -b.xml
* deployment contains both files; foo-a.xml and bar-b.xml
* both will be put under Configuration.class attachment key (by default)
* override of info
--> meaning you need to override the attachmentKey property on the deployer
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/531334#531334
16 years, 3 months