Spring DM und Spring Framework

G

Gast2

Gast
Hallo zusammen,

ich habe als ich angefangen hab mich mit Spring zu beschäftigen die Spring Framework Bundles ganz normal als jar dem ClassPath hinzugefügt. Jetzt wollte ich diese aber richtig als Bundles mit Spring DM zusammen nutzen und einbinden. Das versuche ich grad umzustellen.
Also Spring DM alleine mit ein paar Servicen funktionierte ganz gut.
Und davor hatte ich eine kleine Anwendung die eine DB connection mit Spring/Hibernate macht(ohne App Server !!!), das hat auch ganz gut geklappt. Doch jetzt die beiden Sachen zu kombinieren scheitert kläglich. Ich weiß nicht genau wo der Fehler liegt, darum kann sein dass ich eventuell zuviel Info poste:
Also ich habe meine app.xml in mein Bundle Meta-Inf/spring gelegt damit, der der Spring extender das einliest. Das klappt. Danach habe ich die benötigten package in mein Bundle importiert.
org.springframework.beans.factory.annotation,
org.springframework.context,
org.springframework.jdbc.support,
org.springframework.orm.hibernate3,
org.springframework.transaction.annotation

Die XML, die mit dem Spring Framework funktioniert hat, doch jetzt mit Spring DM nicht mehr richtig geht!
[XML]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:eek:sgi="http://www.springframework.org/schema/osgi"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
Index of /schema/context http://www.springframework.org/schema/context/spring-context.xsd
Index of /schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
Index of /schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">


<context:annotation-config />

<tx:annotation-driven transaction-manager="transactionManager" />

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>

<context:property-placeholder location="classpath:jdbc.properties" />

<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />


<!-- the DataSource (parameterized for configuration via a PropertyPlaceHolderConfigurer) -->
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>

<!-- Hibernate -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration" />
<property name="configLocation" value="hibernate.cfg.xml" />
<property name="dataSource" ref="dataSource" />
</bean>

<!-- Hibernate DAO -->
<bean id="kundenDAO" class="dao.impl.HibernateKundenDAOImpl" />
[/XML]

