A famous Java application server 1 A Hello World example with Jboss and Eclipse Install Eclipse and jboss Install jboss Eclipse IDE In eclipse create a new project by selecting new->Project->Web project->dynamic web project, say the project name is demo. The project should have a demo\src directory for source files, a demo\WebContent directory for jsp and html files. Right click project name demo, select properties->packaging configurations. Select Standar-War.war. You need to manually add the items you want in the package. You need to fill out Prefix field: if it's .jsp page, then leave it blank; if it's .class file, use WEB-INF\classes. There is also an include and an exclude field: use **\*.class if you want to include all .class files. Add a few jsp file and a few servlet Right click project name demo, then choose Run Packaging. A demo.war file will be generated in the directory you specified when you setup the "Packaging configurations" Copy the .war file to you jboss server. Put it under $JBOSS_HOME/server/deploy/ The content you created can be accessed by http://www.yourdomainname.com/demo 2 Jboss Admin Interface visit http://localhost:8080/jmx-console/ 3 Deploying datasources Follow the following steps to deploy a data source in Jboss: Create a data source xml file login-ds.xml <?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>login</jndi-name> <connection-url>jdbc:postgresql://localhost:5432/login</connection-url> <driver-class>org.postgresql.Driver</driver-class> <user-name>yourusername</user-name> <password>yourpassword</password> <metadata> <type-mapping>PostgreSQL 7.2</type-mapping> </metadata> </local-tx-datasource> </datasources> Copy this file over to $JBOSS_HOME/server/default/deploy/, JBoss will automatically deploy this datasource file. Use JNDI naming and directory package to lookup this datasource and use it. Trouble shooting: if you see this error: org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: org.postgresql.Driver; - nested throwable: (java.lang.ClassNotFoundException: org.postgresql.Driver)); - nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: org.postgresql.Driver; - nested throwable: (java.lang.ClassNotFoundException: org.postgresql.Driver))) Check if you have the correct version of database driver, or do you have the correct version? Here is a list jdbc drivers for postgresql. 4 Jboss Web Service Jboss support SOAP-based web service. Note that starting from Version 4, Apache Axis is not supported by Jboss. 4.1 Jboss vs Axis Before version 4, Jboss uses a modified version of Axis as web service engine. After version 4, Jboss developed its own ws engine because of the following: [JBOSS]. Portable web service endpoints and clients that do not need to have a dependency on a propriatary stack Secure your investment and learn a standard rather than a propriatary solution Achieve good interoperability by beeing BasicProfile-1.0 compliant Take advantage of test coverage that comes with Sun's Compatibility Test Suite (>2300 WS tests) Good integration with the overall JBoss architecture i.e. hot deployment/redeployment, management interface Our support offering covers our own stack and the JBossWS team is dedicated full time to improve that constantly. 4.2 JbossWS vs. Jboss.NET JBossWS is the J2EE-1.4 compatible web service implemenation in JBoss. It is installed in the all and default configuration. This implementaion will be developed further and replaced JBoss.NET. (http://www.jboss.org/index.html?module=bb&op=viewtopic&t=65248) 5 Setting SQL Server data source <?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>msuhr</jndi-name> <connection-url>jdbc:microsoft:sqlserver://hostname:1433;DatabaseName=test</connection-url> <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class> <user-name>username</user-name> <password>secret</password> </local-tx-datasource> </datasources> Note that when you used Microsoft SQL Server database with Microsoft JDBC driver, remeber to include all three .jar files: msbase.jar mssqlserver.jar msutil.jar, if you miss one of them, you'll get this error: org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.jdbc.sqlserver.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundExcepti 6 Setting up connection pool http://pipin.tmd.ns.ac.yu/extra/java2/libs/JBoss/ch03s09.html 7 Configuring JBoss with C3P0 Refer to C3P0. 8 A console is not available Restart your jboss server would usually get back your console. 9 Create your own jboss service Jboss uses JMX to manage services, for example, ConnectionBindingService, etc. The Jboss API allows us to create our own services. The following shows how to create a simple query service. [J] 9.1 Create the management interface package com.foo.mbeans; import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); } 9.2 Service implementation package edu.msu.egr.decs.config.mbeans; import org.jboss.system.ServiceMBeanSupport; public class BarService extends ServiceMBeanSupport implements BarServiceMBean { // Our message attribute private String message = "Sorry no message today"; private String abc = ""; //The printMessage operation public void printMessage() { log.info(message); } //The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); } protected void stopService() throws Exception { log.info("Stopping BarService"); } //Getters and Setters public String getMessage(){ return message; } public void setMessage(String message) { this.message = message; } public String getAbc() { return abc; } public void setAbc(String abc) { this.abc = abc; } } 9.3 Create service descriptor Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml". <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server> 9.4 Compile Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
visit http://localhost:8080/jmx-console/ 3 Deploying datasources Follow the following steps to deploy a data source in Jboss: Create a data source xml file login-ds.xml <?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>login</jndi-name> <connection-url>jdbc:postgresql://localhost:5432/login</connection-url> <driver-class>org.postgresql.Driver</driver-class> <user-name>yourusername</user-name> <password>yourpassword</password> <metadata> <type-mapping>PostgreSQL 7.2</type-mapping> </metadata> </local-tx-datasource> </datasources> Copy this file over to $JBOSS_HOME/server/default/deploy/, JBoss will automatically deploy this datasource file. Use JNDI naming and directory package to lookup this datasource and use it. Trouble shooting: if you see this error: org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: org.postgresql.Driver; - nested throwable: (java.lang.ClassNotFoundException: org.postgresql.Driver)); - nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: org.postgresql.Driver; - nested throwable: (java.lang.ClassNotFoundException: org.postgresql.Driver))) Check if you have the correct version of database driver, or do you have the correct version? Here is a list jdbc drivers for postgresql. 4 Jboss Web Service Jboss support SOAP-based web service. Note that starting from Version 4, Apache Axis is not supported by Jboss. 4.1 Jboss vs Axis Before version 4, Jboss uses a modified version of Axis as web service engine. After version 4, Jboss developed its own ws engine because of the following: [JBOSS]. Portable web service endpoints and clients that do not need to have a dependency on a propriatary stack Secure your investment and learn a standard rather than a propriatary solution Achieve good interoperability by beeing BasicProfile-1.0 compliant Take advantage of test coverage that comes with Sun's Compatibility Test Suite (>2300 WS tests) Good integration with the overall JBoss architecture i.e. hot deployment/redeployment, management interface Our support offering covers our own stack and the JBossWS team is dedicated full time to improve that constantly. 4.2 JbossWS vs. Jboss.NET JBossWS is the J2EE-1.4 compatible web service implemenation in JBoss. It is installed in the all and default configuration. This implementaion will be developed further and replaced JBoss.NET. (http://www.jboss.org/index.html?module=bb&op=viewtopic&t=65248) 5 Setting SQL Server data source <?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>msuhr</jndi-name> <connection-url>jdbc:microsoft:sqlserver://hostname:1433;DatabaseName=test</connection-url> <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class> <user-name>username</user-name> <password>secret</password> </local-tx-datasource> </datasources> Note that when you used Microsoft SQL Server database with Microsoft JDBC driver, remeber to include all three .jar files: msbase.jar mssqlserver.jar msutil.jar, if you miss one of them, you'll get this error: org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.jdbc.sqlserver.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundExcepti 6 Setting up connection pool http://pipin.tmd.ns.ac.yu/extra/java2/libs/JBoss/ch03s09.html 7 Configuring JBoss with C3P0 Refer to C3P0. 8 A console is not available Restart your jboss server would usually get back your console. 9 Create your own jboss service Jboss uses JMX to manage services, for example, ConnectionBindingService, etc. The Jboss API allows us to create our own services. The following shows how to create a simple query service. [J] 9.1 Create the management interface package com.foo.mbeans; import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); } 9.2 Service implementation package edu.msu.egr.decs.config.mbeans; import org.jboss.system.ServiceMBeanSupport; public class BarService extends ServiceMBeanSupport implements BarServiceMBean { // Our message attribute private String message = "Sorry no message today"; private String abc = ""; //The printMessage operation public void printMessage() { log.info(message); } //The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); } protected void stopService() throws Exception { log.info("Stopping BarService"); } //Getters and Setters public String getMessage(){ return message; } public void setMessage(String message) { this.message = message; } public String getAbc() { return abc; } public void setAbc(String abc) { this.abc = abc; } } 9.3 Create service descriptor Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml". <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server> 9.4 Compile Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
Follow the following steps to deploy a data source in Jboss:
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>login</jndi-name> <connection-url>jdbc:postgresql://localhost:5432/login</connection-url> <driver-class>org.postgresql.Driver</driver-class> <user-name>yourusername</user-name> <password>yourpassword</password> <metadata> <type-mapping>PostgreSQL 7.2</type-mapping> </metadata> </local-tx-datasource> </datasources>
org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: org.postgresql.Driver; - nested throwable: (java.lang.ClassNotFoundException: org.postgresql.Driver)); - nested throwable: (org.jboss.resource.JBossResourceException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: org.postgresql.Driver; - nested throwable: (java.lang.ClassNotFoundException: org.postgresql.Driver)))
Jboss support SOAP-based web service. Note that starting from Version 4, Apache Axis is not supported by Jboss. 4.1 Jboss vs Axis Before version 4, Jboss uses a modified version of Axis as web service engine. After version 4, Jboss developed its own ws engine because of the following: [JBOSS]. Portable web service endpoints and clients that do not need to have a dependency on a propriatary stack Secure your investment and learn a standard rather than a propriatary solution Achieve good interoperability by beeing BasicProfile-1.0 compliant Take advantage of test coverage that comes with Sun's Compatibility Test Suite (>2300 WS tests) Good integration with the overall JBoss architecture i.e. hot deployment/redeployment, management interface Our support offering covers our own stack and the JBossWS team is dedicated full time to improve that constantly. 4.2 JbossWS vs. Jboss.NET JBossWS is the J2EE-1.4 compatible web service implemenation in JBoss. It is installed in the all and default configuration. This implementaion will be developed further and replaced JBoss.NET. (http://www.jboss.org/index.html?module=bb&op=viewtopic&t=65248) 5 Setting SQL Server data source <?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>msuhr</jndi-name> <connection-url>jdbc:microsoft:sqlserver://hostname:1433;DatabaseName=test</connection-url> <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class> <user-name>username</user-name> <password>secret</password> </local-tx-datasource> </datasources> Note that when you used Microsoft SQL Server database with Microsoft JDBC driver, remeber to include all three .jar files: msbase.jar mssqlserver.jar msutil.jar, if you miss one of them, you'll get this error: org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.jdbc.sqlserver.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundExcepti 6 Setting up connection pool http://pipin.tmd.ns.ac.yu/extra/java2/libs/JBoss/ch03s09.html 7 Configuring JBoss with C3P0 Refer to C3P0. 8 A console is not available Restart your jboss server would usually get back your console. 9 Create your own jboss service Jboss uses JMX to manage services, for example, ConnectionBindingService, etc. The Jboss API allows us to create our own services. The following shows how to create a simple query service. [J] 9.1 Create the management interface package com.foo.mbeans; import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); } 9.2 Service implementation package edu.msu.egr.decs.config.mbeans; import org.jboss.system.ServiceMBeanSupport; public class BarService extends ServiceMBeanSupport implements BarServiceMBean { // Our message attribute private String message = "Sorry no message today"; private String abc = ""; //The printMessage operation public void printMessage() { log.info(message); } //The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); } protected void stopService() throws Exception { log.info("Stopping BarService"); } //Getters and Setters public String getMessage(){ return message; } public void setMessage(String message) { this.message = message; } public String getAbc() { return abc; } public void setAbc(String abc) { this.abc = abc; } } 9.3 Create service descriptor Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml". <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server> 9.4 Compile Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
Before version 4, Jboss uses a modified version of Axis as web service engine. After version 4, Jboss developed its own ws engine because of the following: [JBOSS].
JBossWS is the J2EE-1.4 compatible web service implemenation in JBoss. It is installed in the all and default configuration. This implementaion will be developed further and replaced JBoss.NET. (http://www.jboss.org/index.html?module=bb&op=viewtopic&t=65248) 5 Setting SQL Server data source <?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>msuhr</jndi-name> <connection-url>jdbc:microsoft:sqlserver://hostname:1433;DatabaseName=test</connection-url> <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class> <user-name>username</user-name> <password>secret</password> </local-tx-datasource> </datasources> Note that when you used Microsoft SQL Server database with Microsoft JDBC driver, remeber to include all three .jar files: msbase.jar mssqlserver.jar msutil.jar, if you miss one of them, you'll get this error: org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.jdbc.sqlserver.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundExcepti 6 Setting up connection pool http://pipin.tmd.ns.ac.yu/extra/java2/libs/JBoss/ch03s09.html 7 Configuring JBoss with C3P0 Refer to C3P0. 8 A console is not available Restart your jboss server would usually get back your console. 9 Create your own jboss service Jboss uses JMX to manage services, for example, ConnectionBindingService, etc. The Jboss API allows us to create our own services. The following shows how to create a simple query service. [J] 9.1 Create the management interface package com.foo.mbeans; import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); } 9.2 Service implementation package edu.msu.egr.decs.config.mbeans; import org.jboss.system.ServiceMBeanSupport; public class BarService extends ServiceMBeanSupport implements BarServiceMBean { // Our message attribute private String message = "Sorry no message today"; private String abc = ""; //The printMessage operation public void printMessage() { log.info(message); } //The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); } protected void stopService() throws Exception { log.info("Stopping BarService"); } //Getters and Setters public String getMessage(){ return message; } public void setMessage(String message) { this.message = message; } public String getAbc() { return abc; } public void setAbc(String abc) { this.abc = abc; } } 9.3 Create service descriptor Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml". <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server> 9.4 Compile Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
<?xml version="1.0" encoding="UTF-8"?> <datasources> <local-tx-datasource> <jndi-name>msuhr</jndi-name> <connection-url>jdbc:microsoft:sqlserver://hostname:1433;DatabaseName=test</connection-url> <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class> <user-name>username</user-name> <password>secret</password> </local-tx-datasource> </datasources>
Note that when you used Microsoft SQL Server database with Microsoft JDBC driver, remeber to include all three .jar files: msbase.jar mssqlserver.jar msutil.jar, if you miss one of them, you'll get this error:
org.jboss.util.NestedSQLException: Could not create connection; - nested throwable: (org.jboss.resource.JBossResourceException: Failed to register driver for: com.microsoft.jdbc.sqlserver.SQLServerDriver; - nested throwable: (java.lang.ClassNotFoundExcepti
http://pipin.tmd.ns.ac.yu/extra/java2/libs/JBoss/ch03s09.html 7 Configuring JBoss with C3P0 Refer to C3P0. 8 A console is not available Restart your jboss server would usually get back your console. 9 Create your own jboss service Jboss uses JMX to manage services, for example, ConnectionBindingService, etc. The Jboss API allows us to create our own services. The following shows how to create a simple query service. [J] 9.1 Create the management interface package com.foo.mbeans; import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); } 9.2 Service implementation package edu.msu.egr.decs.config.mbeans; import org.jboss.system.ServiceMBeanSupport; public class BarService extends ServiceMBeanSupport implements BarServiceMBean { // Our message attribute private String message = "Sorry no message today"; private String abc = ""; //The printMessage operation public void printMessage() { log.info(message); } //The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); } protected void stopService() throws Exception { log.info("Stopping BarService"); } //Getters and Setters public String getMessage(){ return message; } public void setMessage(String message) { this.message = message; } public String getAbc() { return abc; } public void setAbc(String abc) { this.abc = abc; } } 9.3 Create service descriptor Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml". <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server> 9.4 Compile Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
Refer to C3P0.
8 A console is not available Restart your jboss server would usually get back your console. 9 Create your own jboss service Jboss uses JMX to manage services, for example, ConnectionBindingService, etc. The Jboss API allows us to create our own services. The following shows how to create a simple query service. [J] 9.1 Create the management interface package com.foo.mbeans; import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); } 9.2 Service implementation package edu.msu.egr.decs.config.mbeans; import org.jboss.system.ServiceMBeanSupport; public class BarService extends ServiceMBeanSupport implements BarServiceMBean { // Our message attribute private String message = "Sorry no message today"; private String abc = ""; //The printMessage operation public void printMessage() { log.info(message); } //The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); } protected void stopService() throws Exception { log.info("Stopping BarService"); } //Getters and Setters public String getMessage(){ return message; } public void setMessage(String message) { this.message = message; } public String getAbc() { return abc; } public void setAbc(String abc) { this.abc = abc; } } 9.3 Create service descriptor Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml". <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server> 9.4 Compile Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
Restart your jboss server would usually get back your console. 9 Create your own jboss service Jboss uses JMX to manage services, for example, ConnectionBindingService, etc. The Jboss API allows us to create our own services. The following shows how to create a simple query service. [J] 9.1 Create the management interface package com.foo.mbeans; import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); } 9.2 Service implementation package edu.msu.egr.decs.config.mbeans; import org.jboss.system.ServiceMBeanSupport; public class BarService extends ServiceMBeanSupport implements BarServiceMBean { // Our message attribute private String message = "Sorry no message today"; private String abc = ""; //The printMessage operation public void printMessage() { log.info(message); } //The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); } protected void stopService() throws Exception { log.info("Stopping BarService"); } //Getters and Setters public String getMessage(){ return message; } public void setMessage(String message) { this.message = message; } public String getAbc() { return abc; } public void setAbc(String abc) { this.abc = abc; } } 9.3 Create service descriptor Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml". <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server> 9.4 Compile Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
Jboss uses JMX to manage services, for example, ConnectionBindingService, etc. The Jboss API allows us to create our own services. The following shows how to create a simple query service. [J] 9.1 Create the management interface package com.foo.mbeans; import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); } 9.2 Service implementation package edu.msu.egr.decs.config.mbeans; import org.jboss.system.ServiceMBeanSupport; public class BarService extends ServiceMBeanSupport implements BarServiceMBean { // Our message attribute private String message = "Sorry no message today"; private String abc = ""; //The printMessage operation public void printMessage() { log.info(message); } //The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); } protected void stopService() throws Exception { log.info("Stopping BarService"); } //Getters and Setters public String getMessage(){ return message; } public void setMessage(String message) { this.message = message; } public String getAbc() { return abc; } public void setAbc(String abc) { this.abc = abc; } } 9.3 Create service descriptor Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml". <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server> 9.4 Compile Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
package com.foo.mbeans; import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); }
import org.jboss.system.ServiceMBean; public interface BarServiceMBean extends ServiceMBean { // Configure getters and setters for the message attribute public String getMessage(); public void setMessage(String message); public String getAbc(); public void setAbc(String abc); // The print message operation void printMessage(); }
package edu.msu.egr.decs.config.mbeans; import org.jboss.system.ServiceMBeanSupport; public class BarService extends ServiceMBeanSupport implements BarServiceMBean { // Our message attribute private String message = "Sorry no message today"; private String abc = ""; //The printMessage operation public void printMessage() { log.info(message); } //The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); } protected void stopService() throws Exception { log.info("Stopping BarService"); } //Getters and Setters public String getMessage(){ return message; } public void setMessage(String message) { this.message = message; } public String getAbc() { return abc; } public void setAbc(String abc) { this.abc = abc; } }
// Our message attribute private String message = "Sorry no message today"; private String abc = "";
//The printMessage operation public void printMessage() { log.info(message); }
//The lifecycle protected void startService() throws Exception { log.info("Starting BarServoce"); }
protected void stopService() throws Exception { log.info("Stopping BarService"); }
//Getters and Setters public String getMessage(){ return message; }
public void setMessage(String message) { this.message = message; }
public String getAbc() { return abc; }
public void setAbc(String abc) { this.abc = abc; } }
9.3 Create service descriptor Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml". <?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server> 9.4 Compile Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
Note that each attribute in this xml file must have a corresponding pair of getter and setter in the MBean interface file and the java implementation file. People often use service name to name this file, e.g., this one could be named "barservice.xml".
<?xml version="1.0" encoding="UTF-8"?> <server> <mbean code="com.foo.mbeans.BarService" name="foo.com:service=BarService"> <attribute name="Message">Hello World</attribute> <attribute name="abc">haha, here we are</attribute> </mbean> </server>
Compile the Java files and put them into a jar file: barservice.jar. 9.5 Deploy service First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
First, put a copy of barservice.jar into your jboss deployment directory (which is usually $JBOSSDIR/server/default/deploy), then, put a copy of barservice.jar into your jboss lib directory (which is usually $JBOSSDIR/server/default/lib), then put a copy of barservice.xml into the deployment directory. 9.6 Incomplete deployment? If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory. A HelloWorld Comments References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com
If you can redeploy the service by updating barservice.xml (without restarting jboss), but you see "incomplete deployment" error when restarting jboss, check to make sure that you have a copy of barservice.jar in the jboss lib directory.
A HelloWorld
References[J] http://wiki.jboss.org/wiki/Wiki.jsp?page=ExampleHelloWorldService[JBOSS] http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889456#3889456[JH] http://www.jboss.com