Bonjour,
Je suis nouveau dans la programmation, on m'a demandé de réaliser une application dont la partie web et réalisée en flex.
J'ai opté pour les thecno suivantes(BlazeDs, Spring,Blazeds Spring Intégration, Hibernate3 et ma base de donnée en Mysql).
Je développe sous éclipse et j'utilise le pluggin FlexBuilder3.
J'ai structuré mon appli à partir du blazeds.war.
Flex à accès au classe Java que j'ai utilisé pour faire des tests.
Ma partie DAO fonctionne je peut exécuter les methodes du crud dessus.
Je pense donc qu'il ne manque pas de lib et que la structure de mon appli et correcte.
Seulement voilà dés que je fais le mapping d'un service qui utilise ma DAO à travers BlazeDs pour pouvoir l'utilisé sur ma partie Flex un message apparet lors du lancement de TOMCAT.
Voici le message de ma console:La service qui utilise ma DAO09-Aug-2011 12:17:00 org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /Seat-Database threw load() exception
java.lang.NoClassDefFoundError: org/hibernate/HibernateException
at service.UserImpl.<init>(UserImpl.java:11)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:100)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:61)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:877)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:839)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:440)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4420)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4733)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
09-Aug-2011 12:17:00 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
09-Aug-2011 12:17:00 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /0.0.0.0:8009
09-Aug-2011 12:17:00 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/16 config=null
09-Aug-2011 12:17:00 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1777 ms
le web.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 package service; import org.hibernate.Session; import service.serviceInterface.User; import dao.HibernateUtil; import dao.seat.TUser; public class UserImpl implements User { Session session = HibernateUtil.currentSession(); public TUser createUser(TUser user) { session.beginTransaction(); session.save(user); session.getTransaction().commit(); HibernateUtil.closeSession(); return user; } public Boolean connectionUser(Integer iduser,String password) { Boolean bool= true; session.beginTransaction(); TUser user = (TUser)session.get(TUser.class, iduser); if(!(user.getPassword()).equals(password)||user==null) { bool= false; } session.getTransaction().commit(); HibernateUtil.closeSession(); return bool; } }
Dans mon dossier WEB-INF/flex
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <display-name>Seat-Database</display-name> <description>BlazeDS Application</description> <!-- Http Flex Session attribute and binding listener support --> <listener> <listener-class>flex.messaging.HttpFlexSession</listener-class> </listener> <!-- Front Controller de Spring MVC qui va gérer les requêtes Flex --> <servlet> <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/flex/web-application-config.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <!-- Mapping des requêtes pour le controlleur Spring --> <servlet-mapping> <servlet-name>Spring MVC Dispatcher Servlet</servlet-name> <url-pattern>/messagebroker/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> </welcome-file-list> </web-app>
le web-application-conf.xml
le service-config.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Maps request paths at /messagebroker to the BlazeDS MessageBroker --> <bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping"> <property name="mappings"> <value> /*=flexMessageBroker </value> </property> </bean> <!-- Handler qui va gérer les différents canaux Flex ( AMF, Http ,...) --> <bean class="org.springframework.flex.messaging.servlet.MessageBrokerHandlerAdapter"/> <!-- Factory qui va créer le broker Flex --> <bean id="flexMessageBroker" class="org.springframework.flex.messaging.MessageBrokerFactoryBean" > <!-- Configuration du chemin vers le service-config.xml --> <property name="servicesConfigPath" value="/WEB-INF/flex/services-config.xml" /> </bean> <bean id="UserImpl" class="service.UserImpl" /> <bean id="user" class="org.springframework.flex.messaging.remoting.FlexRemotingServiceExporter"> <property name="messageBroker" ref="flexMessageBroker"/> <property name="service" ref="UserImpl"/> <property name="serviceId" value="UserImpl"></property> </bean> </beans>
le remoting-config.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86 <?xml version="1.0" encoding="UTF-8"?> <services-config> <services> <service-include file-path="remoting-config.xml" /> <!-- Spécifie un canal par défault pour toutes destinations --> <default-channels> <channel ref="my-amf"/> </default-channels> </services> <security> <security-constraint id="sample-users"> <auth-method>Custom</auth-method> <roles> <role>sampleusers</role> </roles> </security-constraint> <login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/> <!-- Uncomment the correct app server <login-command class="flex.messaging.security.TomcatLoginCommand" server="JBoss"> <login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/> <login-command class="flex.messaging.security.WeblogicLoginCommand" server="Weblogic"/> <login-command class="flex.messaging.security.WebSphereLoginCommand" server="WebSphere"/> --> </security> <channels> <channel-definition id="my-streaming-amf" class="mx.messaging.channels.StreamingAMFChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/streamingamf" class="flex.messaging.endpoints.StreamingAMFEndpoint"/> </channel-definition> <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/> <properties> <polling-enabled>false</polling-enabled> </properties> </channel-definition> <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel"> <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/> <properties> <add-no-cache-headers>false</add-no-cache-headers> </properties> </channel-definition> <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel"> <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/> <properties> <polling-enabled>true</polling-enabled> <polling-interval-seconds>4</polling-interval-seconds> </properties> </channel-definition> </channels> <logging> <!-- You may also use flex.messaging.log.ServletLogTarget --> <target class="flex.messaging.log.ConsoleTarget" level="info"> <properties> <prefix>[BlazeDS] </prefix> <includeDate>false</includeDate> <includeTime>false</includeTime> <includeLevel>true</includeLevel> <includeCategory>false</includeCategory> </properties> <filters> <pattern>Endpoint.*</pattern> <pattern>Service.*</pattern> <pattern>Configuration</pattern> </filters> </target> </logging> </services-config>
le fichier hibernate.cfg.xml de ma DAO
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <?xml version="1.0" encoding="UTF-8"?> <service id="remoting-service" class="flex.messaging.services.RemotingService"> <adapters> <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter" default="true"/> </adapters> <default-channels> <channel ref="my-amf"/> </default-channels> </service>
Si quelqu’un à la solution à mon problème je l'en remercie d'avance.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 <?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 > <!-- local connection properties --> <property name="hibernate.connection.url">jdbc:mysql://44.45.62.138:3306/seat_database</property> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <property name="hibernate.connection.username">Leo</property> <property name="hibernate.connection.password"></property> <!-- property name="hibernate.connection.pool_size"></property --> <!-- dialect for MySQL --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="hibernate.show_sql">false</property> <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> <!-- Mapping files--> <mapping resource="TUser.hbm.xml"/> <mapping resource="TSeat.hbm.xml"/> <mapping resource="TSource.hbm.xml"/> <mapping resource="THistory.hbm.xml"/> <mapping resource="TCustomized.hbm.xml"/> <mapping resource="TStandard.hbm.xml"/> <mapping resource="TSide.hbm.xml"/> <mapping resource="TDouble.hbm.xml"/> <mapping resource="TTriple.hbm.xml"/> <mapping resource="TQuad.hbm.xml"/> </session-factory> </hibernate-configuration>![]()
Partager