Bug 288383 - Spring Issues
Summary: Spring Issues
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Eclipselink (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P5 normal with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: spring
Keywords:
Depends on: 332336
Blocks: 219472 272690 292801 298286 300376 332950 332951 332952 309853 332953
  Show dependency tree
 
Reported: 2009-09-02 13:06 EDT by James Sutherland CLA
Modified: 2022-06-09 10:10 EDT (History)
6 users (show)

See Also:
michael.f.obrien: documentation+


Attachments
adds jpa test support for spring (103.73 KB, patch)
2009-09-14 09:45 EDT, James Sutherland CLA
no flags Details | Diff
removes temp class loader dependency from weaving (335.95 KB, patch)
2009-09-16 14:57 EDT, James Sutherland CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Sutherland CLA 2009-09-02 13:06:39 EDT
In investigating our Spring tests and trying to get all JPA tests running on Spring, I noticed several issues:

- Spring temp class loader excludes org.eclipse.persistence, oracle., this means any EclipseLink test/example using these packages will not weave/work.
- Spring ignores exclude-unlisted-classes=false (makes true), the only way to make false is to remove the element entirely.
- Spring cannot find jar-file elements on the classpath unless the directory the jars are in are also on the classpath.
Comment 1 James Sutherland CLA 2009-09-02 13:07:55 EDT
These are mainly Spring issues, so there is not much we can do other than logging bugs on Spring, document the issues, or waiting for the Spring 3.0 release to re-test.
Comment 2 James Sutherland CLA 2009-09-02 13:13:21 EDT
Also:
- Spring by default calls beginEarlyTransaction on beginTransaction, this will cause the shared cache to effectively be disabled.  They seem to do this to be able to have a single JDBC connection used, but seems very odd.  If they really need this, would probably be better to use exclusive connection properties.
Comment 3 Tom Ware CLA 2009-09-03 09:13:08 EDT
Setting target and priority.  To see what these settings mean see:

http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines
Comment 4 James Sutherland CLA 2009-09-14 09:45:56 EDT
Created attachment 147101 [details]
adds jpa test support for spring
Comment 5 James Sutherland CLA 2009-09-14 10:05:47 EDT
SVN main commit: Bug#288383 - Spring platform test support

- Adds support for running any JPA test on the Spring platform
- Added JPA test framework server platform for Spring
- Added, build, config files and test persistence.xml for Spring testing
- Added system property to set test server platform.
- Some JPA test fixes for serverifacation.
- Added SQLResultSetMappingTestSuite back to server tests (and fixed deadlock issue)

Any of the JPA tests should be able to run with Spring now.  You need to set the test server platform system property and add spring to the class path (is a run target in the spring test project).
The advanced and field-access tests should all pass except a single legitimate failure.  Weaving is currently disabled because of Spring issues in weaving org.eclipse.persistence classes.
Other test models will need there own config files.
Comment 6 James Sutherland CLA 2009-09-16 11:44:55 EDT
Removed our temp class loader dependecy to allow weaving of org.eclipse.persistence classes.  But found a bigger weaving issue.

The spring-agent does not load persistence contexts in premain, only when they get accessed.  This can be too late, as the classes can already have been loaded.

I added a work around to the tests for this, by forcing loading of the contexts before any test class is loaded, but this can be a major issue for users trying to use Spring.

Other workarounds include static weaving or no weaving, or using the eclipselink agent and not using a container factory in Spring.
Comment 7 James Sutherland CLA 2009-09-16 14:57:37 EDT
Created attachment 147367 [details]
removes temp class loader dependency from weaving
Comment 8 Michael OBrien CLA 2009-09-28 23:14:01 EDT
The hardcoded "C:/Engineering/EclipseLink" spring jar references in the .classpath should be refactored into relative paths
Comment 9 James Sutherland CLA 2009-09-29 10:33:32 EDT
SVN Commit: Bug#288383

 

https://bugs.eclipse.org/bugs/show_bug.cgi?id=288383

 

Code Review: Andrei

 

Changes:

- Fixed issue of null session in getReference

- Moved weaving classes into JPA

- Enabled weaving in Spring tests

- Added method to initial platform to test framework to allow pre-loading of Spring context

- Switched weaving to use meta-data class

- Enabled weaving for platforms without a temp class loader

- Fixed typo in JPA XML schema loading
Comment 10 Igor Mukhin CLA 2014-10-21 09:36:05 EDT
Workaround to those who need to get shared cache to work:

@Bean
    public EntityManagerFactory entityManagerFactory() {
        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
        factory.setDataSource(dataSource());
        factory.setPersistenceUnitName("main");
        
        Properties jpaProps = new Properties();
        jpaProps.put(PersistenceUnitProperties.LOGGING_LOGGER, Slf4jSessionLogger.class.getName());
        jpaProps.put(PersistenceUnitProperties.ORDER_UPDATES, "true");
        jpaProps.put(PersistenceUnitProperties.UPPERCASE_COLUMN_NAMES, "true");
        factory.setJpaProperties(jpaProps);

        final EclipseLinkJpaDialect customDialect = new EclipseLinkJpaDialect() {
            @Override
            public ConnectionHandle getJdbcConnection(EntityManager entityManager, boolean readOnly) throws PersistenceException, SQLException {
                // Hides: return super.getJdbcConnection(entityManager, readOnly);
                return null;
            }
        };
        
        customDialect.setLazyDatabaseTransaction(true);
        
        EclipseLinkJpaVendorAdapter customAdapter = new EclipseLinkJpaVendorAdapter() {
            @Override
            public JpaDialect getJpaDialect() {
                return customDialect;
            }
        };
        
        customAdapter.setDatabase(Database.ORACLE);
        factory.setJpaVendorAdapter(customAdapter);

        factory.afterPropertiesSet();
        return factory.getObject();
    }
Comment 11 Mauro Molinari CLA 2014-11-03 12:02:40 EST
(In reply to James Sutherland from comment #0)
> - Spring ignores exclude-unlisted-classes=false (makes true), the only way
> to make false is to remove the element entirely.

I just opened bug #449800 to notify that this is not true since Spring 3.2.4 and 4.0.
Comment 12 Eclipse Webmaster CLA 2022-06-09 10:10:15 EDT
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink