i have a very concerning issue related with Spring Boot 1.5.16 and JBoss 6.4 EAP.
Introduction
The application is archived as War and it is contained into a EAR with another Spring Application and an Angular as well.
Problem
As far I test the deploy in local, none issue appears. Althought in local environment the War is loaded correctly into Jboss, in a remote test server the run would hang during the Spring Boot Application running in this specific phase.
10:04:53,056 WARN [org.jboss.as.ee] (MSC service thread 1-2) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
10:04:53,056 WARN [org.jboss.as.ee] (MSC service thread 1-2) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
10:04:53,058 WARN [org.jboss.as.ee] (MSC service thread 1-4) JBAS011006: Not installing optional component org.springframework.http.server.ServletServerHttpAsyncRequestControl due to an exception (enable DEBUG log level to see the cause)
10:04:53,059 WARN [org.jboss.as.ee] (MSC service thread 1-4) JBAS011006: Not installing optional component org.springframework.web.context.request.async.StandardServletAsyncWebRequest due to an exception (enable DEBUG log level to see the cause)
10:04:53,155 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)
10:04:53,157 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.fabric.jdbc.FabricMySQLDriver (version 5.1)
10:04:53,247 INFO [org.jboss.web] (ServerService Thread Pool -- 65) JBAS018210: Register web context: /ng-app
10:04:53,252 INFO [org.jboss.web] (ServerService Thread Pool -- 52) JBAS018210: Register web context: /spring-boot-app
10:04:53,252 INFO [org.jboss.web] (ServerService Thread Pool -- 51) JBAS018210: Register web context: /spring-app
10:04:53,294 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spring-app]] (ServerService Thread Pool -- 51) No Spring WebApplicationInitializer types detected on classpath
10:04:53,306 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spring-boot-app]] (ServerService Thread Pool -- 52) 2 Spring WebApplicationInitializers detected on classpath
10:04:53,522 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/spring-app]] (ServerService Thread Pool -- 51) Initializing Spring root WebApplicationContext
10:04:53,525 INFO [stdout] (ServerService Thread Pool -- 51) INFO org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
Despite the app is being loaded and run correctly (the whole app works), if the application is restarted, Spring Boot Application won't close its session successfully. The result is that on the new loading phase, the JVM will have doubled its resources occupied and so on.
What I did
I focused essentially to this message:
2 Spring WebApplicationInitializers detected on classpath
It might be an issue related to multiple context initialization? I provide you my relevant classes and I hope for your advice.
ServletInitializer.class
#SpringBootApplication(exclude = {EmbeddedServletContainerAutoConfiguration.class})
public class ServletInitializer {
public static void main(String[] args) {
SpringApplication application = new SpringApplication(ApplicationConfig.class);
new SpringApplicationBuilder(application).web(false).run(args); }
}
ApplicationConfig.class
#Configuration
#EnableJpaAuditing
#Order
public class ApplicationConfig extends SpringBootServletInitializer {
// #PostConstruct
// void init() {
// TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
// }
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
application.web(false);
return application.sources(ServletInitializer.class);
}
#Bean
public DispatcherServlet dispatcherServlet() {
return new DispatcherServlet();
}
#Bean
public ServletRegistrationBean dispatcherServletRegistration() {
ServletRegistrationBean registration = new ServletRegistrationBean(
dispatcherServlet(), "/*");
registration
.setName(DispatcherServletAutoConfiguration.DEFAULT_DISPATCHER_SERVLET_REGISTRATION_BEAN_NAME);
registration.setLoadOnStartup(1);
return registration;
}
#Override
public void onStartup(ServletContext servletContext) throws ServletException {
System.setProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME, "test");
super.onStartup(servletContext);
}
}
Some Details
I have a JNDI Database Connection that works correctly at least in local environment.
I have no web.xml.
This is the springboot app sub-deployment in jboss-deployment-structure.xml
<sub-deployment name="CRVbusinessService.war">
<dependencies>
<module name="javax.xml.rpc.api"/>
<module name="javax.wsdl4j.api"/>
</dependencies>
<exclusions>
<module name="org.apache.xalan"/>
<module name="org.apache.commons.logging"/>
<module name="org.apache.log4j"/>
<module name="org.jboss.logging"/>
<module name="org.jboss.logging.jul-to-slf4j-stub"/>
<module name="org.jboss.logmanager"/>
<module name="org.jboss.logmanager.log4j"/>
<module name="org.slf4j"/>
<module name="org.slf4j.impl"/>
</exclusions>
</sub-deployment>
<sub-deployment name="restService.war">
<local-last value="true" />
<dependencies>
<module name="deployment.jpa2.1"/>
</dependencies>
<exclusions>
<module name="org.jboss.logging"/>
<module name="org.apache.commons.logging"/>
<module name="org.jboss.logmanager"/>
<module name="org.slf4j"/>
<module name="org.apache.log4j"/>
<module name="javax.persistence.api" />
<module name="org.hibernate" />
<module name="javax.validation.api"/>
<module name="javaee.api" />
</exclusions>
</sub-deployment>
<module name="deployment.jpa2.1" >
<module-alias name="jpa2.1"/>
<resources>
<resource-root path="hibernate-jpa-2.1-api-1.0.0.Final.jar" />
</resources>
</module>
Thank you in advance for any help.
Related
I'm new in the company and they were helping me while I setup the enviroment, I got this error when I started WildFly server (they gave me their wildfly 18):
`
09:47:20,106 INFO [org.jboss.as.ejb3] (MSC service thread 1-4) WFLYEJB0493: EJB subsystem suspension complete
09:47:20,124 INFO [org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService$AS7DataSourceDeployer] (MSC service thread 1-5) IJ020018: Enabling <validate-on-match> for java:/goljagen
09:47:20,124 INFO [org.jboss.as.connector.subsystems.datasources.AbstractDataSourceService$AS7DataSourceDeployer] (MSC service thread 1-8) IJ020018: Enabling <validate-on-match> for java:/goljagra
09:47:20,129 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) WFLYJCA0001: Bound data source [java:/agepos]
09:47:20,129 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0001: Bound data source [java:/goljagen]
09:47:20,130 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-8) WFLYJCA0001: Bound data source [java:/goljagra]
09:47:22,425 INFO [org.jboss.as.patching] (MSC service thread 1-1) WFLYPAT0050: WildFly Full cumulative patch ID is: base, one-off patches include: none
09:47:22,439 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) WFLYDS0013: Started FileSystemDeploymentService for directory C:\Program Files\wildfly-18.0.0.Final\standalone\deployments
09:47:22,458 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) WFLYSRV0027: Starting deployment of "archiconEar.ear" (runtime-name: "archiconEar.ear")
09:47:22,760 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443
09:47:23,436 INFO [org.jboss.ws.common.management] (MSC service thread 1-6) JBWS022052: Starting JBossWS 5.3.0.Final (Apache CXF 3.3.3)
09:47:25,221 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-8) MSC000001: Failed to start service jboss.deployment.unit."archiconEar.ear".STRUCTURE: org.jboss.msc.service.StartException in service jboss.deployment.unit."archiconEar.ear".STRUCTURE: WFLYSRV0153: Failed to process phase STRUCTURE of deployment "archiconEar.ear"
at org.jboss.as.server#10.0.0.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:183)
at org.jboss.msc#1.4.11.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
at org.jboss.msc#1.4.11.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
at org.jboss.msc#1.4.11.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1982)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
at org.jboss.threads#2.3.3.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYSRV0166: Sub deployment archiconWeb.war in jboss-deployment-structure.xml was not found. Available sub deployments: archiconWeb
at org.jboss.as.server#10.0.0.Final//org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.subDeploymentNotFound(DeploymentStructureDescriptorParser.java:327)
at org.jboss.as.server#10.0.0.Final//org.jboss.as.server.deployment.module.descriptor.DeploymentStructureDescriptorParser.deploy(DeploymentStructureDescriptorParser.java:221)
at org.jboss.as.server#10.0.0.Final//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:176)
... 8 more
09:47:25,728 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "archiconEar.ear")]) - failure description: {"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"archiconEar.ear\".STRUCTURE" => "WFLYSRV0153: Failed to process phase STRUCTURE of deployment \"archiconEar.ear\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYSRV0166: Sub deployment archiconWeb.war in jboss-deployment-structure.xml was not found. Available sub deployments: archiconWeb"}}
09:47:25,747 INFO [org.jboss.as.server] (ServerService Thread Pool -- 44) WFLYSRV0010: Deployed "archiconEar.ear" (runtime-name : "archiconEar.ear")
09:47:25,748 INFO [org.jboss.as.controller] (Controller Boot Thread) WFLYCTL0183: Service status report
WFLYCTL0186: Services which failed to start: service jboss.deployment.unit."archiconEar.ear".STRUCTURE: WFLYSRV0153: Failed to process phase STRUCTURE of deployment "archiconEar.ear"
09:47:25,820 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server
09:47:25,823 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management
09:47:25,824 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990
09:47:25,824 ERROR [org.jboss.as] (Controller Boot Thread) WFLYSRV0026: WildFly Full 18.0.0.Final (WildFly Core 10.0.0.Final) started (with errors) in 18868ms - Started 597 of 859 services (1 services failed or missing dependencies, 408 services are lazy, passive or on-demand)
`
We whatched in the jboss-deployment-structur and we have this:
`
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
<sub-deployment name="archiconWeb.war">
<dependencies>
<!-- <module name="org.apache.poi" /> -->
<module name="org.apache.commons.codec" />
</dependencies>
</sub-deployment>
</jboss-deployment-structure>
`
this is the pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>it.sisal</groupId>
<artifactId>archicon</artifactId>
<version>0.0.39-SNAPSHOT</version>
</parent>
<artifactId>archiconEar</artifactId>
<packaging>ear</packaging>
<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-ear-plugin</artifactId>
<version>${version.ear.plugin}</version>
<configuration>
<wtpContextName>archicon</wtpContextName>
<!-- Tell Maven we are using Java EE 7 -->
<version>7</version>
<!-- Use Java EE ear libraries as needed. Java EE ear libraries
are in easy way to package any libraries needed in the ear, and automatically
have any modules (EJB-JARs and WARs) use them -->
<defaultLibBundleDir>lib</defaultLibBundleDir>
<outputFileNameMapping>#{artifactId}#</outputFileNameMapping>
<contextRoot>/archicon</contextRoot>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>it.sisal</groupId>
<artifactId>archiconWeb</artifactId>
<version>0.0.39-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
</project>
Everyone else got the same file, Do you have any Idea which file should I check and how I can solve this problem.
Thanks to all!!!!
They told me to do:
mvn build, on eclipse do:
mvn update;
Project -> clean;
Project -> build All;
On the right click on the server I selected: clean than Publish.
I'm developing a maven based JSF+JPA+EJB 3.2 Project using Eclipse and Wildfly 11.
While starting the App Server am getting the following error :
20:37:27,664 INFO [org.jboss.weld.deployer] (MSC service thread 1-4) WFLYWELD0003: Processing weld deployment erpmini.war
20:37:28,116 INFO [org.hibernate.validator.internal.util.Version] (MSC service thread 1-4) HV000001: Hibernate Validator 5.3.5.Final
20:37:28,552 INFO [org.jboss.as.ejb3.deployment] (MSC service thread 1-4) WFLYEJB0473: JNDI bindings for session bean named 'UserManagementServiceSlsb' in deployment unit 'deployment "erpmini.war"' are as follows:
java:global/erpmini/UserManagementServiceSlsb!com.itsys.erp.server.commonservices.usermgmt.UserManagementService
java:app/erpmini/UserManagementServiceSlsb!com.itsys.erp.server.commonservices.usermgmt.UserManagementService
java:module/UserManagementServiceSlsb!com.itsys.erp.server.commonservices.usermgmt.UserManagementService
java:jboss/exported/erpmini/UserManagementServiceSlsb!com.itsys.erp.server.commonservices.usermgmt.UserManagementService
java:global/erpmini/UserManagementServiceSlsb
java:app/erpmini/UserManagementServiceSlsb
java:module/UserManagementServiceSlsb
20:37:29,879 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."erpmini.war".INSTALL: org.jboss.msc.service.StartException in service jboss.deployment.unit."erpmini.war".INSTALL: WFLYSRV0153: Failed to process phase INSTALL of deployment "erpmini.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:172)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:2032)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1955)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0041: Component class com.itsys.erp.server.commonservices.usermgmt.slsbadapter.UserManagementServiceSlsb for component UserManagementServiceSlsb has errors:
WFLYJPA0033: Can't find a persistence unit named null in deployment "erpmini.war"
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor$1.handle(ModuleJndiBindingProcessor.java:157)
at org.jboss.as.ee.component.ClassDescriptionTraversal.run(ClassDescriptionTraversal.java:54)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.processClassConfigurations(ModuleJndiBindingProcessor.java:186)
at org.jboss.as.ee.component.deployers.ModuleJndiBindingProcessor.deploy(ModuleJndiBindingProcessor.java:143)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:165)
... 5 more
20:37:30,098 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-2) ISPN000128: Infinispan version: Infinispan 'Chakra' 8.2.8.Final
20:37:31,825 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 63) WFLYCLINF0002: Started client-mappings cache from ejb container
20:37:32,131 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "erpmini.war")]) - failure description: {
"WFLYCTL0080: Failed services" => {"jboss.deployment.unit.\"erpmini.war\".INSTALL" => "WFLYSRV0153: Failed to process phase INSTALL of deployment \"erpmini.war\"
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: WFLYEE0041: Component class com.itsys.erp.server.commonservices.usermgmt.slsbadapter.UserManagementServiceSlsb for component UserManagementServiceSlsb has errors:
WFLYJPA0033: Can't find a persistence unit named null in deployment \"erpmini.war\""},
"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.unit.\"erpmini.war\".beanmanager"],
"WFLYCTL0180: Services with missing/unavailable dependencies" => [
"jboss.deployment.unit.\"erpmini.war\".weld.weldClassIntrospector is missing [jboss.deployment.unit.\"erpmini.war\".beanmanager]",
"jboss.deployment.unit.\"erpmini.war\".batch.artifact.factory is missing [jboss.deployment.unit.\"erpmini.war\".beanmanager]"
]
}
I'm injecting the EntityManager in stateless bean:
#Stateless
public class UserManagementServiceSlsb implements UserManagementService {
/** The Entity Manager */
#PersistenceContext(name = "TELCOAppPU")
private EntityManager entityManager;
private UserManagementService userMgmtService;
....
}
Why the Container is not able to find persistence.xml file? persistence.xml is present in META-INF directory. Any help would be appreciated.
Thanks.
UPDATE :
here is Project dir structure , persistence.xml is present in META-INF directory.
Project dir structure
persistence.xml contains Entity classes and MySql database connection details.
<persistence-unit name="TELCOAppPU">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>com.itsys.erp.server.dal.entities.City</class>
<class>com.itsys.erp.server.dal.entities.Machine</class>
<class>com.itsys.erp.server.dal.entities.Product</class>
<class>com.itsys.erp.server.dal.entities.ProductType</class>
<class>com.itsys.erp.server.dal.entities.ProductionLog</class>
...
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/erpdb" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<property name="hibernate.show_sql" value="true" />
</properties>
</persistence-unit>
Solved it by adding resources folder (as source folder) to the path src/main/resources and moving the META-INF folder to resources folder, which in turn tells maven to put all files under resources directory to target/classes and in WEB-INF/classes in the WAR.
Try placing your persistance.xml file inside WEB-INF (src/main/webapp/WEB-INF) directory, Since in case of a war, that is where you are supposed to place your persisntence.xml file.
From this post start from Jboss AS7 the jdbc driver is able to deploy as regular application. However a question is, how other application is able to refer to this jdbc jar?
here is what I tried but it doesn't work
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
......
<deployment>
<dependencies>
<module name="ojdbc6.jar" />
</dependencies>
</deployment>
.....
</jboss-deployment-structure>
UPDATE
When I deploy ojdbc.jar there is a section of log from console:
10:56:20,416 INFO [org.jboss.as.server.deployment] (MSC service thread 1-8) JBAS015876: Starting deployment of "ojdbc6.jar"
10:56:21,487 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-2) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
10:56:21,489 INFO [org.jboss.as.osgi] (MSC service thread 1-7) JBAS011907: Register module: Module "deployment.ojdbc6.jar:main" from Service Module Loader
10:56:21,499 INFO [org.jboss.as.server] (HttpManagementService-threads - 6) JBAS018559: Deployed "ojdbc6.jar"
Per the log jdbc module is with name deployment.ojdbc6.jar:main, but after I update jboss-deployment-structure.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.0">
......
<deployment>
<dependencies>
<module name="deployment.ojdbc6.jar:main" />
</dependencies>
</deployment>
.....
</jboss-deployment-structure>
it still does not work. with following message:
10:59:34,448 INFO [org.jboss.as.server] (HttpManagementService-threads - 7) JBAS015870: Deploy of deployment "MyApp.war" was rolled back with failure message {"JBAS014771: Services with missing/unavailable dependencies" => ["jboss.deployment.unit.\"MyApp.war.war\".POST_MODULE Missing[JBAS014861: <one or more transitive dependencies>]","jboss.module.service.\"deployment.MyApp.war.war\".main Missing[jboss.module.spec.service.\"deployment.ojdbc6.jar:main\".main]"]}
10:59:35,198 INFO [org.jboss.as.server.deployment] (MSC service thread 1-7) JBAS015877: Stopped deployment MyApp.war.war in 749ms
You can reference the jars from other deployments in this way:
<module name="deployment.YourEarOrWar.YourJar.jar" />
Where deployment is the general prefix for a reference to your deployed apps.
However, for a lib like a jdbc-driver I recommend to put it in the module-folder of the JBoss
<module xmlns="urn:jboss:module:1.1" name="driver.ojdbc">
<resources>
<resource-root path="ojdbc6.jar"/>
</resources>
</module>
and reference it then
<module name="driver.ojdbc"/>
See also
https://community.jboss.org/thread/169894
and
http://www.mastertheboss.com/jboss-as-7/how-to-install-a-module-on-jboss-as-7
I am running JBoss as standalone version. I would like to connect to my local mysql database
I copied the mysql connector in modules folder
me#air~/Downloads/jboss/standalone/configuration - 10:56:18 $ ls ../../modules/org/mysql/main/
mysql-connector-java-5.1.22-bin.jar
Next I changed the standalone.xml in jboss/standalone/configuration as
<drivers>
<driver name="com.mysql" module="org.mysql" />
<driver name="h2" module="com.h2database.h2"> <!-- default provided-->
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
</drivers>
Then I added the datasource as
<datasource jndi-name="java:/bb" pool-name="bb-pool" enabled="true" use-java-context="true" use-ccm="true">
<connection-url>jdbc:mysql://127.0.0.1:3306/mydb</connection-url>
<driver>mysql</driver>
<pool>
<min-pool-size>10</min-pool-size>
<max-pool-size>100</max-pool-size>
<prefill>true</prefill>
</pool>
<security>
<user-name>bb</user-name>
<password>bb</password>
</security>
<statement>
<prepared-statement-cache-size>100</prepared-statement-cache-size>
<share-prepared-statements>true</share-prepared-statements>
</statement>
</datasource>
I am using JBoss AS 7.1.
When I start the server on console, I see errors
10:54:47,458 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]
10:54:47,671 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.mysql (missing) dependents: [service jboss.data-source.java:/bb]
10:54:47,676 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990
10:54:47,676 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.1.Final "Brontes" started (with errors) in 2000ms - Started 134 of 212 services (2 services failed or missing dependencies, 74 services are passive or on-demand)
and when I hit Ctrl+C, I see
^C10:54:54,998 INFO [org.jboss.as.osgi] (MSC service thread 1-8) JBAS011942: Stopping OSGi Framework
10:54:55,004 INFO [org.jboss.as.logging] JBAS011503: Restored bootstrap log handlers
10:54:55,007 INFO [com.arjuna.ats.jbossatx] ARJUNA032018: Destroying TransactionManagerService
10:54:55,008 INFO [com.arjuna.ats.jbossatx] ARJUNA032014: Stopping transaction recovery manager
10:54:55,010 INFO [org.apache.catalina.core.StandardContext] Container org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/] has not been started
10:54:55,039 INFO [org.apache.coyote.http11.Http11Protocol] Pausing Coyote HTTP/1.1 on http--127.0.0.1-8080
10:54:55,039 INFO [org.apache.coyote.http11.Http11Protocol] Stopping Coyote HTTP/1.1 on http--127.0.0.1-8080
10:54:55,043 INFO [org.jboss.as.controller] JBAS014774: Service status report
JBAS014776: Newly corrected services:
service jboss.jdbc-driver.mysql (new available)
10:54:55,044 INFO [org.jboss.as] JBAS015950: JBoss AS 7.1.1.Final "Brontes" stopped in 47ms
I am new to JBoss and don't know how to fix this issue or to understand what is that I am doing wrong here
I think in your datasource you are referencing the driver mysql, but you named the driver com.mysql.
Try changing one the driver name to mysql.
Just a note: it is best to use the CLI to install the drivers and use the CLI or Web Console to build your datasources. The intention with AS7 is that these tools are used for all of your config and there are very few reasons why you should touch the XML yourself.
I had exactly the same mistake. Took me hours to find out how dumb it was.
In my case I was running jboss as a service under the jboss-as user, nice and easy. Except that when I created the mysql/main directory, along with the files within, I was under another user. No permissions there for jboss-as guy.
A simple chown on modules/ directory did the job.
First of all, your driver definition name doesn't match the driver name under the <datasource> definition. Replace <driver name="com.mysql" ... with <driver name="mysql" ... for it to work.
Second, have you added the module.xml file? It's not enough to copy the MySQL connector jar in the ./modules/com/mysql/main folder, you also have to add the module.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.26-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
Also, I had a strage similar problem when using the MySQL connector version 5.0.8, where the driver was not found / recognized. It disappeared when I switched to the newer 5.1.26 version.
Make sure you are using latest version of mysql jdbc connector , i solve same issue of mine with replacing latest mysql connetor
I'm deploying a really simple helloworld style EJB application. When doing so I get...
WARNING: -logmodule is deprecated. Please use the system property 'java.util.logging.manager' or the 'java.util.logging.LogManager' service loader.
13:15:54,638 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA
13:15:55,094 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA
13:15:55,175 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.0.Final "Thunder" starting
13:15:56,587 INFO [org.xnio] XNIO Version 3.0.3.GA
13:15:56,592 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http)
13:15:56,602 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA
13:15:56,614 INFO [org.jboss.remoting] JBoss Remoting version 3.2.2.GA
13:15:56,655 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers
13:15:56,661 INFO [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem
13:15:56,707 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem.
13:15:56,793 INFO [org.jboss.as.connector] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.7.Final)
13:15:56,822 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem
13:15:56,839 INFO [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem
13:15:56,881 INFO [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem
13:15:56,889 INFO [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service
13:15:56,898 INFO [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]
13:15:56,933 INFO [org.jboss.as.security] (MSC service thread 1-2) JBAS013100: Current PicketBox version=4.0.6.final
13:15:56,989 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension
13:15:57,324 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-2) JBoss Web Services - Stack CXF Server 4.0.1.GA
13:15:57,501 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-4) Starting Coyote HTTP/1.1 on http--127.0.0.1-8080
13:15:58,264 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-2) JBAS015012: Started FileSystemDeploymentService for directory /usr/bin/jboss-as-7.1.0.Final/standalone/deployments
13:15:58,265 INFO [org.jboss.as.remoting] (MSC service thread 1-1) JBAS017100: Listening on /127.0.0.1:4447
13:15:58,265 INFO [org.jboss.as.remoting] (MSC service thread 1-3) JBAS017100: Listening on /127.0.0.1:9999
13:15:58,272 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found HelloWorld.war in deployment directory. To trigger deployment create a file called HelloWorld.war.dodeploy
13:15:58,581 INFO [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775: New missing/unsatisfied dependencies:
service jboss.jdbc-driver.com_mysql (missing) dependents: [service jboss.data-source.java:jboss/datasources/EjbMySql]
13:15:58,589 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: JBoss AS 7.1.0.Final "Thunder" started (with errors) in 4548ms - Started 131 of 204 services (2 services failed or missing dependencies, 70 services are passive or on-demand)
It looks like I need to add an include somewhere, my code is very simple...
package server;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceUnit;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.MyUser;
/**
* Servlet implementation class HelloServlet
*/
#WebServlet("/HelloServlet")
public class HelloServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
#EJB HelloBean bean;
#PersistenceUnit
EntityManagerFactory emF;
/**
* #see HttpServlet#HttpServlet()
*/
public HelloServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* #see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.print("<html><body>");
MyUser user = (MyUser)emF.createEntityManager().createQuery("select * from myuser").getResultList().get(0);
out.println("Username = " + user.getName());
out.print("</body></html>");
}
/**
* #see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
}
Persistance.xml is shown below...
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.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_2_0.xsd">
<persistence-unit name="HelloWorld">
<jta-data-source>EjbMySql</jta-data-source>
<class>model.MyUser</class>
</persistence-unit>
</persistence>
modules/com/mysql/main/Modules.xml is as follows...
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ JBoss, Home of Professional Open Source.
~ Copyright 2010, Red Hat, Inc., and individual contributors
~ as indicated by the #author tags. See the copyright.txt file in the
~ distribution for a full listing of individual contributors.
~
~ This is free software; you can redistribute it and/or modify it
~ under the terms of the GNU Lesser General Public License as
~ published by the Free Software Foundation; either version 2.1 of
~ the License, or (at your option) any later version.
~
~ This software is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ Lesser General Public License for more details.
~
~ You should have received a copy of the GNU Lesser General Public
~ License along with this software; if not, write to the Free
~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
<module xmlns="urn:jboss:module:1.0" name="com.mysql.jdbc">
<resources>
<resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
</resources>
<dependencies>
<module name="javax.api"/>
</dependencies>
</module>
Standalone.xml has the following entry...
<subsystem xmlns="urn:jboss:domain:datasources:1.0">
<datasources>
<datasource jndi-name="java:jboss/datasources/EjbMySql" pool-name="EjbMySql" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/ejbdb</connection-url>
<driver>com.mysql</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql.jdbc"> <xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class> </driver>
</drivers>
</datasources>
</subsystem>
In my project, I have the MySQL jar in /WebContent/META-INF/services/mysql-connector-java-5.1.18-bin.jar
Does anyone have any ideas?
Thanks!
EDIT: Tried...
<datasource jndi-name="java:jboss/datasources/EjbMySql" pool-name="EjbMySql" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/ejbdb</connection-url>
<driver>com.mysql.jdbc.Driver</driver>
<security>
<user-name>root</user-name>
<password>root</password>
</security>
comes back with the same error.
In <JBOSS_HOME>/standalone/configuration/standalone.xml find the <subsystem xmlns="urn:jboss:domain:datasources:1.0"> tag and add the following inside the <datasources> element:
<datasources>
<datasource jndi-name="java:jboss/datasources/MysqlDS" pool-name="MysqlDS" enabled="true" use-java-context="true">
<connection-url>jdbc:mysql://localhost:3306/DATABASE_NAME</connection-url>
<driver>com.mysql</driver>
<security>
<user-name>USERNAME</user-name>
<password>PASSWORD</password>
</security>
</datasource>
<drivers>
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
</drivers>
</datasources>
Replace DATABASE_NAME,USERNAME and PASSWORD apporpriately.
Inside the <drivers> element add the following:
<driver name="com.mysql" module="com.mysql">
<xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class>
</driver>
Now, go to <JBOSS_HOME>/modules and create the path com/mysql/mainput the driver's jar there (eg. mysql-connector-java-5.1.18-bin.jar) and create the file module.xml with the following contents:
<module xmlns="urn:jboss:module:1.1" name="com.mysql">
<resources>
<resource-root path="mysql-connector-java-5.1.18-bin.jar"/>
<!-- Insert resources here -->
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
<module name="javax.servlet.api" optional="true"/>
</dependencies>
</module>
That should do the trick.
I think you need to associate the datasource in standalone.xml with the driver-module like in the example below (taken from here:
<datasources>
<datasource jndi-name="java:jboss/datasources/ExampleDS" enabled="true" use-java-context="true" pool-name="H2DS">
<connection-url>jdbc:h2:mem:test;DB_CLOSE_DELAY=-1</connection-url>
<driver>h2</driver>
<pool></pool>
<security>
<user-name>sa</user-name>
<password>sa</password>
</security>
<validation></validation>
<timeout></timeout>
<statement></statement>
</datasource>
<drivers>
<driver name="h2" module="com.h2database.h2">
<xa-datasource-class>org.h2.jdbcx.JdbcDataSource</xa-datasource-class>
</driver>
<driver name="mysql" module="com.mysql.jdbc"> <xa-datasource-class>com.mysql.jdbc.jdbc2.optional.MysqlXADataSource</xa-datasource-class> </driver>
</drivers>
</datasources>
The driver-element in datasources herein references a driver definition in the drivers-element, which in itself references the module that you defined and the classes. That is how I use it, and it works for me on JBoss 7.1.
In JBoss 7, several configuration details changed for creating a data source and installing a JDBC driver. Take a look at this migration guide, in the sections "Define the datasource" and "Install the JDBC driver".
Is the version of driver. Change for a new version. Believe, is only it!!!
I changed the driver mysql-connector-java-5.0.4-bin.jar to mysql-connector-java-5.1.25-bin.jar, then the problem is solved.