问题描述:我装下面的的ejb部署到jboss 4 sp1里,jboss没有出现任何的反溃信息,一般情况下
部署EJB无论是成功还是失败,JBOSS都会出现一些反溃信息的,可这连个异常也不给
我抛出客户端测试也不成功,这个问题困扰了我快一个星期.
救各位帮我看看,是我Beans写错了,还是部署文件写错,或是两者都有错.
200分救解决办法
/*******************************************************************************/
/*******************************************************************************/
Beans
/*******************************************************************************/
/********************************* Product ************************************/
package examples;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
public interface Product extends EJBObject
{
public void setProductID(String productID)
throws RemoteException;
public String getProductID()
throws RemoteException;
public void setName(String name)
throws RemoteException;
public String getName() throws RemoteException;
public void setDescription(String description)
throws RemoteException;
public String getDescription()
throws RemoteException;
public void setBasePrice(double basePrice)
throws RemoteException;
public double getBasePrice() throws RemoteException;
}
/******************************* ProductLocal **********************************/
package examples;
import javax.ejb.EJBLocalObject;
public interface ProductLocal extends EJBLocalObject
{
public void setProductID(String productID);
public String getProductID();
public void setName(String name);
public String getName();
public void setDescription(String description);
public String getDescription();
public void setBasePrice(double basePrice);
public double getBasePrice();
}
/******************************* ProductHome **********************************/
package examples;
import java.rmi.RemoteException;
import java.util.Collection;
import javax.ejb.CreateException;
import javax.ejb.EJBHome;
import javax.ejb.FinderException;
public interface ProductHome extends EJBHome
{
public Product create(String productID,String name,String description,
double basePrice)
throws CreateException,RemoteException;
public Product findByPrimaryKey(ProductPK pk)
throws FinderException,RemoteException;
public Collection findByName(String name)
throws FinderException,RemoteException;
public Collection findByDescription(String description)
throws FinderException,RemoteException;
public Collection findByBasePrice(double basePrice)
throws FinderException,RemoteException;
public Collection findExpensiveProducts(double minPrice)
throws FinderException,RemoteException;
public Collection findCheapProducts(double maxPrice)
throws FinderException,RemoteException;
public Collection findAllProducts()
throws FinderException,RemoteException;
}
/***************************** ProductLocalHome ********************************/
package examples;
import java.util.Collection;
import javax.ejb.CreateException;
import javax.ejb.EJBLocalHome;
import javax.ejb.FinderException;
public interface ProductLocalHome extends EJBLocalHome
{
public ProductLocal create(String productID,String name,String description,
double basePrice) throws CreateException;
public ProductLocal findByPrimaryKey(ProductPK pk)
throws FinderException;
public Collection findByName(String name)
throws FinderException;
public Collection findByDescription(String description)
throws FinderException;
public Collection findByBasePrice(double basePrice)
throws FinderException;
public Collection findExpensiveProducts(double minPrice)
throws FinderException;
public Collection findCheapProducts(double maxPrice)
throws FinderException;
public Collection findAllProducts() throws FinderException;
}
/******************************** ProductPK ***********************************/
package examples;
import java.io.Serializable;
public class ProductPK implements Serializable
{
public String productID;
public ProductPK(String productID)
{
this.productID=productID;
}
public String toString()
{
return this.productID.toString();
}
public int hashCode()
{
return this.productID.hashCode();
}
public boolean equals(Object obj)
{
return ((ProductPK)obj).productID.equals(productID);
}
}
/******************************** ProductBean ***********************************/
package examples;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;
public abstract class ProductBean implements EntityBean
{
protected EntityContext ctx;
public abstract void setProductID(String productID);
public abstract String getProductID();
public abstract void setName(String name);
public abstract String getName();
public abstract void setDescription(String description);
public abstract String getDescription();
public abstract void setBasePrice(double basePrice);
public abstract double getBasePrice();
public ProductBean()
{
//super();
}
public void setEntityContext(EntityContext ctx)
throws EJBException,RemoteException
{
System.out.println("setEntityContext() called");
this.ctx=ctx;
}
public void unsetEntityContext() throws EJBException,
RemoteException
{
System.out.println("unsetEntityContext() called");
}
public void ejbRemove() throws RemoveException,
EJBException,RemoteException
{
System.out.println("ejbRemove() called");
}
public void ejbActivate() throws EJBException, RemoteException
{
System.out.println("ejbActivate() called");
}
public void ejbPassivate() throws EJBException, RemoteException
{
System.out.println("ejbPassivate() called");
}
public void ejbLoad() throws EJBException, RemoteException
{
System.out.println("ejbLoad() called");
}
public void ejbStore() throws EJBException, RemoteException
{
System.out.println("ejbStore() called");
}
public ProductPK ejbCreate(String productID,String name,
String description,double basePrice)
{
this.setProductID(productID);
this.setName(name);
this.setDescription(description);
this.setBasePrice(basePrice);
return new ProductPK(productID);
}
public void ejbPostCreate(String productID,String name,
String description,double basePrice){};
}
5 个解决方案
#1
/*****************************************************************************/
下面是部署文件描述符
/*****************************************************************************/
/******************************** ejb-jar.xml ********************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<display-name>CMP 2.0 example</display-name>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<home>examples.ProductHome</home>
<remote>examples.Product</remote>
<local-home>examples.ProductLocalHome</local-home>
<local>examples.ProductLocal</local>
<ejb-class>examples.ProductBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>examples.ProductPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>ProductBean</abstract-schema-name>
<cmp-field>
<field-name>productID</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
</cmp-field>
<query>
<query-method>
<method-name>findByName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE name=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findByDescription</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.description=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findByBasePrice</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.basePrice=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findExpensiveProducts</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.basePrice>?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findCheapProducts</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p
WHERE p,basePrice<?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findAllProducts</method-name>
<method-params></method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p
WHERE p.productID IS NOT NULL]]>
</ejb-ql>
</query>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>ProductEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
/******************************* jboss.xml ***********************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<jndi-name>cmps/products</jndi-name>
<local-jndi-name>cmps/productslocal</local-jndi-name>
</entity>
</enterprise-beans>
</jboss>
/*************************** jbosscmp-jdbc.xml *******************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">
<jbosscmp-jdbc>
<defaults>
<datasource>java:/MSSQLDS</datasource>
<datasource-mapping>Microsoft SQL Server 2000</datasource-mapping>
<create-table>true</create-table>
<remove-table>true</remove-table>
<pk-constraint>true</pk-constraint>
<preferred-relation-mapping>foreign-key</preferred-relation-mapping>
</defaults>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<table-name>product</table-name>
<cmp-field>
<field-name>productID</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(20)</sql-type>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>nVARCHAR(50)</sql-type>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(255)</sql-type>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
<jdbc-type>FLOAT</jdbc-type>
<sql-type>FLOAT</sql-type>
</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>
下面是部署文件描述符
/*****************************************************************************/
/******************************** ejb-jar.xml ********************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<display-name>CMP 2.0 example</display-name>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<home>examples.ProductHome</home>
<remote>examples.Product</remote>
<local-home>examples.ProductLocalHome</local-home>
<local>examples.ProductLocal</local>
<ejb-class>examples.ProductBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>examples.ProductPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>ProductBean</abstract-schema-name>
<cmp-field>
<field-name>productID</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
</cmp-field>
<query>
<query-method>
<method-name>findByName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE name=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findByDescription</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.description=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findByBasePrice</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.basePrice=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findExpensiveProducts</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.basePrice>?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findCheapProducts</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p
WHERE p,basePrice<?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findAllProducts</method-name>
<method-params></method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p
WHERE p.productID IS NOT NULL]]>
</ejb-ql>
</query>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>ProductEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
/******************************* jboss.xml ***********************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<jndi-name>cmps/products</jndi-name>
<local-jndi-name>cmps/productslocal</local-jndi-name>
</entity>
</enterprise-beans>
</jboss>
/*************************** jbosscmp-jdbc.xml *******************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">
<jbosscmp-jdbc>
<defaults>
<datasource>java:/MSSQLDS</datasource>
<datasource-mapping>Microsoft SQL Server 2000</datasource-mapping>
<create-table>true</create-table>
<remove-table>true</remove-table>
<pk-constraint>true</pk-constraint>
<preferred-relation-mapping>foreign-key</preferred-relation-mapping>
</defaults>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<table-name>product</table-name>
<cmp-field>
<field-name>productID</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(20)</sql-type>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>nVARCHAR(50)</sql-type>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(255)</sql-type>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
<jdbc-type>FLOAT</jdbc-type>
<sql-type>FLOAT</sql-type>
</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>
#2
部署出问题一般都是配置文件有问题,或者配置文件和类文件不对应。。。光给类文件是没用的
#3
沉了.....
#4
你用的IDE是什么呢?如果是Eclipse和Limboz的话,我有一个例子可以给你看看。
#5
kylejiang(雁过留声) ( ) 信誉:99
我的问题解决了,原来是键误
原来我是:jar cvf Product.jar examples meta-inf 这样打包的,部署不成功,并且在Jboss上不会显示任何的反溃信息
后来改成:jar cvf Product.jar examples META-INF,这样就成功了
原来编译和打抱的时候也要区分大小写的
我的问题解决了,原来是键误
原来我是:jar cvf Product.jar examples meta-inf 这样打包的,部署不成功,并且在Jboss上不会显示任何的反溃信息
后来改成:jar cvf Product.jar examples META-INF,这样就成功了
原来编译和打抱的时候也要区分大小写的
#1
/*****************************************************************************/
下面是部署文件描述符
/*****************************************************************************/
/******************************** ejb-jar.xml ********************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<display-name>CMP 2.0 example</display-name>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<home>examples.ProductHome</home>
<remote>examples.Product</remote>
<local-home>examples.ProductLocalHome</local-home>
<local>examples.ProductLocal</local>
<ejb-class>examples.ProductBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>examples.ProductPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>ProductBean</abstract-schema-name>
<cmp-field>
<field-name>productID</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
</cmp-field>
<query>
<query-method>
<method-name>findByName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE name=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findByDescription</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.description=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findByBasePrice</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.basePrice=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findExpensiveProducts</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.basePrice>?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findCheapProducts</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p
WHERE p,basePrice<?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findAllProducts</method-name>
<method-params></method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p
WHERE p.productID IS NOT NULL]]>
</ejb-ql>
</query>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>ProductEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
/******************************* jboss.xml ***********************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<jndi-name>cmps/products</jndi-name>
<local-jndi-name>cmps/productslocal</local-jndi-name>
</entity>
</enterprise-beans>
</jboss>
/*************************** jbosscmp-jdbc.xml *******************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">
<jbosscmp-jdbc>
<defaults>
<datasource>java:/MSSQLDS</datasource>
<datasource-mapping>Microsoft SQL Server 2000</datasource-mapping>
<create-table>true</create-table>
<remove-table>true</remove-table>
<pk-constraint>true</pk-constraint>
<preferred-relation-mapping>foreign-key</preferred-relation-mapping>
</defaults>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<table-name>product</table-name>
<cmp-field>
<field-name>productID</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(20)</sql-type>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>nVARCHAR(50)</sql-type>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(255)</sql-type>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
<jdbc-type>FLOAT</jdbc-type>
<sql-type>FLOAT</sql-type>
</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>
下面是部署文件描述符
/*****************************************************************************/
/******************************** ejb-jar.xml ********************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
<display-name>CMP 2.0 example</display-name>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<home>examples.ProductHome</home>
<remote>examples.Product</remote>
<local-home>examples.ProductLocalHome</local-home>
<local>examples.ProductLocal</local>
<ejb-class>examples.ProductBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>examples.ProductPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>ProductBean</abstract-schema-name>
<cmp-field>
<field-name>productID</field-name>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
</cmp-field>
<query>
<query-method>
<method-name>findByName</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE name=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findByDescription</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.description=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findByBasePrice</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.basePrice=?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findExpensiveProducts</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p WHERE p.basePrice>?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findCheapProducts</method-name>
<method-params>
<method-param>double</method-param>
</method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p
WHERE p,basePrice<?1]]>
</ejb-ql>
</query>
<query>
<query-method>
<method-name>findAllProducts</method-name>
<method-params></method-params>
</query-method>
<ejb-ql>
<![CDATA[SELECT OBJECT(p) FROM product AS p
WHERE p.productID IS NOT NULL]]>
</ejb-ql>
</query>
</entity>
</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>ProductEJB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
/******************************* jboss.xml ***********************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jboss PUBLIC
"-//JBoss//DTD JBOSS 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<jndi-name>cmps/products</jndi-name>
<local-jndi-name>cmps/productslocal</local-jndi-name>
</entity>
</enterprise-beans>
</jboss>
/*************************** jbosscmp-jdbc.xml *******************************/
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_4_0.dtd">
<jbosscmp-jdbc>
<defaults>
<datasource>java:/MSSQLDS</datasource>
<datasource-mapping>Microsoft SQL Server 2000</datasource-mapping>
<create-table>true</create-table>
<remove-table>true</remove-table>
<pk-constraint>true</pk-constraint>
<preferred-relation-mapping>foreign-key</preferred-relation-mapping>
</defaults>
<enterprise-beans>
<entity>
<ejb-name>ProductEJB</ejb-name>
<table-name>product</table-name>
<cmp-field>
<field-name>productID</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(20)</sql-type>
</cmp-field>
<cmp-field>
<field-name>name</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>nVARCHAR(50)</sql-type>
</cmp-field>
<cmp-field>
<field-name>description</field-name>
<jdbc-type>VARCHAR</jdbc-type>
<sql-type>VARCHAR(255)</sql-type>
</cmp-field>
<cmp-field>
<field-name>basePrice</field-name>
<jdbc-type>FLOAT</jdbc-type>
<sql-type>FLOAT</sql-type>
</cmp-field>
</entity>
</enterprise-beans>
</jbosscmp-jdbc>
#2
部署出问题一般都是配置文件有问题,或者配置文件和类文件不对应。。。光给类文件是没用的
#3
沉了.....
#4
你用的IDE是什么呢?如果是Eclipse和Limboz的话,我有一个例子可以给你看看。
#5
kylejiang(雁过留声) ( ) 信誉:99
我的问题解决了,原来是键误
原来我是:jar cvf Product.jar examples meta-inf 这样打包的,部署不成功,并且在Jboss上不会显示任何的反溃信息
后来改成:jar cvf Product.jar examples META-INF,这样就成功了
原来编译和打抱的时候也要区分大小写的
我的问题解决了,原来是键误
原来我是:jar cvf Product.jar examples meta-inf 这样打包的,部署不成功,并且在Jboss上不会显示任何的反溃信息
后来改成:jar cvf Product.jar examples META-INF,这样就成功了
原来编译和打抱的时候也要区分大小写的