Die jdbc.properties und die hibernate.cfg.xml liegen immer noch im src Folder. Und die hibernate jar hab ich auch nicht verändert und sind immer noch dem classpath hinzugefügt.
Hier mal die Exception:
Java:
Feb 15, 2010 10:50:16 PM org.springframework.osgi.extender.internal.activator.ContextLoaderListener start
INFO: Starting [org.springframework.osgi.extender] bundle v.[1.2.1]
Feb 15, 2010 10:50:16 PM org.springframework.osgi.extender.internal.support.ExtenderConfiguration <init>
INFO: No custom extender configuration detected; using defaults...
Feb 15, 2010 10:50:16 PM org.springframework.scheduling.timer.TimerTaskExecutor afterPropertiesSet
INFO: Initializing Timer
Feb 15, 2010 10:50:16 PM org.springframework.osgi.extender.support.DefaultOsgiApplicationContextCreator createApplicationContext
INFO: Discovered configurations {osgibundle:/META-INF/spring/*.xml} in bundle [RCPTest (RCPTest;singleton:=true)]
Feb 15, 2010 10:50:17 PM org.springframework.context.support.AbstractApplicationContext prepareRefresh
INFO: Refreshing OsgiBundleXmlApplicationContext(bundle=RCPTest, config=osgibundle:/META-INF/spring/*.xml): startup date [Mon Feb 15 22:50:17 CET 2010]; root of context hierarchy
Feb 15, 2010 10:50:17 PM org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext unpublishContextAsOsgiService
INFO: Application Context service already unpublished
Feb 15, 2010 10:50:17 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from URL [bundleentry://4213.fwk27189676/META-INF/spring/client-context.xml]
Feb 15, 2010 10:50:18 PM org.springframework.core.io.support.PropertiesLoaderSupport loadProperties
INFO: Loading properties file from OSGi resource[classpath:jdbc.properties|bnd.id=4213|bnd.sym=RCPTest]
Feb 15, 2010 10:50:19 PM org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor stageOne
INFO: No outstanding OSGi service dependencies, completing initialization for OsgiBundleXmlApplicationContext(bundle=RCPTest, config=osgibundle:/META-INF/spring/*.xml)
Feb 15, 2010 10:50:19 PM org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@15cd9c0: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,transactionManager,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0,dataSource,sessionFactory,angebotModel,kundenModel,mitarbeiterModel,terminModel,angebotController,kundenController,mitarbeiterController,terminController,kundenDAO,connection,angebotDAO,propertyDAO,terminDAO,mitarbeiterDAO,kundenService,angebotService,connectionService,propertyService,terminService,mitarbeiterService,GrantView,PropertiesView,ViewAngebotSearch,ViewKundenSearch,ViewMitarbeiterSearch,AngebotEditor,KundenEditor,KundenTerminEditor,MitarbeiterEditor,MultiKundenEditor,DBObjectFactory,property]; root of factory hierarchy
Feb 15, 2010 10:50:19 PM org.springframework.osgi.extender.internal.support.DefaultOsgiBundleApplicationContextListener onOsgiApplicationEvent
SEVERE: Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=RCPTest, config=osgibundle:/META-INF/spring/*.xml))
java.lang.NoClassDefFoundError: org/hibernate/HibernateException
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.lang.Class.getDeclaredConstructors(Unknown Source)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:225)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:909)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:882)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
	... 20 more
Exception in thread "SpringOsgiExtenderThread-2" java.lang.NoClassDefFoundError: org/hibernate/HibernateException
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.lang.Class.getDeclaredConstructors(Unknown Source)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:225)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:909)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:882)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:479)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:557)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:842)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$1600(AbstractDelegatedExecutionApplicationContext.java:69)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:355)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.hibernate.HibernateException
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
	at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClassInternal(Unknown Source)
	... 20 more
Feb 15, 2010 10:53:14 PM org.springframework.osgi.extender.internal.activator.ContextLoaderListener shutdown
INFO: Stopping [org.springframework.osgi.extender] bundle v.[1.2.1]
Feb 15, 2010 10:53:14 PM org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext unpublishContextAsOsgiService
INFO: Application Context service already unpublished
Feb 15, 2010 10:53:14 PM org.springframework.context.support.AbstractApplicationContext doClose
INFO: Closing OsgiBundleXmlApplicationContext(bundle=RCPTest, config=osgibundle:/META-INF/spring/*.xml): startup date [Mon Feb 15 22:50:17 CET 2010]; root of context hierarchy
Feb 15, 2010 10:53:14 PM org.springframework.osgi.extender.internal.support.DefaultOsgiBundleApplicationContextListener onOsgiApplicationEvent
SEVERE: Application context close failed (OsgiBundleXmlApplicationContext(bundle=RCPTest, config=osgibundle:/META-INF/spring/*.xml))
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: OsgiBundleXmlApplicationContext(bundle=RCPTest, config=osgibundle:/META-INF/spring/*.xml): startup date [Mon Feb 15 22:50:17 CET 2010]; root of context hierarchy
	at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:320)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:950)
	at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.doClose(AbstractOsgiBundleApplicationContext.java:197)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:69)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:214)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:210)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextExecutor.java:374)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:236)
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:917)
	at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$1.run(ContextLoaderListener.java:522)
	at org.springframework.osgi.extender.internal.util.concurrent.RunnableTimedExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60)
	at org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:70)
	at java.util.TimerThread.mainLoop(Unknown Source)
	at java.util.TimerThread.run(Unknown Source)
Feb 15, 2010 10:53:14 PM org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor close
SEVERE: Could not succesfully close context OsgiBundleXmlApplicationContext(bundle=RCPTest, config=osgibundle:/META-INF/spring/*.xml): startup date [Mon Feb 15 22:50:17 CET 2010]; root of context hierarchy
java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: OsgiBundleXmlApplicationContext(bundle=RCPTest, config=osgibundle:/META-INF/spring/*.xml): startup date [Mon Feb 15 22:50:17 CET 2010]; root of context hierarchy
	at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:320)
	at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:950)
	at org.springframework.osgi.context.support.AbstractOsgiBundleApplicationContext.doClose(AbstractOsgiBundleApplicationContext.java:197)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.access$501(AbstractDelegatedExecutionApplicationContext.java:69)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$2.run(AbstractDelegatedExecutionApplicationContext.java:214)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.normalClose(AbstractDelegatedExecutionApplicationContext.java:210)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.close(DependencyWaiterApplicationContextExecutor.java:374)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.doClose(AbstractDelegatedExecutionApplicationContext.java:236)
	at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:917)
	at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$1.run(ContextLoaderListener.java:522)
	at org.springframework.osgi.extender.internal.util.concurrent.RunnableTimedExecution$MonitoredRunnable.run(RunnableTimedExecution.java:60)
	at org.springframework.scheduling.timer.DelegatingTimerTask.run(DelegatingTimerTask.java:70)
	at java.util.TimerThread.mainLoop(Unknown Source)
	at java.util.TimerThread.run(Unknown Source)
Feb 15, 2010 10:53:14 PM org.springframework.scheduling.timer.TimerTaskExecutor destroy
INFO: Cancelling Timer

Also ich sehe dass er meine xml liest und versucht die beans zu laden. Und ich denke mal es scheitert an der DB verbindung. Was mit total schleierhaft ist, dass er die Hibernate Klassen nicht findet, weil die jars liegen im classpath. Oder muss ich diese jetzt mit Spring DM anders einbinden? Weil sobald die Sache mit der Datenbank, das mit der sessionFactory draußen lasse bekomme ich keinen Fehler mehr

Danke für jeden Ratschlag!
 
Zuletzt bearbeitet von einem Moderator:

fkh

Mitglied
Grundsätzlich gibt es zwei Ansätze, wie du Bibliotheken in Bundles einbinden kannst.

Meine präferierte Methode wäre, die Hibernate-Bibliotheken als Bundle im OSGI-Container zu deployen und in meinen eigenen Bundles via package import einzubinden (geht auch mit require bundle, soll man aber nicht machen wenn nicht unbedingt notwendig). Das Spring Team hat da schon einige Bibliotheken vorgefertigt, damit diese "OSGI-tauglich" sind, zu finden hier SpringSource Enterprise Bundle Repository Diese einfach in deinen OSGI-Container deployen (in Equinox z. B. in den plugin-Ordner, beim dm-server kannst es aus dem Eclipse Tool im STS heraus runterladen und deployen).

Der andere Ansatz wäre, die Bibliotheken in deinem Bundle in einen Unterordner zu kopieren und im Manifest den Pfad anzugeben. Dieser Ansatz eignet sich u. U. dann, wenn du ausschließen kannst, dass andere Bundles jemals Hibernate-Bibliotheken benötigen werden. Ansonsten widerspricht das meiner Meinung nach aber dem Grundgedanken von OSGI, weshalb ich das fast nie einsetze.

Hoffe, dass hilft dir mit deiner Problematik.

Gruß
fkh
 
G

Gast2

Gast
Grundsätzlich gibt es zwei Ansätze, wie du Bibliotheken in Bundles einbinden kannst.

Meine präferierte Methode wäre, die Hibernate-Bibliotheken als Bundle im OSGI-Container zu deployen und in meinen eigenen Bundles via package import einzubinden (geht auch mit require bundle, soll man aber nicht machen wenn nicht unbedingt notwendig). Das Spring Team hat da schon einige Bibliotheken vorgefertigt, damit diese "OSGI-tauglich" sind, zu finden hier SpringSource Enterprise Bundle Repository Diese einfach in deinen OSGI-Container deployen (in Equinox z. B. in den plugin-Ordner, beim dm-server kannst es aus dem Eclipse Tool im STS heraus runterladen und deployen).

Warum nutzt du Hibernate nicht auch als OSGi Bundle?

Ja ich hab die hibernate jars runtergeladen, aber irgenwie wurden diese mir nicht als bundles angezeigt, muss ich nochmal versuchen...

Der andere Ansatz wäre, die Bibliotheken in deinem Bundle in einen Unterordner zu kopieren und im Manifest den Pfad anzugeben. Dieser Ansatz eignet sich u. U. dann, wenn du ausschließen kannst, dass andere Bundles jemals Hibernate-Bibliotheken benötigen werden. Ansonsten widerspricht das meiner Meinung nach aber dem Grundgedanken von OSGI, weshalb ich das fast nie einsetze.

Hoffe, dass hilft dir mit deiner Problematik.

Gruß
fkh

Ja das habe ich ja so versucht, klappt aber nicht. Aber die andere Lösung hört sich eh besser an :D...
 
M

maki

Gast
Hibernate in OSGi ist nciht so dolle, da sieht man erst mal wie "invasive" Hibernate wirklich ist.
*EclipseLinkEmpfehl*
 
G

Gast2

Gast
Hibernate in OSGi ist nciht so dolle, da sieht man erst mal wie "invasive" Hibernate wirklich ist.
*EclipseLinkEmpfehl*

Ja dann muss ich nochmal die Persitenz Schicht austauschen mal schauen wieviel Aufwand das ist, muss ich ja auch neu einlesen in EclipseLink noch nie was mitgemacht.
 
M

maki

Gast
Du wirst dich ärgern dass du es nciht gleich mit EclipseLink gemacht hast, Hibernate verwendet dynamische Proxies, jedes Bundle das Entities verwendet ist dann vom Hibernate Bundle (und dem riesiegen Rattenschwanz) abhängig.
 

Noctarius

Top Contributor
Wenn du durchweg JPA genutzt hast ist der Wechsel auf EclipseLink ned so umständlich. Den Rest hat maki schon gesagt, EclipseLink ist besser als Hibernate :p
 
G

Gast2

Gast
Du wirst dich ärgern dass du es nciht gleich mit EclipseLink gemacht hast, Hibernate verwendet dynamische Proxies, jedes Bundle das Entities verwendet ist dann vom Hibernate Bundle (und dem riesiegen Rattenschwanz) abhängig.

Okay dann werd ich das mal versuchen ;)

Wenn du durchweg JPA genutzt hast ist der Wechsel auf EclipseLink ned so umständlich. Den Rest hat maki schon gesagt, EclipseLink ist besser als Hibernate :p

Ja ich glaub ich hab durchweg JPA verwendet. Mir machen mehr die Konfigurationsdateien sorgen :D...
Aber da es eh nur zum Lernen ist schadet es bestimmt nicht beides zu versuchen ;)...

Also EclipseLink hab ich mir die Bundle mal runtergeladen und eingebunden.
Wenn ich das richtig verstanden hab und Hibernate benutzen will, dann muss ich die Bundles von Spring Repository runterladen und nicht die von Hibernate(weil die jars lassen sich irgendwie nicht einbinden)
 

Noctarius

Top Contributor
Ja aber wie gesagt Hibernate nutzt Dynamic Proxies was bei OSGi mit den HibernateSessions schwer Probleme machen kann.

Die Persistence Config sollte eigentlich (da JPA Standard) relativ einfach zu adaptieren sein.
 
G

Gast2

Gast
Ja aber wie gesagt Hibernate nutzt Dynamic Proxies was bei OSGi mit den HibernateSessions schwer Probleme machen kann.

Die Persistence Config sollte eigentlich (da JPA Standard) relativ einfach zu adaptieren sein.

Okay alles klar werd ich mal versuche.
Gibts gute Plugins für die eclipde IDE, zur Unterstützung?
 

Noctarius

Top Contributor
Für EclipseLink? Japp!

Allgemein zu JPA und EclipseLink
EclipseLink/Examples/JPA - Eclipsepedia

Zitat zu EclipseLink und Eclipse
EclipseLink's inclusion in the Eclipse IDE for Java EE Developers combined with the extended support in WTP's Dali Java Persistence Tools project allows developers to start building JPA enabled applications quickly and easily. The Dali integration allows developers to optionally select EclipseLink as their JPA implementation and have it automatically added to their project classpath. This support along with Dali's rich validation and intelligent code assist provide a highly productive environment for developing, testing, packaging, and deploying JPA enabled applications.
 
G

Gast2

Gast
Also die die Db Objekte umzustellen war kein Problem das ich die JP benutz habe...
Aber jetzt muss ich meine ganzen DAOs ändern da ich die Criteria und sessionFactory von hibernate benutzt habe ...
 

Noctarius

Top Contributor
Joar aber das sollte nicht so schlimm sein, nimm das DaoJpaTemplate von Spring (oder war es JpaDaoTemplate?) - irgendwie sowas ^^
 
G

Gast2

Gast
Muss ich eigentlich den EntityManager injecten oder EntityManagerFactory? Irgendwie seh ich immer unterschiedlich Beispiele...

Naja find bis jetzt find ich es schon ein großer Unterschied ich hab alles mit Criterias gemacht... Und die Criteria Api sieht ganz anders aus...
 

Noctarius

Top Contributor
Puh müsst ich in der Firma nachsehen was ich injected hab. Aber ich glaube ich hatte mir immer direkt den EntityManager ins Template injecten lassen.
 
G

Gast2

Gast
Puh müsst ich in der Firma nachsehen was ich injected hab. Aber ich glaube ich hatte mir immer direkt den EntityManager ins Template injecten lassen.

Ja so hab ichs auch grad... Ich seh grad irgendwie noch keinen Vorteil vond em Template, nur dass ich nie Abhängigkeit zu Spring dann hab^^...

Und dass die Criteria API voll der Kraus ist... Ich glaub ohne Criteria bin ich besser dran...

EDIT:
Also mal ein kleines Beispiel in Hibernate war das mit den Criterias kein Problem das dynamisch zusammen zu bauen...
Wie würdest du sowas hier abfragen
Klasse kunde(id,name,wohnort)
Code:
public List<Kunde> getKunden(Kunde kunde)

so wenn die id gesetzt ist klar wird die abgefragt, wenn nicht wird geschaut ob name und/oder wohnort gesetzt und danach gefragt: In Hibernate sah das so aus. Fand ich eigentlich ganz praktisch und einfach. Wie würdest sowas mit JPA machen?
Java:
		Criteria crit = sessionFactory.getCurrentSession().createCriteria(Kunde.class);
		if(kunde.getId() != null){
		   crit.add(Restrictions.idEq(kunde.getId()));
		}else{
			if(kunde.getName() != null && !kunde.getName().isEmpty()){
				crit.add(Restrictions.like("name", kunde.getName()));
			}
			if(kunde.getVorname() != null && !kunde.getVorname().isEmpty()){
				crit.add(Restrictions.like("vorname", kunde.getVorname()));
			}
		}

return crit.list()
 
Zuletzt bearbeitet von einem Moderator:

Noctarius

Top Contributor
Zuletzt bearbeitet:
G

Gast2

Gast
Schau ich mir später mal an wenn die Sache mal läuft -.-...
Also ich bekomm beim Starten diese Fehlernachricht
Java:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL [bundleentry://4311.fwk27189676/META-INF/spring/client-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [bundleentry://4311.fwk27189676/META-INF/spring/client-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.eclipse.persistence.jpa.PersistenceProvider]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1004)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.registerBeanPostProcessors(AbstractDelegatedExecutionApplicationContext.java:542)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.registerBeanPostProcessors(AbstractDelegatedExecutionApplicationContext.java:486)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:336)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [bundleentry://4311.fwk27189676/META-INF/spring/client-context.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Cannot find class [org.eclipse.persistence.jpa.PersistenceProvider]

okay dann wollte ich das package org.eclipse.persistence.jpa impoertieren. Und dann werden mir auf einmal alle Bundles rot und unsatisfied angezeigt.
Dann hab ich versucht die dependencies mit zu importieren aber immer noch rot ???:L

EDIT: oder muss ich den org.eclipse.persistence.jpa.osgi.PersistenceProvider verwenden?
 
Zuletzt bearbeitet von einem Moderator:

Noctarius

Top Contributor
Ist die persistence.xml im richtigen Bundle? Ist die persistence.xml für den Classloader sichtbar?

Ich hab in der Firma die persistence.xml hier liegen:
src/main/resources/META-INF/persistence.xml
 
G

Gast2

Gast
Ja ich nehm das Meta-Inf wo eclipse anlegt so hab ich es auch in den Tutorials gesehen...
Im richtigen Bundle ist es auch, da ich grad noch keine Aufteilung hab ^^...
Wie sehe ich das ob es für den ClassLoader sichtbar ist...
In ein paar Tutorials hab ich gesehen, dass die noch einen Wert in eine HashMap reinschreiben bevor Sie den EntiyManager generieren... Aber das macht ja Spring für mich oder?
Injectest du jetzt den EntiyManager oder die Factory?
Ich poste nachher mal meine config vielleicht passt da schon was nicht.

EclipseLink – Persistence für OSGI Teil 1 Eclipse Stuff
Java:
org.eclipse.persistence.jpa.osgi.PersistenceProvider p =
new org.eclipse.persistence.jpa.osgi.PersistenceProvider();
Map map = new HashMap();
map.put(PersistenceUnitProperties.CLASSLOADER, Person.class
.getClassLoader());
EntityManagerFactory fac = p.createEntityManagerFactory(“personUnit”,
map);
EntityManager manager = fac.createEntityManager();

Und hier ganz unten, hab ich noch gelesen dass ich meine persistence-unit ins manifest eintragen soll... wie habt ihr das gemacht?
EclipseLink/Development/OSGi Proof of Concept - Eclipsepedia
 
Zuletzt bearbeitet von einem Moderator:

Noctarius

Top Contributor
So sieht mein AppContext aus, allerdings hab ich nen extra Project für nen VendorAdapter und einiges mehr

[xml]<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:eek:sgix="http://www.springframework.org/schema/osgi-compendium"
xsi:schemaLocation="
http: //www.springframework.org/schema/beans
http: //www.springframework.org/schema/beans/spring-beans.xsd
http: //www.springframework.org/schema/context
http: //www.springframework.org/schema/context/spring-context-2.5.xsd
http: //www.springframework.org/schema/tx
http: //www.springframework.org/schema/tx/spring-tx-2.5.xsd
http: //www.springframework.org/schema/osgi-compendium
http: //www.springframework.org/schema/osgi-compendium/spring-osgi-compendium-1.2-m2.xsd">

<context:annotation-config />
<context:component-scan base-package="com.opta.bnavi.jobservice.impl" />

<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" />

<osgix:cm-properties id="cmProps" persistent-id="com.opta.bnavi.jobservice" />

<context:property-placeholder
properties-ref="cmProps" />

<!--
Post-processor to perform exception translation on @Repository classes (from native exceptions
such as JPA PersistenceExceptions to Spring's DataAccessException hierarchy).
-->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />

<!--
regular spring configuration file defining the beans for this bundle. The configuration of OSGi
definitions is kept in a separate configuration file so that this file can easily be used for
integration testing outside of an OSGi environment
-->

<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.MySQLPlatform" />
<property name="showSql" value="true" />
</bean>

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jpa.datasource.driver}" />
<property name="url" value="${jpa.datasource.url}" />
<property name="username" value="${jpa.datasource.user}" />
<property name="password" value="${jpa.datasource.password}" />
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="dataSource" ref="dataSource" />
</bean>

<bean id="jobDao" class="com.opta.bnavi.jobservice.impl.JobDaoImpl">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<bean id="jobstatusDao" class="com.opta.bnavi.jobservice.impl.JobstatusDaoImpl">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>

<bean id="jobExporterService" class="com.opta.bnavi.jobservice.impl.JobExportServiceImpl">
<property name="jobstatusDao" ref="jobstatusDao" />
<property name="exporterList" ref="exporterList" />
</bean>

<bean id="jobServiceBean" class="com.opta.bnavi.jobservice.impl.JobServiceImpl">
<property name="jobExporterService" ref="jobExporterService" />
<property name="jobDao" ref="jobDao" />
</bean>

</beans>[/xml]
 
G

Gast2

Gast
Hier mal meine XML
[XML]
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:eek:sgi="http://www.springframework.org/schema/osgi"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
Index of /schema/context http://www.springframework.org/schema/context/spring-context.xsd
Index of /schema/osgi http://www.springframework.org/schema/osgi/spring-osgi.xsd
Index of /schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">


<context:annotation-config />

<context:property-placeholder location="classpath:jdbc.properties" />

<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />

<!-- the DataSource (parameterized for configuration via a PropertyPlaceHolderConfigurer) -->
<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>

<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor" />

<bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="databasePlatform" value="org.eclipse.persistence.platform.database.MySQLPlatform" />
<property name="showSql" value="true" />
</bean>

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
</bean>

<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="dataSource" ref="dataSource" />
</bean>
[/XML]

Persitence
[XML]
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="default">

<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

<class>class1</class>

<properties>
<!-- EclipseLink should create the database schema automatically -->
<property name="eclipselink.ddl-generation" value="create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
<property name="eclipselink.logging.level" value="INFO"/>
</properties>

</persistence-unit>
</persistence>

[/XML]

Ausgabe
Java:
EVERE: Application context refresh failed (OsgiBundleXmlApplicationContext(bundle=client, config=osgibundle:/META-INF/spring/*.xml))
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in URL [bundleentry://860.fwk10039797/META-INF/spring/client-context.xml]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [bundleentry://860.fwk10039797/META-INF/spring/client-context.xml]: Cannot resolve reference to bean 'jpaVendorAdapter' while setting bean property 'jpaVendorAdapter'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter] for bean with name 'jpaVendorAdapter' defined in URL [bundleentry://860.fwk10039797/META-INF/spring/client-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter not found from bundle [client]
Related cause: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter] for bean with name 'jpaVendorAdapter' defined in URL [bundleentry://860.fwk10039797/META-INF/spring/client-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter not found from bundle [client]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1004)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.registerBeanPostProcessors(AbstractDelegatedExecutionApplicationContext.java:542)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.registerBeanPostProcessors(AbstractDelegatedExecutionApplicationContext.java:486)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext$4.run(AbstractDelegatedExecutionApplicationContext.java:336)
	at org.springframework.osgi.util.internal.PrivilegedUtils.executeWithCustomTCCL(PrivilegedUtils.java:85)
	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.completeRefresh(AbstractDelegatedExecutionApplicationContext.java:320)
	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor$CompleteRefreshTask.run(DependencyWaiterApplicationContextExecutor.java:132)
	at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in URL [bundleentry://860.fwk10039797/META-INF/spring/client-context.xml]: Cannot resolve reference to bean 'jpaVendorAdapter' while setting bean property 'jpaVendorAdapter'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter] for bean with name 'jpaVendorAdapter' defined in URL [bundleentry://860.fwk10039797/META-INF/spring/client-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter not found from bundle [client]
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1305)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:385)
	at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:266)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:121)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:77)
	at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
	at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1422)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1389)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
	... 13 more
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter] for bean with name 'jpaVendorAdapter' defined in URL [bundleentry://860.fwk10039797/META-INF/spring/client-context.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter not found from bundle [client]

Sobald ich
Java:
org.springframework.orm.jpa.vendor
importiere geht gar nichts mehr !!!Unsatisfied so wie oben beschrieben... *grrrr* welche package hast du den impoertiert???
 
Zuletzt bearbeitet von einem Moderator:
G

Gast2

Gast
Vielleicht liegt es auch an der Version welche EclipseLink version benutzt du?
Ja und welche packages du von spring und eclipseLink importiert hast,
weil wenn ich EclipseLink ohne Spring laufen lass klappts wunderbar, da ich das package nicht importieren muss...
 
Zuletzt bearbeitet von einem Moderator:
G

Gast2

Gast
Derzeit noch 1.1.0

Wollt ihr umstellen?
Naja wie gesagt ich steh grad in einer Sackgasse irgendwie egal was ich versuch wills nicht klappen...
Die Tutorials sagen dazu nichts aus...
Also EclipseLink alleine zu benutzen hat geklappt... Aber in Kombi mit Spring will es nicht klappen weil er immer die Klasse nicht findet... Und wie ich diese importierte geht gar nichts mehr...
Des witzige ist ja dass ich dass jpa.support und das jpa selber ohne Probleme importieren kann, nur das Vendor package nicht???:L???:L
Hab ihr das vendor package importiert?

EDIT:Was ich auch noch komisch finde, dass mein XML Editor diese Klasse erkennt und ich wenn ich drüber fahre zu der hinspringen kann ...
 
Zuletzt bearbeitet von einem Moderator:
G

Gast2

Gast
2.0 bringt JPA 2.0 mit, aber ist das denn schon komplett freigegeben jetzt? Bisher wusste ich nur von EclipseLink 1.2

Ja gibts ein release... Also ich habe Spring Dm 1.2.1 mir Spring 3.0 und Eclipse Link 2.0!!!
Aber da es dann ne funktioniert hat habe ich Eclipse Link 1.2 ausprobiert, kam aber genau an das gleiche Problem. Wie gesagt hab Eclipse Link allein in einem RCP ausprobiert und mit den EntityManager selber erstellt hat geklappt(dazu musste ich NICHT org.eclipse.persitence.jpa impoertieren). Und Spring und Spring DM haben davor auch funktioniert. Nur wenn ich beides jetzt kombiniere klappt es nicht.
Bekomme immer die Fehlermeldung von oben dass er die Klasse nicht findet. Importier ich das package meckert die IDE... Also ziemlich ratlos ^^...
 

Noctarius

Top Contributor
Dann hast du eine falsche Version des Packages welches du importierst. Sagt der Fehler doch. Sicher, dass deine Spring Version gegen EclipseLink 2.0 gelinkt ist? (ich würde vermuten - nein).
 
G

Gast2

Gast
Dann hast du eine falsche Version des Packages welches du importierst. Sagt der Fehler doch. Sicher, dass deine Spring Version gegen EclipseLink 2.0 gelinkt ist? (ich würde vermuten - nein).

Ja EclipseLink 2.0 mit Spring 3.0!!! Ja aber er meckert mir meine Bundles an und nicht das package!!! Und ich importiere ja das Spring package, wie gesagt so ganz versteh ich es nicht... Sobald das package draußen ist sind die Fehler weg...

Spring Framework 3.0 goes GA | SpringSource Team Blog
 
Zuletzt bearbeitet von einem Moderator:
G

Gast2

Gast
Also hab mir mal das neue Release runter geladen, aber LEIDER ;( gleiches Ergebnis
Hier mal meine Manifest Datei...Sobald das package drin ist bekomme ich Probleme...
 

Anhänge

  • rcp1.jpg
    rcp1.jpg
    18,6 KB · Aufrufe: 24
  • rcp2.jpg
    rcp2.jpg
    24,6 KB · Aufrufe: 22
G

Gast2

Gast
Vielleicht fehlen ja noch mehr Packages?

Darum frag ich welche du alle importiert hast!!!Wo seh ich welche packages ich alle benötige??? Ja gut ich hab auch mal versucht die Plugins direkt zu adden mit den abhänigkeiten, aber hat auch net ganz funktioniert!!!

naja die 2 package funktionieren ja auch
[XML]
org.springframework.orm.jpa,
org.springframework.orm.jpa.support
[/XML]
 
Zuletzt bearbeitet von einem Moderator:
G

Gast2

Gast
ah ich hab mal was gefunden!!! Denk mal dass ich die alle importieren muss ^^... Mal versuchen
[XML]
org.springframework.orm.jpa.vendor;version="3.0.1.RELEASE-
A";uses:="javax.persistence,javax.persistence.spi,oracle.toplink.esse
ntials.sessions,org.apache.openjpa.persistence,org.eclipse.persistenc
e.sessions,org.hibernate,org.springframework.dao,org.springframework.
jdbc.datasource,org.springframework.orm.jpa,org.springframework.trans
action"
[/XML]

EDIT: naja ein paar hab ich gar net, aber ich glaub auch nicht dass ich wiklich alle brauch weil hibernate verwende ich ja net... mhm...
 
Zuletzt bearbeitet von einem Moderator:

Noctarius

Top Contributor
Code:
<Import-Package>*, org.springframework.jdbc.datasource,
org.springframework.jdbc.datasource.lookup, com.mysql.jdbc,
org.springframework.orm.jpa.vendor,
org.springframework.instrument.classloading,
javax.xml.namespace,
org.apache.commons.dbcp, org.springframework.context.weaving,
org.springframework.transaction.aspectj,
org.springframework.transaction.interceptor,
org.springframework.dao.annotation,
org.eclipse.persistence.internal.weaving,
org.eclipse.persistence.internal.descriptors,
org.eclipse.persistence.queries,
org.eclipse.persistence.descriptors.changetracking,
org.eclipse.persistence.indirection,
org.eclipse.persistence.sessions,
org.eclipse.persistence.internal.identitymaps,
org.eclipse.persistence.expressions, javax.persistence.spi,
org.springframework.aop,
org.springframework.aop.framework,
net.sf.cglib.proxy, org.aopalliance.aop, net.sf.cglib.core,
net.sf.cglib.reflect, org.springframework.dao.support,
org.eclipse.persistence.internal.libraries.antlr.runtime,
org.apache.xbean.spring, org.apache.xbean.spring.context,org.apache.xbean.spring.util,
org.apache.activemq, org.apache.activemq.spring, org.apache.activemq.command,
com.mysql.jdbc</Import-Package>
 
G

Gast2

Gast
So dann probier ich das mal :D

Awa des hilft alles nichts ;(;(;(;(
Code:
javax.persistence,
 javax.persistence.spi,
 javax.xml.namespace,
 org.aopalliance.aop,
 org.apache.commons.dbcp,
 org.apache.derby.jdbc,
 org.eclipse.persistence.descriptors.changetracking,
 org.eclipse.persistence.expressions,
 org.eclipse.persistence.indirection,
 org.eclipse.persistence.internal.descriptors,
 org.eclipse.persistence.internal.identitymaps,
 org.eclipse.persistence.internal.weaving,
 org.eclipse.persistence.queries,
 org.eclipse.persistence.sessions,
 org.eclipse.springframework.util,
 org.springframework.aop,
 org.springframework.aop.framework,
 org.springframework.beans.factory,
 org.springframework.beans.factory.annotation,
 org.springframework.context.weaving,
 org.springframework.dao,
 org.springframework.dao.annotation,
 org.springframework.dao.support,
 org.springframework.instrument.classloading,
 org.springframework.jdbc.datasource,
 org.springframework.jdbc.datasource.lookup,
 org.springframework.orm.jpa,
 org.springframework.orm.jpa.support,
 org.springframework.transaction,
 org.springframework.transaction.aspectj,
 org.springframework.transaction.interceptor

Sobald ich irgendwas von org.eclipse.persistence reinmacht bäm alle rot =(...

EDIT:
Also wenn ich die reinmache
Code:
 org.eclipse.persistence.descriptors.changetracking,
 org.eclipse.persistence.expressions,
 org.eclipse.persistence.indirection,
 org.eclipse.persistence.internal.descriptors,
 org.eclipse.persistence.internal.identitymaps,
 org.eclipse.persistence.queries,
 org.eclipse.persistence.sessions,
 
Zuletzt bearbeitet von einem Moderator:
G

Gast2

Gast
Dann stimmt halt irgendwas nicht mit den Bundles oder Versionen, ich bleib dabei

Ich versuch mal ein OSGi Bundle anzulegen und kein Equinox ...
Mhm wie bekomm ich raus dass etwas nicht mit der Version stimmt?
Hab EclipseLink 2.0.1 und Spring 3.0.1A!!!

EDIT: Also wenn ich ein normales OSGi Bundle anlege meckert mein Manifest zumindest mal nicht rum...

EDIT EDIT: Kannst ja mal versuchen ein Equniox Bundle anzulegen und die Sachen zu importieren ob des bei dir klappt... Sobald ich Equinox verwende und was importiere meckert an den required Bundles rum
 
Zuletzt bearbeitet von einem Moderator:
Ähnliche Java Themen
  Titel Forum Antworten Datum
D Was ist das Framework "Spring"? Frameworks - Spring, Play, Blade, Vaadin & Co 1
N Buch zum Spring Framework bzw. Spring Boot Frameworks - Spring, Play, Blade, Vaadin & Co 3
8u3631984 Welches Spring Frontend Framework verwendet ihr und wie bzw wo ? Frameworks - Spring, Play, Blade, Vaadin & Co 7
W Projekt Bootstrap/Kotlin/Spring Framework Frameworks - Spring, Play, Blade, Vaadin & Co 0
W Kotlin / Spring Framework Frameworks - Spring, Play, Blade, Vaadin & Co 3
T Einführung in das Spring MVC Framework Frameworks - Spring, Play, Blade, Vaadin & Co 0
L Dependency Injection mit Spring Framework Frameworks - Spring, Play, Blade, Vaadin & Co 5
Puppetmaster Benötige Buchempfehlung zum Spring-Framework Frameworks - Spring, Play, Blade, Vaadin & Co 1
P Spring Framework Terminologie Frameworks - Spring, Play, Blade, Vaadin & Co 0
K Spring Framework und EJB Komponenten mischen Frameworks - Spring, Play, Blade, Vaadin & Co 1
G Spring Framework in Eclipse einbinden Frameworks - Spring, Play, Blade, Vaadin & Co 0
8u3631984 Ist es möglich in Spring Entity generische Listen verwenden Frameworks - Spring, Play, Blade, Vaadin & Co 3
R Spring Boot Test Assertions mit Objekten Frameworks - Spring, Play, Blade, Vaadin & Co 6
8u3631984 Pfad zu Test Datei in application.yml in Spring Boot Test Frameworks - Spring, Play, Blade, Vaadin & Co 7
R Spring Boot sql Beziehungen Frameworks - Spring, Play, Blade, Vaadin & Co 12
8u3631984 Spring JPA Probleme beim SPeichern von Sets Frameworks - Spring, Play, Blade, Vaadin & Co 3
M Spring Boot 3 Datenbanken zur Laufzeit Verbinden Frameworks - Spring, Play, Blade, Vaadin & Co 5
8u3631984 Spring JDBC Probleme beim Spaltennamen Frameworks - Spring, Play, Blade, Vaadin & Co 3
LimDul Spring-Batches in Docker über Rest starten/verfolgen Frameworks - Spring, Play, Blade, Vaadin & Co 0
ExceptionOfExpectation In Meiner Spring-Boot Applikation verlangt die Datenbank Wert für eine ID Frameworks - Spring, Play, Blade, Vaadin & Co 5
H Spring Boot Applikation und JHM Benchmark sowie ContextConfiguration in H2 Tests ich bekomme es nicht hin Frameworks - Spring, Play, Blade, Vaadin & Co 2
ExceptionOfExpectation Tests in Spring-Boot Frameworks - Spring, Play, Blade, Vaadin & Co 4
R Eure Erfahrungen mit Primefaces und Spring - wer managed die Beans Frameworks - Spring, Play, Blade, Vaadin & Co 4
Avalon Get Request doppelt abfeuern ohne Post Redirect Get Pattern. Spring Boot Thymeleaf MVC Frameworks - Spring, Play, Blade, Vaadin & Co 12
thor_norsk Konfigurationsprobleme mit Spring Boot Frameworks - Spring, Play, Blade, Vaadin & Co 9
R Spring Boot Integration-testing mit Keycloak Frameworks - Spring, Play, Blade, Vaadin & Co 1
R Spring Boot Integration-testing mit Keycloak Frameworks - Spring, Play, Blade, Vaadin & Co 13
L Spring Data und Rest Controller? Frameworks - Spring, Play, Blade, Vaadin & Co 4
thor_norsk Spring Boot Fehler Frameworks - Spring, Play, Blade, Vaadin & Co 1
L Spring Data und Rest Conroller? Frameworks - Spring, Play, Blade, Vaadin & Co 4
thor_norsk Spring Boot und Docker Frameworks - Spring, Play, Blade, Vaadin & Co 5
B Spring Amazon-SP-Api Frameworks - Spring, Play, Blade, Vaadin & Co 3
8u3631984 Aktualisiere Spring Controller Frameworks - Spring, Play, Blade, Vaadin & Co 4
L Spring Data: Modellierung mit einer Embeddable bean Frameworks - Spring, Play, Blade, Vaadin & Co 2
D Spring Boot Test ob Validation geprüft wurde Frameworks - Spring, Play, Blade, Vaadin & Co 8
K Spring Boot OneToMany Frameworks - Spring, Play, Blade, Vaadin & Co 6
8u3631984 Spring Boot Docker Image erstellen und mit docker-compose konfigurieren Frameworks - Spring, Play, Blade, Vaadin & Co 1
M Wann Spring Batch nutzen? Frameworks - Spring, Play, Blade, Vaadin & Co 1
P Spring Hessian Remote Beispiel Frameworks - Spring, Play, Blade, Vaadin & Co 20
8u3631984 Spring 2.7.8 Info Enpoint nicht zuerreichen Frameworks - Spring, Play, Blade, Vaadin & Co 1
gradlew.bat spring-boot:run funktioniert nicht Frameworks - Spring, Play, Blade, Vaadin & Co 4
Zrebna Spring Boot/Thymeleaf: Bestätigungsemail senden. Frameworks - Spring, Play, Blade, Vaadin & Co 2
Zrebna Spring - Thymeleaf: Wieso wird gem. Fallunterscheidung entsprechende View nicht geladen? Frameworks - Spring, Play, Blade, Vaadin & Co 3
Dimax Spring UsernameNotFoundException(msg); auf der View msg ausdrücken Frameworks - Spring, Play, Blade, Vaadin & Co 1
Dimax Spring UsernameNotFoundException(Message) auf der View Message ausdrücken Frameworks - Spring, Play, Blade, Vaadin & Co 2
B Spring Boot und JPA Error creating bean Frameworks - Spring, Play, Blade, Vaadin & Co 24
R Spring Security: Wie kommt 'UserDetails' an Username und Passwort ran? Frameworks - Spring, Play, Blade, Vaadin & Co 6
R Spring Security: Wie den User dynamisch authentifizieren? Frameworks - Spring, Play, Blade, Vaadin & Co 8
R Spring Security: Authentication & Permissions Frameworks - Spring, Play, Blade, Vaadin & Co 4
R Spring Boot: Warum soll PasswordEncoder in einer neuen Methode definiert sein? Frameworks - Spring, Play, Blade, Vaadin & Co 1
8u3631984 Cross-Origin beim Abrufen von Spring Endpoint Frameworks - Spring, Play, Blade, Vaadin & Co 1
D Spring Boot und Microservices Frameworks - Spring, Play, Blade, Vaadin & Co 1
M Spring Boot additional Datasource for a single entity Frameworks - Spring, Play, Blade, Vaadin & Co 0
T Spring Resourcen Ordner ermitteln Frameworks - Spring, Play, Blade, Vaadin & Co 5
B Spring JPA und Repository Frameworks - Spring, Play, Blade, Vaadin & Co 12
D Mapstruct Dependency Injection funktioniert nicht mit Spring Frameworks - Spring, Play, Blade, Vaadin & Co 15
Avalon Wie sieht bei Euch das Deployment einer Spring Boot Anwendung aus? Frameworks - Spring, Play, Blade, Vaadin & Co 4
M Threads in Spring Boot Frameworks - Spring, Play, Blade, Vaadin & Co 7
W DI-Problem in Spring Boot Frameworks - Spring, Play, Blade, Vaadin & Co 4
T Spring Boot: Was bewirkt parent in maven genau? Frameworks - Spring, Play, Blade, Vaadin & Co 4
T Spring Security: Run-as replacement Einsatzbereich? Frameworks - Spring, Play, Blade, Vaadin & Co 1
OnDemand Vaadin+Spring Boot erster Seitenload nach Neustart endlos Frameworks - Spring, Play, Blade, Vaadin & Co 0
doncarlito87 Wie erhalte ich ein JSON aus eine NativeQuery (Spring Boot)? Frameworks - Spring, Play, Blade, Vaadin & Co 8
Avalon @Query Select Abfrage liefert falsche Werte (Spring Boot, JPA, Hibernate) Frameworks - Spring, Play, Blade, Vaadin & Co 3
Avalon Erstellung Dockerimage mit spring-boot:build-image in Spring Boot mit Umgebungsvariablen Frameworks - Spring, Play, Blade, Vaadin & Co 0
N Spring Integration - Logging Frameworks - Spring, Play, Blade, Vaadin & Co 7
D Spring Boot Field Injection in MapStruct Frameworks - Spring, Play, Blade, Vaadin & Co 5
D Spring Anfänger benötigt Hilfe Frameworks - Spring, Play, Blade, Vaadin & Co 9
OnDemand Spring Boot seltsame Logeinträge: Manipulationsversuche? Frameworks - Spring, Play, Blade, Vaadin & Co 2
D Spring Date keine neue Tabelle fuer Attribut Frameworks - Spring, Play, Blade, Vaadin & Co 1
T Spring Security Config File anpassen Frameworks - Spring, Play, Blade, Vaadin & Co 1
8u3631984 Spring Cloud : Resttemplate mit Loadballancer Frameworks - Spring, Play, Blade, Vaadin & Co 11
Dimax Spring resource not found Frameworks - Spring, Play, Blade, Vaadin & Co 2
M Spring MongoDB unique index Frameworks - Spring, Play, Blade, Vaadin & Co 3
M Spring Entity testen Frameworks - Spring, Play, Blade, Vaadin & Co 1
M Spring Entity testen Frameworks - Spring, Play, Blade, Vaadin & Co 5
Dimax Spring App Probleme beim Ausführen auf dem Tomcat Server Frameworks - Spring, Play, Blade, Vaadin & Co 1
D Spring WebFlux Cors konfigurieren Frameworks - Spring, Play, Blade, Vaadin & Co 1
Dimax Schöne View mit anchor scrolling in Spring Frameworks - Spring, Play, Blade, Vaadin & Co 2
Dimax Spring JPA Multiple Keys Frameworks - Spring, Play, Blade, Vaadin & Co 3
S Spring Security mit oauth2 in lokaler Konfiguration principal mocken Frameworks - Spring, Play, Blade, Vaadin & Co 0
D Spring Boot Mile Stone und Snapshot Versionen Frameworks - Spring, Play, Blade, Vaadin & Co 2
OnDemand Spring Boot Exception Body Frameworks - Spring, Play, Blade, Vaadin & Co 2
M Spring Unit/Integrations Testing Frameworks - Spring, Play, Blade, Vaadin & Co 3
D Spring Unit Test: UnsatisfiedDependencyException: Error creating bean with name Frameworks - Spring, Play, Blade, Vaadin & Co 2
H Resource Liste Lazy Autowired Spring Context Frameworks - Spring, Play, Blade, Vaadin & Co 2
M Java Spring Security Frameworks - Spring, Play, Blade, Vaadin & Co 5
M Spring Security Login with Credentials Frameworks - Spring, Play, Blade, Vaadin & Co 0
N Spring Boot - Overkill für private Projekte? Frameworks - Spring, Play, Blade, Vaadin & Co 3
krgewb Spring und GWT - & wird zu & amp; Frameworks - Spring, Play, Blade, Vaadin & Co 2
K Migration eines internen Frameworks zu Spring:Boot Frameworks - Spring, Play, Blade, Vaadin & Co 0
OnDemand JPA/Spring Repository Like Suche leeres Ergebnis Frameworks - Spring, Play, Blade, Vaadin & Co 0
Z Hibernate & Postgres in Spring Boot (Syntaxprobleme) Frameworks - Spring, Play, Blade, Vaadin & Co 2
Z Spring Boot mit JPA;, Hibernate, Rest & Lombok Frameworks - Spring, Play, Blade, Vaadin & Co 8
M Spring Initializer - Webservices Frameworks - Spring, Play, Blade, Vaadin & Co 0
D Spring Hateoas Frameworks - Spring, Play, Blade, Vaadin & Co 1
ma095 Spring und Postgresql Errors Frameworks - Spring, Play, Blade, Vaadin & Co 4
OnDemand Spring+Vaadin App startet nicht Frameworks - Spring, Play, Blade, Vaadin & Co 1
OnDemand Spring Request externe API SSL Error Frameworks - Spring, Play, Blade, Vaadin & Co 7
OnDemand Spring Repo speichert, aber es kommt in der DB nicht an Frameworks - Spring, Play, Blade, Vaadin & Co 3

Ähnliche Java Themen


Oben