Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!

Bobby Anderson

Ranch Hand
+ Follow
since Oct 28, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bobby Anderson

here is the exception:
11 years ago

You can however disable this in JBOSS_HOME/server/< servername>/deploy/jboss-web.deployer/META-INF/jboss-service.xml, set the UseJBossWebLoader to true:



I tried that with no luck so I assume my war is not trying to load a class my ear already loaded.

Here is my spring config file:


Not sure what else you are looking for? I will post the stack trace as well
11 years ago
I can post the stack trace in a while but I am sure that will not solve my problem. The class in question that spring cannot find is my class. com.test.MyEntity. This class lives in a jar file. That jar file lives in the .ear/lib directory. That jar is not placed in the war. So the class is not getting loaded twice. I assume that spring is not looking in the right place for my class.
11 years ago
They are EJB3 entity beans.

My jars which contain the entity beans are in the lib directory of the .ear file and spring still cannot find them

I am using JBoss 4.2.3 does that make a difference?

Here is my jboss-app.xml ( to isolate class loading so I can update hibernate)


And here is my application.xml for my ear


Also as you can see I am using application_1_4.xsd. Since Jboss 4.2.3 is only EE 1,4 I think this is right but maybe not.

Any other ideas? Thanks!
11 years ago
I am running spring inside JBoss 4.2.3 and I am trying to update Hibernate to the latest version. I am using jboss class loader isolation to accomplish this (this is the only way to update hibernate in jboss). I also have my entity beans in a jar file at the ear level. My spring stuff is in a war that lives in the ear.

If I deploy just the ear hibernate is updated and all my entities are processed by hibernate and all looks great.

The problem happens when I introduce my war (which is using spring) into the ear. My spring classes cannot find my entity classes. I.E. I get a NoClassDefFound exception.

I am not sure, but I imagine this is because my entities were deployed in a specific class loader by JBoss and Spring is not going to that class loader to look for classes.

Has anyone ever run into this before? Please Help!
11 years ago
Is there an easy way to get hibernate search to work on JBoss 4.2.3? I.E. does anyone know of a how-to article anywhere?

JBoss 4.2.3.GA comes with:
Hibernate - 3.2.4.sp1
Hibernate-annotations - 3.2.1.GA
Hibernate-entity-manager - 3.2.1.GA

I was hoping this would be as easy as just dropping Hibernate-search 3.0.1.GA in jboss/server/all/lib directory and running.

I found out that I need to turn on event listeners to get indexing to work which I did


But when I deploy I get NoClassDef errors. Can I put the hibernate-search jar in server/all/lib? Are all my versions compatible (I think so according to the compatibility matrix)

Please help!!!
11 years ago
I am trying to create a index file with hibernate search and I cannot even get it to create an index file.

I am running JBoss 4.2.3.GA (which I think has hibernate 3.2.4.sp1) So I got Hibernate-Search 3.0.1.GA and used annotations.

I am running jboss4.2.3.GA and I am having problems getting hibernate search to work.

Looking at the compatibility matrix I think with jboss4.2.3.GA I need to use hibernate-search version 3.0.1. (I may upgrade later but I would like to get a small example working first).

I downloaded version 3.0.1 and put the jar in the jboss lib directory. Started jboss and I did not see anything out of the ordinary.

I have the following in my persistence.xml


and I have a couple entity beans:




So a doc is just a simple entity that contains one or more text items. I want to be able to search for text and return the doc that the text belongs to. However when I persist my data I do not see any hibernate search output in the jboss logs nor do I see anything in my index (i.e index file is never even created).

Am I missing something, or is all I really need to do for jboss is deploy the hibernate-search.jar?

I thought that if you use annotations you did not have to turn anything on (like listeners).

Any ideas
I am confused the setTextItems(Set<TextItem> items) takes a Set object. I thought that the old set would be completely overridden when you set a new object of type Set.

I.E.


I am replacing the entire set not just one element, right? When debugging I can see the object change, but hibernate is not deleting all the old TextItems that were in the old list. Also the code posted as a solution does not work either, i.e. just clearing the list. I actually have to iterate though the list and remove all the textItems from the db.

I think this is due to the bidirectional dependency. I.E. a TextItem has a reference back to a Doc and a Doc has a set of text items.

Also what does

Please relook in hibernate.cfg.xml

mean???

Thanks
When creating a complete new Set of entities and storing that set using the entity's set method I thought that hibernate would pick up that fact that since this is a new set all other elements in the old set (db rows) will be deleted.

I.E. A document contains many text items




I want to be able to store text items for a doc and have hibernate delete all old text items for that doc.

I.E.


Why is this not deleting the 10 old text items since I used a new set with just one item in it?

Is this a problem because the relationship is bi-directional.
No luck, got the following from jboss log


2009-12-15 09:06:46,899 INFO [org.jboss.deployment.EARDeployer] Init J2EE application: file:/opt/jboss-4.2.3.GA/server/all/farm/test.ear
2009-12-15 09:06:46,902 DEBUG [org.jboss.deployment.EARDeployer] Extracted non-deployable content: META-INF/MANIFEST.MF
2009-12-15 09:06:46,902 DEBUG [org.jboss.deployment.EARDeployer] Extracted non-deployable content: META-INF/application.xml
2009-12-15 09:06:46,903 DEBUG [org.jboss.deployment.EARDeployer] Extracted deployable content: MyEntities1.jar
2009-12-15 09:06:46,903 DEBUG [org.jboss.deployment.EARDeployer] Extracted deployable content: MyEntities2.jar
2009-12-15 09:06:46,903 DEBUG [org.jboss.deployment.EARDeployer] Extracted non-deployable content: META-INF/persistence.xml
2009-12-15 09:06:46,904 DEBUG [org.jboss.deployment.EARDeployer] Extracted non-deployable content: META-INF/orm.xml



here is my new persistence.xml file:


here is my ear file listed:


0 Tue Dec 15 09:03:58 MST 2009 META-INF/
106 Tue Dec 15 09:03:56 MST 2009 META-INF/MANIFEST.MF
664 Tue Dec 15 08:57:20 MST 2009 META-INF/application.xml
17330 Tue Dec 15 08:53:54 MST 2009 MyEntities1.jar
12191 Tue Dec 15 08:53:44 MST 2009 MyEntities1.jar
2167 Tue Dec 15 09:03:40 MST 2009 META-INF/persistence.xml
424 Mon Dec 14 12:03:44 MST 2009 META-INF/orm.xml



here is a snippet from my application.xml file:


Do I still store the entity jars at the top level?

I cannot switch to jboss 5 so I am stuck with re-packaging all entities in one jar if I cannot get this to work

I will look around to see if JBoss 4.2.3 will allow this, if anyone has any more ideas please let me know

Thanks!
It is worth a try. I will try will the jar file in the persistence.xml file to see if that helps. I will edit this reply to let everyone know what I find.

Thanks for your help!
Just as I suspected you cannot do this in jboss 4

This is from the link you posted:


4.2.2. persistence.xml and .jar files

For those of you familiar with older versions of the spec, there is no .par file anymore. Entities are placed in a EJB-JAR .jar file or a .jar file all their own. You must also define a persistence.xml file that resides in the META-INF folder of the .jar file. Here's an example of a persistence.xml file.



and


4.3. EAR and WAR files

JBoss 4.0.x does not support the Java EE 5 EAR format. So, if you want to deploy a standalone persistence archive, you must list it within application.xml as an ejb module.

For WAR files, JBoss 4.0.x does not yet support deploying a persistence archive with WEB-INF/lib as required by the spec.



Although it does say Jboss 4.0.x does not support Java EE Ear format, but since I cannot get this to work my guess is that JBoss 4.2.x also does not support it.


Oh well I guess at least I know this is a JBoss limitation.
Hibernate on my app server (JBoss 4.2.3) is not picking up my entities so it seems like the persistence.xml is not in the correct place. If I put a persistence.xml file in META-INF directory of each jar file with a different unit name hibernate picks up and deploys all my entities. But I want only one unit name (persistence unit) for all my entities even though they are in a different jar.

Is this a problem with JBoss?
I have two jars that are included in an ear file. Each jar contains entity classes but neither jar includes a persistence.xml.

I would like the entities in both jars to share the same persistence unit (myPU). So I would like to store the persistence.xml file at the ear level and not the jar level.

I have tried putting the persistence.xml file in the META-INF of the ear and also at the top level of the ear and neither seems to work.

my ear is structured as follows

EAR

META-INF/MANIFEST.MF
META-INF/application.xml
MyEntities1.jar
MyEntities2.jar
persistence.xml
orm.xml

Is it possible to store the persistence.xml in an ear file?
I want to inject an entity manager into a spring bean using a setter but in my config I only have access to a object of type EntityManagerFactory

I want the following:


In my spring config I get the entity manager factory from JNDI:


So when I want to inject that entityManager into my spring bean I use the following:


Which calls the setter on my bean but I of course get an exception saying that I cannot set a type of EntityManger using a EntityManagerFactory type
11 years ago