|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Configuration bitronix mysql in tomcat 5.5 with eclipseHi,
I use the following tutorial with eclipse: How to use BTM as the transaction manager in Tomcat 5.5.x. http://docs.codehaus.org/display/BTM/Tomcat with : tomcat :Apache Tomcat 5.5.27 mysql with the driver mysql-connector-java-5.1.7 in my application WEB-INF\web.xml <resource-ref> <description>FTA-NG database connection</description> <res-ref-name>jdbc/mysql</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> <servlet> <servlet-name>tuto</servlet-name> <servlet-class>test.TutoPool</servlet-class> </servlet> <servlet-mapping> <servlet-name>tuto</servlet-name> <url-pattern>/tuto</url-pattern> </servlet-mapping> META-INF\context.xml <Context> <Resource name="jdbc/mysql" auth="Container" type="javax.sql.DataSource" factory="bitronix.tm.resource.ResourceObjectFactory" description="DB Connection" driverClass="org.gjt.mm.mysql.Driver" jdbcUrl="jdbc:mysql://localhost:3306/bdd" user="root" localDataSource="true" password="mysql" maxPoolSize="15" minPoolSize="3" /> <ResourceLink global="jdbc/mysql" name="jdbc/mysql" type="javax.sql.DataSource"/> <WatchedResource>WEB-INF/web.xml</WatchedResource> <Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory" /> </Context> in my servlet test.TutoPool.java public void init() throws ServletException { try { //récupération de la source de donnée /*Context initCtx = new InitialContext(); ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/mysql"); */ Context initContext = new InitialContext(); Context envContext = (Context) initContext.lookup("java:/comp/env"); ds = (DataSource) envContext.lookup("jdbc/mysql"); } catch (Exception e) { throw new UnavailableException(e.getMessage()); } } When i run tomcat i have that : 27 mai 2009 16:15:10 org.apache.catalina.core.AprLifecycleListener lifecycleEvent INFO: The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_18\bin;.;C:\WINNT\system32;C:\WINNT;C:\Program Files\Java\jre6\bin\client;C:\Program Files\Java\jre6\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem 27 mai 2009 16:15:10 org.apache.coyote.http11.Http11BaseProtocol init INFO: Initialisation de Coyote HTTP/1.1 sur http-8080 27 mai 2009 16:15:10 org.apache.catalina.startup.Catalina load INFO: Initialization processed in 953 ms 27 mai 2009 16:15:10 org.apache.catalina.core.StandardService start INFO: Démarrage du service Catalina 27 mai 2009 16:15:10 org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/5.5.27 27 mai 2009 16:15:10 org.apache.catalina.core.StandardHost start INFO: XML validation disabled 27 mai 2009 16:15:11 org.apache.commons.modeler.Registry registerComponent GRAVE: Null component Catalina:type=DataSource,path=/BITRONX-HIBERNATE_V2,host=localhost,class=javax.sql.DataSource,name="jdbc/mysql" 27 mai 2009 16:15:11 org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring root WebApplicationContext 27 mai 2009 16:15:11 org.springframework.web.context.ContextLoader initWebApplicationContext INFO: Root WebApplicationContext: initialization started 27 mai 2009 16:15:11 org.springframework.context.support.AbstractApplicationContext prepareRefresh INFO: Refreshing org.springframework.web.context.support.XmlWebApplicationContext@1112783: display name [Root WebApplicationContext]; startup date [Wed May 27 16:15:11 CEST 2009]; root of context hierarchy 27 mai 2009 16:15:11 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext-services.xml] 27 mai 2009 16:15:11 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory INFO: Bean factory for application context [org.springframework.web.context.support.XmlWebApplicationContext@1112783]: org.springframework.beans.factory.support.DefaultListableBeanFactory@d0af9b 27 mai 2009 16:15:11 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@d0af9b: defining beans []; root of factory hierarchy 27 mai 2009 16:15:11 org.springframework.web.context.ContextLoader initWebApplicationContext INFO: Root WebApplicationContext: initialization completed in 531 ms 27 mai 2009 16:15:12 org.apache.coyote.http11.Http11BaseProtocol start INFO: Démarrage de Coyote HTTP/1.1 sur http-8080 27 mai 2009 16:15:12 org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 27 mai 2009 16:15:12 org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/125 config=null 27 mai 2009 16:15:12 org.apache.catalina.storeconfig.StoreLoader load INFO: Find registry server-registry.xml at classpath resource 27 mai 2009 16:15:12 org.apache.catalina.startup.Catalina start INFO: Server startup in 1703 ms But my problem i when i go to : http://localhost:8080/BITRONX-HIBERNATE_V2/tuto 27 mai 2009 16:16:23 org.apache.catalina.core.ApplicationContext log INFO: La servlet tuto est marqué comme indisponible 27 mai 2009 16:16:23 org.apache.catalina.core.StandardWrapperValve invoke GRAVE: Exception lors de l'allocation pour la servlet tuto javax.servlet.UnavailableException: Le Nom java: n'est pas lié à ce Contexte at test.TutoPool.init(TutoPool.java:75) at javax.servlet.GenericServlet.init(GenericServlet.java:212) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139) at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:791) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:127) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689) at java.lang.Thread.run(Thread.java:595) Could you help me please |
|
|
Re: Configuration bitronix mysql in tomcat 5.5 with eclipseHi,
At the top of the page you're referrign to, there is this warning: This is for BTM 1.2 and earlier These instructions are for BTM 1.2 and earlier only. BTM 1.3 instructions are here. I guess you've downloaded the latest BTM version so why not following the link and using the appropriate instructions ? It also looks like you've not followed the instructions very carefully looking at your context.xml file. Why did you define a <Resource> tag containing direct MySQL configuration ? And why did you add a <ResourceLink> with the exact same JNDI name ? More information would have been helpful as well like the line of Java code which throws this exception, the Tomcat server.xml config file, the BTM TM & resource loader configs... I strongly advise you to start all over again from a clean Tomcat installation and strictly follow the procedure documented here: http://docs.codehaus.org/display/BTM/Tomcat13 |
|
|
Re: Configuration bitronix mysql in tomcat 5.5 with eclipseHi,
I follow the procedure documented here with tomcat 6 : http://docs.codehaus.org/display/BTM/Tomcat13 but i have some warnings. 28 mai 2009 16:22:39 org.apache.tomcat.util.digester.SetPropertiesRule begin ATTENTION: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.j2ee.server:BITRONIX-HIBERNATE_V3' did not find a matching property. 28 mai 2009 16:22:39 org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.5.0_18\bin;.;C:\WINNT\system32;C:\WINNT;C:\Program Files\Java\jre6\bin\client;C:\Program Files\Java\jre6\bin;C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem 28 mai 2009 16:22:39 org.apache.coyote.http11.Http11Protocol init INFO: Initialisation de Coyote HTTP/1.1 sur http-8080 28 mai 2009 16:22:39 org.apache.catalina.startup.Catalina load INFO: Initialization processed in 859 ms 28 mai 2009 16:22:39 bitronix.tm.integration.tomcat55.BTMLifecycleListener lifecycleEvent INFO: Starting Bitronix Transaction Manager 28 mai 2009 16:22:40 bitronix.tm.BitronixTransactionManager logVersion INFO: Bitronix Transaction Manager version 1.3.1 28 mai 2009 16:22:40 bitronix.tm.Configuration buildServerIdArray ATTENTION: cannot get this JVM unique ID. Make sure it is configured and you only use ASCII characters. Will use IP address instead (unsafe for production usage!). 28 mai 2009 16:22:40 bitronix.tm.Configuration buildServerIdArray INFO: JVM unique ID: <192.168.232.130> 28 mai 2009 16:22:40 bitronix.tm.journal.DiskJournal open ATTENTION: active log file is unclean, previous server crash ? 28 mai 2009 16:22:43 bitronix.tm.recovery.Recoverer run INFO: recovery committed 0 dangling transaction(s) and rolled back 0 aborted transaction(s) on 0 resource(s) [] 28 mai 2009 16:22:43 org.apache.catalina.core.StandardService start INFO: D�marrage du service Catalina 28 mai 2009 16:22:43 org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.18 28 mai 2009 16:22:43 org.apache.catalina.core.NamingContextListener addResource ATTENTION: Failed to register in JMX: javax.naming.NamingException: no resource registered with uniqueName 'jdbc/mydatasource', available resources: [] 28 mai 2009 16:22:43 org.apache.coyote.http11.Http11Protocol start INFO: D�marrage de Coyote HTTP/1.1 sur http-8080 28 mai 2009 16:22:43 org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 28 mai 2009 16:22:43 org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/125 config=null 28 mai 2009 16:22:44 org.apache.catalina.startup.Catalina start INFO: Server startup in 4094 ms My procedure : Step 1: Copy the BTM jars and mysql-connector-java-5.1.7-bin.jar Step 2: setenv.bat : set CATALINA_OPTS=-Dbtm.root=%CATALINA_HOME% -Dbitronix.tm.configuration=%CATALINA_HOME%\conf\btm-config.properties btm-config.properties bitronix.tm.serverId=tomcat-btm-node0 bitronix.tm.journal.disk.logPart1Filename=${btm.root}/work/btm1.tlog bitronix.tm.journal.disk.logPart2Filename=${btm.root}/work/btm2.tlog bitronix.tm.resource.configuration=${btm.root}/conf/resources.properties server.xml ... <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <Listener className="bitronix.tm.integration.tomcat55.BTMLifecycleListener" /> ... Step 3: resources.properties resource.ds1.className=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource resource.ds1.uniqueName=jdbc/mydatasource resource.ds1.minPoolSize=0 resource.ds1.maxPoolSize=5 resource.ds1.driverProperties.driverClassName=org.gjt.mm.mysql.Driver resource.ds1.driverProperties.url=jdbc:mysql://localhost:3306/bdd resource.ds1.driverProperties.password=mysql resource.ds1.driverProperties.user=root Step 4: context.xml <?xml version="1.0" encoding="utf-8" ?> <Context> <WatchedResource>WEB-INF/web.xml</WatchedResource> <Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory" /> <Resource name="jdbc/mydatasource" auth="Container" type="javax.sql.DataSource" factory="bitronix.tm.resource.ResourceObjectFactory" uniqueName="jdbc/mydatasource" /> </Context> Step 5: web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name> BITRONIX-HIBERNATE_V3</display-name> <resource-env-ref> <resource-env-ref-name>jdbc/mydatasource</resource-env-ref-name> <resource-env-ref-type>javax.sql.DataSource</resource-env-ref-type> </resource-env-ref> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app> End Procedure I have some questions about the procedure. - When and How setenv.bat is executed? - How i can test if ressources.properties and btm-config.properties work when i run tomcat? because when i delete them i have the same errors message |
|
|
Re: Configuration bitronix mysql in tomcat 5.5 with eclipseI resolve my problems.
In fact when you use Eclipse for developp your web dynamic application with tomcat 6 integrated in Eclipse. You have to : 1 - go in open run dialog 2 - choose the server which run your application 3 - go to Arguments 4 - add the following line -Dbtm.root=%CATALINA_HOME% -Dbitronix.tm.configuration=%CATALINA_HOME%\conf\btm-config.properties in VM arguments that why I wondered that setenv.bat is mondatory or not thanx for the help ![]() |
|
|
Re: Configuration bitronix mysql in tomcat 5.5 with eclipseI didn't pay attention to the fact that you're running Tomcat inside Eclipse.
Indeed, you had to set the btm.root and bitronix.tm.configuration system properties in your Eclipse runtime config as the setenv.bat file is only loaded by the catalina.bat script which Eclipse certainly doesn't use. At least with the plugin you're using to run Tomcat. I'm glad to hear that everything works fine now. |
| Free embeddable forum powered by Nabble | Forum Help |