This content has been marked as final.
Show 5 replies
-
1. Re: using jar file ref in persistence.xml
jherkel Aug 11, 2005 3:05 AM (in response to pesalomo)I have a same problem with <jar-file> in persistence.xml. I also tried to add this jar file to lib directory but I got same error output.
jakub -
2. Re: using jar file ref in persistence.xml
epbernard Aug 11, 2005 4:00 AM (in response to pesalomo)open a JIRA issue if none has been so far.
-
4. Re: using jar file ref in persistence.xml
harivenkat116 Nov 28, 2005 1:10 PM (in response to pesalomo)Hi, any update on this issue? I am still getting the error with 4.0.3 SP1.
I tried giving the following line in persistence.xml
<jar-file>DomainClasses.jar</jar-file>
but it didn't work.
Do you guys have any idea? -
5. Re: using jar file ref in persistence.xml
pesalomo Nov 29, 2005 3:55 AM (in response to pesalomo)Doesn't seem like anything has happened here. I've ended up referencing each indiviudal entity-class, though it's a little more work.
However if you have lot's of entity beans, and you need an efficient way to find them and create the xml-references for persitence.xml - try this little piece of code:import java.io.File; import java.lang.annotation.Annotation; /** * Tool to scan for all entity beans in a package and generate persistence.xml class entries * @author peter * */ public class GenPersistArchives { String basePath; String persistClasses = ""; public GenPersistArchives(String basePath) { this.basePath = basePath; File dir = new File(ClassLoader.getSystemResource(basePath).getPath()); scan(dir); System.out.println(persistClasses); } static final String translateToJavaPath(String uri) { // Translate into classname, and also handle subclasses String className = uri.replace(".class",""); if(className.indexOf("$1")>0) className = className.substring(0,className.indexOf("$1")); className = className.replace("/","."); return className; } private void scan(File dir) { for(File file : dir.listFiles()) { if(file.isDirectory()) scan(file); else { String relativePath = file.getPath(); relativePath = relativePath.substring(relativePath.indexOf(basePath)); String className = translateToJavaPath(relativePath); try { Class cls = Class.forName(className); for(Annotation ann : cls.getAnnotations()) { if(ann.annotationType().getName().equals(javax.persistence.Entity.class.getName())) { persistClasses+="<class>"+className+"</class>\n"; } } } catch(Exception e) { e.printStackTrace(); } } } } /** * @param args */ public static void main(String[] args) { // Package to scan new GenPersistArchives("com/lightminds/cms/ejb3"); } }
Good luck,
Peter