我正在尝试使用嵌入式EJB容器创建一个胖jar。 我的问题是,当我尝试运行jar文件时,发生了IllegalArgumentException。
请帮帮我。
我的代码。
public static void main(String[] args) throws NamingException {
try (EJBContainer container = EJBContainer.createEJBContainer()) {
String jndi = "java:global/javaee-batch/MainLogic";
MainLogic logic = (MainLogic) container.getContext().lookup(jndi);
logic.run();
}
}
如果我可以通过maven执行,则此代码成功。
这是我的poms:
<?xml version="1.0" encoding="UTF-8"?>
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>simplebatch</groupId>
<artifactId>JavaEE-Batch</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>simplebatch.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-sample-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.glassfish.main.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>4.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.4</version>
</dependency>
</dependencies>
</project>
当我执行“JavaEE-Batch-1.0-SNAPSHOT-jar-with-dependencies.jar”时,发生了此错误。
Sep 15, 2014 8:21:46 PM org.glassfish.api.ActionReport failure
SEVERE: Exception while deploying the app [javaee-batch]
Sep 15, 2014 8:21:46 PM com.sun.enterprise.v3.server.ApplicationLifecycle deploy
SEVERE: Exception during lifecycle processing
java.lang.IllegalArgumentException: Referencing error: this bundle has no bean of name: MEJBBean
at org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl.getEjbByName(EjbBundleDescriptorImpl.java:323)
at org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl.getEjbByName(EjbBundleDescriptorImpl.java:307)
at org.glassfish.ejb.deployment.node.runtime.EjbNode.setElementValue(EjbNode.java:133)
at com.sun.enterprise.deployment.node.SaxParserHandler.endElement(SaxParserHandler.java:617)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:609)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLNSDTDValidator.endNamespaceScope(XMLNSDTDValidator.java:266)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2005)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.endElement(XMLDTDValidator.java:879)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:117)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
我该怎么做
答案 0 :(得分:0)
MEJBBean
是您的bean或外部库的一部分吗?
堆栈跟踪缺少更多信息。至少应该由...导致maven(使用你使用的任何ide)设置正确的依赖路径,但是在依赖构建时,不会复制此路径,因为这个外部依赖有范围{{ 1}}或设置为provided