为什么Glassfish不识别罐子?

Sur*_*nut 3 glassfish java-ee maven

我想asadmin deploy testapp-1.0-SNAPSHOT.jar在终端上使用命令在glassfish 4上部署一个jar .罐子的完整布局是

/META-INF/MANIFEST.MF
/META-INF/maven/com.test/testapp/pom.properties
/META-INF/maven/com.test/testapp/pom.xml
/com/test/testapp/*.class
Run Code Online (Sandbox Code Playgroud)

但每次我得到错误

remote failure: Archive type of jar was not recognized
Command deploy failed.
Run Code Online (Sandbox Code Playgroud)

我用maven编译和打包jar.

提前致谢.

Sur*_*nut 6

似乎只有个别jar包含Enterprise Java Bean才能部署它们.

将类创建为Enterprise Java Bean有两种选择.

  1. 使用从包中定义注释的组件注释类javax.ejb(例如javax.ejb.Stateless)

  2. 在部署描述符中指定Enterprise Java Bean ejb-jar.xml(或者glassfish-ejb-jar.xml如果使用Glassfish),请在META-INF目录中指定,如5.2 Packaging Enterprise Bean中所示

这是一个简单的例子,取自Simple Stateless with Descriptor

<ejb-jar xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
         version="3.0">
  <enterprise-beans>
    <session>
      <ejb-name>CalculatorImpl</ejb-name>
      <business-local>org.superbiz.calculator.CalculatorLocal</business-local>
      <business-remote>org.superbiz.calculator.CalculatorRemote</business-remote>
      <ejb-class>org.superbiz.calculator.CalculatorImpl</ejb-class>
      <session-type>Stateless</session-type>
      <transaction-type>Container</transaction-type>
    </session>
  </enterprise-beans>
</ejb-jar>
Run Code Online (Sandbox Code Playgroud)