[Hibernate-JIRA] Created: (EJB-242) Eclipse RCP + InputStreamZippedJarVisitor problem
by Michał Kostrzewa (JIRA)
Eclipse RCP + InputStreamZippedJarVisitor problem
-------------------------------------------------
Key: EJB-242
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-242
Project: Hibernate Entity Manager
Type: Bug
Components: EntityManager
Versions: 3.2.0.ga
Environment: Hibernate 3.2.0 GA, postgres (but I guess not relevant here)
Reporter: Michał Kostrzewa
Hi,
Max from user list kindly redirected me to fill a bug here. Here it goes as I described it on list. I didn't attached a test case b/c doing it is non-trivial, maybe you'll just know what is the problem and I provided a patch that works for me. But if test case is needed - I'll do it.
--------------
I'm having problems with bundling hibernate and my ejb model in eclipse RCP application. I managed to solve all classloading problems but one, related to InputStreamZippedJarVisitor class.
Simplifying things I have:
hibernate plugin which registers itself for buddy classloading policy
dbmodel plugin which depends on hibernate and is a buddy of hibernate
application plugin which depends on hibernate and dbmodel and is a buddy of hibernate. This application plugin has hibernate.cfg.xml in self.
When I run this project from eclipse IDE, all is fine except the warning message in logs while creating EntityManager:
2006-10-20 09:07:23 org.hibernate.ejb.packaging.InputStreamZippedJarVisitor doProcessElements
WARNING: Unable to find file (ignored): bundleresource://101
java.io.FileNotFoundException: C:\Documents and Settings\mkostrze\sv-head2\com.pentacomp.dbmodel (Access denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at org.eclipse.osgi.framework.util.SecureAction.getFileInputStream(SecureAction.java:99)
at org.eclipse.osgi.baseadaptor.bundlefile.FileBundleEntry.getInputStream(FileBundleEntry.java:50)
at org.eclipse.osgi.framework.internal.core.BundleURLConnection.connect(BundleURLConnection.java:53)
at org.eclipse.osgi.framework.internal.core.BundleURLConnection.getInputStream(BundleURLConnection.java:99)
at java.net.URL.openStream(URL.java:1007)
at org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doProcessElements(InputStreamZippedJarVisitor.java:33)
at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:215)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:253)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:229)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at com.pentacomp.dicom.viewer.ViewerContstants.createEntityManager(ViewerContstants.java:170)
at com.pentacomp.dicom.viewer.DicomViewerMainFrame$InitRepositoriesTask.call(DicomViewerMainFrame.java:146)
I suppose hibernate tries to inspect the model jar for some reason, but in IDE this jar location is resolved to directory containing the plugin.
But things get worse when I export the project into java webstart application. I'm getting NullPointerException instead of warning in the same place. I investigated the source and the problem is here:
protected void doProcessElements() throws IOException {
JarInputStream jis;
try {
jis = new JarInputStream( jarUrl.openStream() );
}
catch (IOException ze) {
log.warn( "Unable to find file (ignored): " + jarUrl, ze );
return;
}
The jarUrl is a bundleresource:// url which resolves to DirZipBundleEntry which in turn returns null in getInputStream(). Thus JarInputStream thows NPE.
Here's what I've tried to solve this:
- configure the dbmodel to be unpacked or packed after install
- tried dbmodel with jar inside or with unpacked classes inside
- set hibernate.archive.autodetection to 'none'. (I did it passing parameters map to createEntityManager method)
- change the hibernate sources and replace IOException with Exception in doProcessElement method. This one worked
I guess most likely I did something wrong to my deploy - any ideas please? But if not, perhaps such a change in code may make hibernate more robust (?)
Hibernate version: 3.2.0 GA
best regards,
Michal Kostrzewa
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 10 months
[Hibernate-JIRA] Created: (HHH-2352) ClassCastException in Session.get()
by Alexey Romanchuk (JIRA)
ClassCastException in Session.get()
-----------------------------------
Key: HHH-2352
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2352
Project: Hibernate3
Type: Bug
Components: core
Versions: 3.2.1
Environment: Hibernate 3.2.1
Reporter: Alexey Romanchuk
Priority: Critical
We have inheritance with joined-subclass mapping. Imagine that we have parent class - BaseObject and two subclasses - Client and Item. We enable second level cache on BaseObject.
try to load Client in first session
Client client = ( Client ) s1.get( Client.class, 1851727l );
after this we have this client in second level cache.
Next - load another subclass with same id:
Item item = ( Item ) s2.get( Item.class, 1851727l );
and here we have ClassCastException because hibernate found BaseObject (Client) and return it instead of null.
The solution is class check in org.hibernate.event.def.DefaultLoadEventListener.loadFromSecondLevelCache() function. This is crititcal bug that violates Session API.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 10 months
[Hibernate-JIRA] Created: (HBX-863) Hibernate Code Generation toolbar group is appearing in all Eclipse perspectives.
by John O'Shea (JIRA)
Hibernate Code Generation toolbar group is appearing in all Eclipse perspectives.
---------------------------------------------------------------------------------
Key: HBX-863
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-863
Project: Hibernate Tools
Type: Bug
Components: eclipse
Versions: 3.2beta9
Environment: All
Reporter: John O'Shea
Attachments: hib_tools.png
Currently the org.hibernate.eclipse.console plugin is contributing an action to the "org.eclipse.debug.ui.launchActionSet". Consequently, the icon for the action group containing the "Hibernate Code Generation....." action is appearing in all Eclipse perspectives. This is not really a good thing - it is polluting other perspectives that probably have no hibernate related functionality. For example the attached screenshot shows the Synchronize perspective toolbar, with the Hibernate group visible - not very useful (and perhaps confusing for users).
Could you perhaps move this action into a hibernate tools action set that is only displayed when the Hibernate Console (and maybe Java) perspective is active?
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 10 months
[Hibernate-JIRA] Created: (EJB-250) Ejb3Configuration class issue
by David Avenante (JIRA)
Ejb3Configuration class issue
-----------------------------
Key: EJB-250
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-250
Project: Hibernate Entity Manager
Type: Bug
Versions: 3.2.0.ga
Environment: Hibernate version : 3.2.0.ga.
Db : H2
Reporter: David Avenante
Priority: Minor
Hi,
I try for my test to use my entityManager out of container.
For that i instanciate my entityManagerFactory through the Ejb3Configuration helper.
All it's ok (annoted classes found, connection ok ...) but not my transactionType !!!!
i try to add the property "javax.persistence.transactionType" ->"RESOURCE_LOCAL" without success
After inspection of sources it's seem this property is available through the configure() method who need the name of a file configuration.
But i don't want that a want define my entityManager only programaticly.
Ok so after some investigations.
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addProperties(getProperties());
cfg.addAnnotatedClass(User.class);
entityManagerFactory = cfg.buildEntityManagerFactory();
private static Properties getProperties() {
Properties properties = new Properties();
properties.setProperty(Environment.DRIVER, DATABASE_DRIVER_CLASS);
properties.setProperty(Environment.URL, MEMORY_DATABASE_URL);
properties.setProperty(Environment.USER, USERNAME);
properties.setProperty(Environment.PASS, PASSWORD);
properties.setProperty(Environment.DIALECT, DBDIALECT);
properties.put(Environment.SHOW_SQL, "true");
properties.put(Environment.FLUSH_BEFORE_COMPLETION, "false");
properties.put(Environment.TRANSACTION_STRATEGY, PersistenceUnitTransactionType.RESOURCE_LOCAL);
properties.put(Environment.HBM2DDL_AUTO, "create");
return properties;
}
This code don't work because my entityManagerFactory doesn't have TransactionStrategy attached.
But if i use this code
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addProperties(getProperties());
cfg.addAnnotatedClass(User.class);
cfg.configure("hibernate.cfg.xml");
entityManagerFactory = cfg.buildEntityManagerFactory();
with a empty hibernate.cfg.xml config file like that ...
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
</session-factory>
</hibernate-configuration>
the entityManagerFactory have a transaction manager attached !!!!
You can reply me hey guys all is ok good but not really. Because we can see the cfg.configure("hibernate.cfg.xml") don't use a resource or an input stream but a string. So the location of my file must be in my source directory but i dont want that. I want to use my file in my test directory tree.
So emmanuel ask me to open and issue ;)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 10 months
[Hibernate-JIRA] Created: (EJB-257) EJB3Configuration still needing hibernate.cfg.xml for programatic EntityManagerConfiguration construction
by Khalil Bouhamza (JIRA)
EJB3Configuration still needing hibernate.cfg.xml for programatic EntityManagerConfiguration construction
---------------------------------------------------------------------------------------------------------
Key: EJB-257
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-257
Project: Hibernate Entity Manager
Type: Bug
Components: EntityManager
Versions: 3.2.0.ga
Environment: Hibernate 3.2.0 GA
Hibernate Annotations 3.2.0 GA
Hibernate Entity Manager 3.2.0 GA
Reporter: Khalil Bouhamza
Priority: Minor
Attachments: EJB3ConfigurationHibernateCfgXmlInitTest.java
I am opening this issue following Emmanuel's request on http://forum.hibernate.org/viewtopic.php?p=2332948#2332948
The tescase attached is a junit Test that shows that an empty hibernate.cfg.xml and the call cfg.configure("/mypath/hibernate.cfg.xml") as shown in the reference documentation http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/configu... is needed for EntityManagerFactory programatic construction.
The TestCase shows two scnerios with and without hibernate.cfg.xml. The scenarios are building a EntityManagerFactory and either try to persist or retrive an entity of type org.hibernate.ejb.test.Distributor included in HEM's test suite. The hibernate.cfg.xml file is genrated at Runtime and deleted upon VM exit, the varaiable HIBERNATE_CFG_XML_DIR should point to a folder on the classpath. It is created within the initWithHibernateCfgXML method and it is really a file with the bear minimum of empty tags. There are four tests, two failing and the other two passing, the passing tests create the temp XML config file if not already created, and then make the cfg.configure(resource) call, then simply invoke the corresponding failing test.
I hope the TestCase and the above explanation are describing the issue properly.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 10 months
[Hibernate-JIRA] Created: (EJB-260) OneToMany relationship not persiting merges
by Chadwick Baatz (JIRA)
OneToMany relationship not persiting merges
-------------------------------------------
Key: EJB-260
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-260
Project: Hibernate Entity Manager
Type: Bug
Versions: 3.2.1
Environment: MySQL 5.0x
Reporter: Chadwick Baatz
Priority: Blocker
Attachments: TestProject.zip
I am having problems with the merging of a detached object that has changed. The unidirectional OneToMany relationship is being updated in the Hibernate Context, but that update is not being persisted to the database. I've been able to prove that the Hibernate layer works correctly when either:
1. The object is not detached and I perform a persist
2. The object is detached I perform a merge before any changes, then persist after all changes have been made to the object.
However, if I have a detached object with modifications to the manged one and I perform a merge those changes are done to the managed object in the Hibernate Context, but the database statement is never fired to make the change in the database. Worse yet, any changes merged in this way are not updated on subsequent persist calls.
I've attached a sample project with test code that you can use to recreate the problem. You the SQL statements below to populate the database and you'll have to set up the connection in the persistence.xml file.
SQL Statements:
Create table customer (
customer_id Varchar(100) NOT NULL,
UNIQUE (customer_id),
Primary Key (customer_id)) ENGINE = InnoDB;
Create table customer_group (
customer_group_id Int UNSIGNED NOT NULL AUTO_INCREMENT,
name Varchar(250),
Primary Key (customer_group_id)) ENGINE = InnoDB;
Create table customer_group_customer (
customer_group_id Int UNSIGNED NOT NULL,
customer_id Varchar(100) NOT NULL,
Primary Key (customer_group_id,customer_id)) ENGINE = InnoDB;
Alter table customer_group_customer add Foreign Key (customer_id) references customer (customer_id) on delete restrict on update restrict;
Alter table customer_group_customer add Foreign Key (customer_group_id) references customer_group (customer_group_id) on delete restrict on update restrict;
Create table customer (
customer_id Varchar(100) NOT NULL,
UNIQUE (customer_id),
Primary Key (customer_id)) ENGINE = InnoDB;
Create table customer_group (
customer_group_id Int UNSIGNED NOT NULL AUTO_INCREMENT,
name Varchar(250),
Primary Key (customer_group_id)) ENGINE = InnoDB;
Create table customer_group_customer (
customer_group_id Int UNSIGNED NOT NULL,
customer_id Varchar(100) NOT NULL,
Primary Key (customer_group_id,customer_id)) ENGINE = InnoDB;
Alter table customer_group_customer add Foreign Key (customer_id) references customer (customer_id) on delete restrict on update restrict;
Alter table customer_group_customer add Foreign Key (customer_group_id) references customer_group (customer_group_id) on delete restrict on update restrict;
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 10 months
[Hibernate-JIRA] Created: (EJB-262) hbm.xml mapping errors have no context making it hard to track down the cause
by Max Rydahl Andersen (JIRA)
hbm.xml mapping errors have no context making it hard to track down the cause
-----------------------------------------------------------------------------
Key: EJB-262
URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-262
Project: Hibernate Entity Manager
Type: Improvement
Components: EntityManager
Versions: 3.2.1
Reporter: Max Rydahl Andersen
Starting a Ejb3Configuration on e.g. jpwh-essentials lab4 where there is an error in one of the 5 hbm.xml files one get an exception that states:
Caused by: javax.persistence.PersistenceException: org.hibernate.MappingException: invalid mapping
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:247)
... 16 more
Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:672)
at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:920)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:750)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:178)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:235)
... 16 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,resultset*,(query|sql-query)*)".
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:172)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:382)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2048)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:932)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanEndElement(XMLNSDocumentScannerImpl.java:719)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1685)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.AnnotationConfiguration.addInputStream(AnnotationConfiguration.java:668)
... 20 more
When entitymanager parses hbm.xml it apparently create alot of inputstreams and asks hibernate to parse them....the entitymanger should keep track of where those files come from and throw an exception stating which file/resource actually fails.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
18 years, 10 months