简体   繁体   中英

Glassfish deploy error “Archive type of MyProject.jar was not recognized”

I've created a dynamic web application and i'd like to deploy it with glassfish. I've successed build my sources to MyProject.jar. But when i deployed it, the following error displayed:

remote failure: Archive type of /home/davenlin/MyProject/build/MyProject.jar was not recognized

My project is just a normal Restful application, not ejb application, so i don't know if i must generate a MyProject.war instead of MyProject.jar.

Please help me. Thanks !

Okay, because my comment was rather unexplanatory:
Web applications are handled by application servers or servlet containers.
Both do quiet a lot of work for you and web applications are not comparable
to desktop or standalone java applications.
While your standalone applications are deployed as jar - files and then executed by the JVM,
web applications are executed by the container (application server / servlet container).
So this does require your application to provide additional configuration
and affords the archive itself to have a different structure.
So even if you are just exposing some web services to build a restful
application, your application server will do things for you such as
forwarding requests to the right classes, translate query and post
parameters into java - objects accessable by your own classes respectivly
your own objects and returning your response to the clients.
The interesting thing about it is:
The additional files in the web - archive are usually xml - files and web -
related files such as html, css, js.
So this does not distinguish war's from jar's as you can also package
additional resources within a jar.
The basic but now obsolete requirement on a war - file is that it contains
a deployment descriptor (which is again is an xml - file)
to configure your application , its context and the relative url (more concrete : url - patterns) it uses
, but as this requirement is obsolete someone may still think that this distinguishing is obsolete, too.

Replace leambda expressions from your code and try again.

[EDIT]

In my case. I have maven project with pom.xml file

<?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>test.ejb</groupId>
    <artifactId>leambda-ejb</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
    </dependency>
    </dependencies>


    <build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    </build>
</project>

, and an EJB with this content:

package test.ejb;

import javax.ejb.Singleton;

/**
 * Created by me0x847206 on 10/29/15.
 */
@Singleton
public class Test {
    public void test() {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {

            }
        });
    }
}

When .jar artifact is builded with maven, than it is successful deployed to Glassfish 4.1 server.

But, if in Test EJB, Thread will be created with leambda expressions, like

    Thread thread = new Thread(() -> {

    });

, than on deploy Glassfish will show error line:

    remote failure: Archive type of /mnt/2/Projects/IdeaProjects/TestEJB/target/leambda-ejb-1.0-SNAPSHOT.jar was not recognized
    Command deploy failed.

, and in server.log file will be lines:

    [2015-10-29T04:25:20.210+0200] [glassfish 4.1] [WARNING] [NCLS-DEPLOYMENT-00009] [javax.enterprise.system.tools.deployment.common] [tid: _ThreadID=44 _ThreadName=admin-listener(4)] [timeMillis: 1446085520210] [levelValue: 900] [[
      Failed to scan archive for annotations: 1612]]

    [2015-10-29T04:25:20.211+0200] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=44 _ThreadName=admin-listener(4)] [timeMillis: 1446085520211] [levelValue: 1000] [[
      Archive type of /mnt/2/Projects/IdeaProjects/TestEJB/target/leambda-ejb-1.0-SNAPSHOT.jar was not recognized]]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM