Hot questions for Using Enterprise JavaBeans in jar

Question:

I am using arquillian for unit test. I am creating deployment jar using shrinkWrap. But for that I need to add all the packages which are used in my project, which are a lot in number.

following is my test file

@RunWith(Arquillian.class)
public class GreeterTest {



    @Deployment
    public static JavaArchive createDeployment() throws NamingException {

        return ShrinkWrap.create(JavaArchive.class, "test.jar")
                .addPackage(ABC.class.getPackage())
                .addPackage(EFG.class.getPackage())
                .addPackage(HIJ.class.getPackage())
                .addPackage(KLM.class.getPackage())
                .addPackage(NOP.class.getPackage())
                .addPackage(QRS.class.getPackage())
                .addPackage(TUV.class.getPackage())
                .addPackage(XYZ.class.getPackage())

                .addAsResource("test-persistence.xml", "META-INF/persistence.xml")
                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");

      }

    @Inject
    ABC abc;

    @Inject
    EFG efg;

    @Inject
    HIJ hij;

    @Inject
    KLM klm;

    @Inject
    NOP nop;

    @Test
    public void shouldBeAbleToInjectEJBAndInvoke() throws Exception {

        abc.getDetail();

    }
}

You can see .addPackage(). there are hundreds of packages in my project. Obvious code size will be increasing enormously

Is there any other way for this? Or I must be making some big mistake


Answer:

I'd recommend you to use string representation of package path: "com.root.core" etc. And there are methods:

addPackage(String pack)

addPackages(boolean recursive, String... packages)

The latest is more appropriate for you I guess as it provides you a possibility to add packages recursively and thus you avoid repeatedly including every package. For instance:

.addPackages(true, "com.root")

Question:

This might be a silly question. But I have a doubt, why do we need the following dependency to run EJB in Wildfly?

<dependency>
    <groupId>org.jboss.spec.javax.ejb</groupId>
    <artifactId>jboss-ejb-api_3.2_spec</artifactId>
    <scope>provided</scope>
</dependency>

Do we have something similar which is customized for Wildfly only?


Answer:

Actually, you just need this maven dependency so your code can compile successfully during maven compile phase. For example, EJB annotations such as @Stateless are provided by it.

I use to declare this maven dependency instead for my Java EE 7 projects, so the whole bunch of JEE specs are available :

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

Finally this maven dependency has to be declared with "provided" scope as you don't need it within your package. Indeed it is already provided by Wildfly, as described in this documentation: Implicit module dependencies for deployments

Question:

I'm new to EJB. I have an ejb-jar file which contains, "Class1" and i deployed it to glassfish server. Now there is another jar file which contains only the following client file(it has a dependencey injection), so my problem is how should i execute this file?

I just deployed it to glassfish, but it doesn't work and show error in log file("it contains zero ejb").

import com.pack.Class1;

public class CreateAccoutnClient {

@EJB private static Class1 class1;

public static void main(String[] args) { }

}

If anyone who have read EJB 3 in Action, i'm tring to deploy chapter3 code to glassfish with eclipse.

Thanks :)


Answer:

EJB context doesn't execute any main methods, with Glassfish (and others) you must deploy a war to have entry points that run your app or methods (web services or web app).

A jar can contain MDB, remote ejbs or scheduled timers, or could be just a library. The only way to execute some initialization method at startup is to use the EJB3 @Startup annotation

Question:

I am doing a migration from Weblogic to JBoss EAP 6.4 but I am having a problem deploying to and starting the JBoss server.

My EAR structure is as follows:

.EAR
|
|---APP-INF
|      |---lib
|           |---[many .jar files]
|
|---META-INF
|       |---application.xml
|       |---jboss-deployment-structure.xml
|
|---[EJB JAR files]

The problem:

The EJB JARs in the root of the EAR cannot access the classes in the JARs that are in the APP-INF/lib folder.


Answer:

I manually put the lib folder at the root of the EAR instead of in the APP-INF folder and it seemed to do the trick.

JBoss was looking inside .EAR/lib instead of .EAR/APP-INF/lib

Then, I added the following in the maven-ear-plugin section in my pom.xml to get maven to create the lib folder at the root and not in APP-INF:

<plugin>
    <artifactId>maven-ear-plugin</artifactId>
    <version>2.9.1</version>
    <configuration>
        <defaultLibBundleDir>lib</defaultLibBundleDir>
        <goals>
            <goal>generate-application-xml</goal>
            <initializeInOrder>true</initializeInOrder>
        </goals>
    </configuration>
</plugin>

Question:

When I deployed my web apps with EJB 3.0, I saw this warning:

WARNING: jar 'E:\mws\MCDS\portal\portal-web\target\portal-web-1.0.0\WEB-INF\lib\ejb-api-3.0.jar' contains offending class: javax.ejb.EJB. It will be ignored.

My web apps started normally but I want to know why warning appeared and would it be a serious problems.

Im new for EJB and maybe this is dumb question. Thank you for reading.


Answer:

You are getting this warning because you have included the ejb-api-3.0.jar in your application. The classes in this jar are provided by the server implementation that you're using, so should not be packaged in your application.

§15.2.1 of the Servlet (3.0/3.1) Specification states that:

Servlet containers that are part of a Java EE product should not allow the application to override Java SE or Java EE platform classes, such as those in java.* and javax.* namespaces, that either Java SE or Java EE do not allow to be modified.

Question:

I've seem plenty of questions regarding this issue and I still couldn't get it fixed, I'm aware that this exception is thrown when one tries to deploy an ejb module without any classes annotated with @Stateless, @Stateful, @MessageDriven or @Singleton. But that isn't my case, I have several classes annotated like this:

@Stateless
@Remote(TestServiceInterface.class)
public class TestService extends TestSuperclass implements TestServiceInterface<Test>, Serializable{
}

and here is the interface:

public interface TestServiceInterface<T> extends AnotherInterface<T>{
}

All of my interfaces are located in another project, which have its jar added to my ejb module as a lib.

When I try to deploy I get the following exception:

1. A valid ejb jar requires at least one session, entity (1.x/2.x style), or message-driven bean. 
2. EJB3+ entity beans (@Entity) are POJOs and please package them as library jar. 
3. If the jar file contains valid EJBs which are annotated with EJB component level annotations (@Stateless, @Stateful, @MessageDriven, @Singleton), please check server.log to see whether the annotations were processed properly.
    at com.sun.enterprise.deployment.util.EjbBundleValidator.accept(EjbBundleValidator.java:76)
    at com.sun.enterprise.deployment.util.ApplicationValidator.accept(ApplicationValidator.java:128)
    at com.sun.enterprise.deployment.EjbBundleDescriptor.visit(EjbBundleDescriptor.java:730)
    at com.sun.enterprise.deployment.Application.visit(Application.java:1765)
    at com.sun.enterprise.deployment.archivist.ApplicationFactory.openArchive(ApplicationFactory.java:195)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:185)
    at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:94)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:827)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:769)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:368)
    at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
    at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
    at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
    at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
    at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
    at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
    at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:745).

UPDATE:

It also prints this line just before throwing the exception:

[#|2015-06-25T08:43:22.256-0300|WARNING|glassfish3.1.2|global|_ThreadID=126;_ThreadName=Thread-2;|Error in annotation processing: java.lang.NoClassDefFoundError: com/packageName/TestServiceInterface|#]

UPDATE 2

It seems like netbeans is somehow being able to deploy it! But if I try to deploy directly on the glassfish admin page or via command line("asadmin deploy") I get the exception.

I'm probably missing something, any help would be appreciated.


Answer:

It seems like for some reason my TestSuperclass could not be extended by the remote EJB, so I had to remove the extends TestSuperclass.

Instead of this:

@Stateless
@Remote(TestServiceInterface.class)
public class TestService extends TestSuperclass implements TestServiceInterface<Test>, Serializable{
}

I declade the class like this:

@Stateless
@Remote(TestServiceInterface.class)
public class TestService implements TestServiceInterface<Test>, Serializable{
}

Now it's not throwing the exception anymore.

Question:

An error occurred during activation of changes, please see the log for details.

Message icon - Error Exception preparing module: EJBModule(Demo_web_service) [EJB:011023]An error occurred while reading the deployment descriptor. The error was: Error processing annotations: . Message icon - Error There are 1 nested errors: weblogic.j2ee.dd.xml.AnnotationProcessException: [EJB:015002]Unable to load class com.cms.webservice.CMSWebServiceBean in Jar D:\Aswin\Demo_web_service.jar : java.lang.ClassNotFoundException: Class bytes found but defineClass()failed for: 'com.cms.webservice.CMSWebServiceBean'

Message icon - Error Exception preparing module: EJBModule(Demo_web_service) Unable to deploy EJB: Demo_web_service.jar from Demo_web_service.jar: There are 1 nested errors: java.io.IOException: JDT compilation error! at weblogic.ejb.container.ejbc.CompilerForJDT.compile(CompilerForJDT.java:66) at weblogic.ejb.container.ejbc.EJBCompiler.doCompile(EJBCompiler.java:358) at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:556) at weblogic.ejb.container.ejbc.EJBCompiler.compileEJB(EJBCompiler.java:523) at weblogic.ejb.container.deployer.EJBDeployer.runEJBC(EJBDeployer.java:441) at weblogic.ejb.container.deployer.EJBDeployer.compileJar(EJBDeployer.java:766) at weblogic.ejb.container.deployer.EJBDeployer.compileIfNecessary(EJBDeployer.java:666) at weblogic.ejb.container.deployer.EJBDeployer.prepare(EJBDeployer.java:1241) at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:427) at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:199) at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:391) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:59) at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:43) at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:1221) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:83) at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:367) at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:39) at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154) at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:207) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:98) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:217) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:747) at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1216) at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:250) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:159) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:157) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$000(DeploymentReceiverCallbackDeliverer.java:12) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$1.run(DeploymentReceiverCallbackDeliverer.java:45) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201) at weblogic.work.ExecuteThread.run(ExecuteThread.java:173) Message icon - Error JDT compilation error!

Can you please help me out to solve this?


Answer:

The Class bytes found but defineClass()failed for error indicates you have a Java mismatch. Weblogic is running with a different JDK/version of Java than the compiled war file you are deploying.

See: Class bytes found but defineClass()failed for error when deploying EAR

Question:

I'm working with Java and I've been asked to Hotreload a jar file to an ejb-server.

So my question is (and yes I've googled it!), what is the definition of Hot reload anyway?


Answer:

It is hot deployment and not hot reload of ejb, which means, updating an EJB without having to stop and restart the application server. Few application servers support this few don't. You don't have to worry about it, its application server that provides it for your use.

Few application servers does it seamlessly, for example, In weblogic, you can just copy a modified jar file into your applications directory, and changes will take place immediately.

Question:

I want to load and process json schema files from within two different deployments, the first being a WAR with JAX-RS endpoint and the second an EAR with Singleton-EJB + a resources JAR containing the schema files (I've read that packaging resources files for use in EJBs is only possible when bundling them in a separate JAR inside the EAR).

Development environment is eclipse 2019-03 with JBoss Wildfly 16.

WAR deployment with JAX-RS endpoint

The WAR part is fine, I have an @ApplicationScoped Bean and can access the schema files located in src/main/webapp/schemas/ via ServletContext, see the following code snippet:

@ForWarDeployment
@ApplicationScoped
public class JsonSchemaValidatorWar extends JsonSchemaValidatorBase {
...
@PostConstruct
public void init() {
    Consumer<Path> readSchema = schemaFile -> {
        String schemaName = schemaFile.getName(schemaFile.getNameCount() - 1).toString();
        JsonSchema js = jvs.readSchema(schemaFile);
        map.put(schemaName, js); // this is a concurrent hash map in base class
        log.info("Schema " + schemaName + " added: " + js.toJson());
    };
    URI schemaFolder;
    try {
        schemaFolder = servletContext.getResource("/schemas").toURI();
        try (Stream<Path> paths = Files.walk(Paths.get(schemaFolder))) {
            paths.filter(Files::isRegularFile).forEach(readSchema);
        }
    } catch (URISyntaxException | IOException e) {
        throw new RuntimeException("Error loading schema files!", e);
    }
}

Output on first request:

... (default task-1) Schema person.schema.json added: {"$id": ...

EAR deployment with EJB and resources JAR

The EJB part is tricky, I haven't found a solution for reading all schema files yet.

What I currently have is a multi-module maven project with the following structure:

- parent
- | ear 
- | ejb3
- | resources
pom.xml for parent project
<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>mdv</groupId>
  <artifactId>json-parent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

  <modules>
    <module>json-ejb3</module>
    <module>json-ear</module>
    <module>json-resources</module>
  </modules>

  <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>
pom.xml for ear project
<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>
    <parent>
        <groupId>mdv</groupId>
        <artifactId>json-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>json-ear</artifactId>
    <packaging>ear</packaging>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>mdv</groupId>
            <artifactId>json-ejb3</artifactId>
            <version>${project.version}</version>
            <type>ejb</type>
        </dependency>
        <dependency>
            <groupId>mdv</groupId>
            <artifactId>json-resources</artifactId>
            <version>${project.version}</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ear-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <version>7</version>
                    <defaultLibBundleDir>lib</defaultLibBundleDir>
                    <earSourceDirectory>${basedir}/src/main/resources</earSourceDirectory>
                    <outputFileNameMapping>@{artifactId}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
pom.xml for resources project
<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>
    <parent>
        <groupId>mdv</groupId>
        <artifactId>json-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>json-resources</artifactId>
</project>
pom.xml for ejb3 project
<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>
    <parent>
        <groupId>mdv</groupId>
        <artifactId>json-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>json-ejb3</artifactId>
    <packaging>ejb</packaging>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <ejbVersion>3.2</ejbVersion>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
        <!-- contains a json schema processing library and the class JsonSchemaValidatorEjb -->
            <groupId>mdv</groupId>
            <artifactId>json</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
    </dependencies>
</project>
The problem with loading schema files in EJB

I want to load the schema files in an @ApplicationScoped bean for use in a Singleton EJB, the corresponding class is JsonSchemaValidatorService:

package mdv;

import java.util.logging.Logger;

import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;

import json.ForEjbDeployment;
import json.IJsonSchemaValidator;

@Singleton
@Startup
public class JsonSchemaValidatorService {

    Logger log = Logger.getLogger("JsonSchemaValidatorService");

    @Inject
    @ForEjbDeployment
    IJsonSchemaValidator jsonSchemaValidator;
    // this is where json schema files should be loaded

    public JsonSchemaValidatorService() {
        //
    }

    @PostConstruct
    public void init() {
        log.info("Started JsonSchemaValidatorService.");
        log.info("Loaded schemas in jsonSchemaValidator: " + jsonSchemaValidator.getLoadedSchemas());
    }

}

The class for loading json schema files in EJB environment is this bean:

package json;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.function.Consumer;
import java.util.logging.Logger;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.resource.spi.IllegalStateException;

import org.leadpony.justify.api.JsonSchema;

@ForEjbDeployment
@ApplicationScoped
public class JsonSchemaValidatorEjb extends JsonSchemaValidatorBase {

    Logger log = Logger.getLogger("JsonSchemaValidator");

    public JsonSchemaValidatorEjb() {
        //
    }

    @PostConstruct
    public void init() {
        try {
            // This is where I can't manage to get a list of the json schema files and process them
            final ClassLoader loader = Thread.currentThread().getContextClassLoader();
            try(
                    final InputStream is = loader.getResourceAsStream("schemas");
                    final InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
                    final BufferedReader br = new BufferedReader(isr)) {
                log.info("schema files in directory: ");
                br.lines().forEach(x -> log.info(x));
            }
        } catch (Exception e) {
            throw new RuntimeException("Error trying to parse schema files!", e);
        }
    }
}

No Exception is thrown but also no files will be found in the directory provided, e.g. "schemas". The shortened output after EJB started is:

[JsonSchemaValidatorService] Started JsonSchemaValidatorService.
[JsonSchemaValidator] schema files in directory: 
[JsonSchemaValidatorService] Loaded schemas in jsonSchemaValidator: {}

The file structure of the deployed ear is this:

- lib
| - icu4j.jar
| - javax.json-api.jar
| - javax.json.jar
| - json-resources.jar // jar with resources, in this case the schemas
| | - schemas
| | | - person.schema.json
| - json.jar // jar containing @ApplicationScoped beans for war und ejb
| - justify.jar // json schema processing library used
- META-INF
| - maven
| | ...
| - schemas
| | - person.schema.json
| - application.xml
| - MANIFEST.MF
- schemas
| -person.schema.json
- json-ejb3.jar

As you can see I have managed to bundle the schemas folder and the single json schema file in multiple locations, but none of this works.

Is this even possible to achieve? Am I wrong with the path specified at getResourceAsStream("schemas")?

The goal is to load all existing json schema files at startup to parse them to JsonSchema objects once to validate them later on (it will be a message-driven bean, by the way).


Answer:

Finally I found a nice solution that works both in Servlet and EJB context and eliminates the need for distinguishing between them.

Since I am not able to list the files inside the schemas folder from within an EJB but access and read single files I came up with the idea to use an auto-generated – at build time – file containing the list of all JSON schema files and using this to process the schemas

Moving EJB to WAR deployment

First I followed the advice from @IllyaKysil and moved my EJB from an EAR deployment to the already existing and working WAR deployment

Move schema files into JAR

The original approach had the JSON schema files in both WAR and EAR deployments. I now have the files inside src/main/resources/schemas folder of the JAR project which I have a maven dependency on in the WAR project. Result structure of archive is:

| jee7-test.war
| - WEB-INF
| | - lib
| | | - json-validator-0.0.1-SNAPSHOT.jar
| | | | - schemas
| | | | | - person.schema.json
| | | | | - schemaList.txt
Generate schemaList.txt at build

Using the maven antrun plugin a file is created in src/main/resources/schemas with each file in the schemas directory with an extension of .schema.json on a seperate line:

<plugin>
   <artifactId>maven-antrun-plugin</artifactId>
   <version>1.8</version>
   <executions>
      <execution>
         <phase>generate-sources</phase>
         <configuration>
            <target>
               <fileset id="schemaFiles"
                  dir="src/main/resources/schemas/" includes="*.schema.json" />
               <pathconvert pathsep="${line.separator}"
                  property="schemaFileList" refid="schemaFiles">
                  <map from="${basedir}\src\main\resources\schemas\" to="" />
               </pathconvert>
               <echo
               file="${basedir}\src\main\resources\schemas\schemaList.txt">${schemaFileList}</echo>
            </target>
         </configuration>
         <goals>
            <goal>run</goal>
         </goals>
      </execution>
   </executions>
</plugin>

Content of generated file then is:

person.schema.json
Reading schemaList.txt and parsing schemas

Final step is reading the file with the list of JSON schema files and process each line to parse the corresponding schema file:

@ApplicationScoped
public class JsonSchemaValidator implements IJsonSchemaValidator {

    protected JsonValidationService jvs = JsonValidationService.newInstance();
    protected ConcurrentHashMap<String, JsonSchema> schemaMap = new ConcurrentHashMap<String, JsonSchema>();
    private Logger log = Logger.getLogger("JsonSchemaValidator");

    public JsonSchemaValidator() {
        //
    }

    private String SCHEMA_FOLDER = "schemas/";
    private String SCHEMA_LIST_FILE = "schemaList.txt";

    @PostConstruct
    public void init() {
        try {
            final ClassLoader loader = Thread.currentThread().getContextClassLoader();
            // load file containing list of JSON schema files
            try (final InputStream is = loader.getResourceAsStream(SCHEMA_FOLDER + SCHEMA_LIST_FILE);
                    final InputStreamReader isr = new InputStreamReader(is, StandardCharsets.UTF_8);
                    final BufferedReader br = new BufferedReader(isr)) {
                // each line is a name of a JSON schema file that has to be processed
                br.lines().forEach(line -> readSchema(line, loader));
            }
            log.info("Number of JsonSchema objects in schemaMap: " + schemaMap.size());
            log.info("Keys in schemaMap: ");
            schemaMap.forEachKey(1L, key -> log.info(key));
        } catch (Exception e) {
            throw new RuntimeException("Error trying to parse schema files!", e);
        }
    }

    private void readSchema(String schemaFileName, ClassLoader classLoader) {
        // only use part of the file name to first dot, which leaves me with "person"
        // for "person.schema.json" file name
        String schemaName = schemaFileName.substring(0, schemaFileName.indexOf("."));
        JsonSchema js = jvs.readSchema(classLoader.getResourceAsStream(SCHEMA_FOLDER + schemaFileName));
        // put JsonSchema object in map with schema name as key
        schemaMap.put(schemaName, js);
        log.info("Schema " + schemaName + " added: " + js.toJson());
    }

    @Override
    public List<Problem> validate(String json, String schemaName) {
        List<Problem> result = new ArrayList<Problem>();
        JsonSchema jsonSchema = schemaMap.get(schemaName);
        JsonReader reader = jvs.createReader(new StringReader(json), jsonSchema, ProblemHandler.collectingTo(result));
        reader.read();

        return result;
    }

    @Override
    public Map<String, JsonSchema> getLoadedSchemas() {
        return Collections.unmodifiableMap(schemaMap);
    }
}
Result

JSON strings from input can now be validated against a JSON schema without the need to parse the schema over and over again

@Inject
IJsonSchemaValidator jsv;
...
List<Problem> problems = jsv.validate(inputJson, "person");

Logged output after JsonSchemaValidator instance has been created:

Schema person added: {"$id":"....}
Number of JsonSchema objects in schemaMap: 1
Keys in schemaMap: 
person

Question:

I have a problem that I get the following error. Project has jar about this services and my web.xml following

Please help me.

<ejb-local-ref>
    <ejb-ref-name>ejb/KpsSessionFacade</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local>tr.com.meop.db.session.KpsSessionFacadeLocal</local>
    <ejb-link>KpsSessionFacade</ejb-link>
</ejb-local-ref>

Log:

javax.naming.NameNotFoundException: While trying to look up comp/env/ejb/KpsSessionFacade in /app/ejb/meop-service-1.jar#KisiManagerService.; remaining name 'comp/env/ejb/KpsSessionFacade'

at javax.naming.InitialContext.lookup(InitialContext.java:411) at tr.com.meop.scheduler.client.MernisWsFactory.log(MernisWsFactory.java:686) at tr.com.meop.scheduler.client.MernisWsFactory.tcKimliktenAdresSorgula(MernisWsFactory.java:300) at tr.com.meop.business.kisi.service.KisiManagerServiceImpl.findKisiBilgisiByTckn(KisiManagerServiceImpl.java:344) . . .

at tr.com.meop.app.kisi.action.KisiAction.bulKisiBilgilerByTcknProcess(KisiAction.java:684) at tr.com.meop.app.kisi.action.KisiAction.bulKisiBilgilerByTckn(KisiAction.java:672) . .


Answer:

Add a prefix java in your lookup code. It will be like below:

"java:comp/env/ejb/KpsSessionFacade"

A full example is given in this link: javax.naming.NameNotFoundException: jdbc not bound

Some steps are used for checking, is given here: javax.naming.NameNotFoundException: Unable to resolve 'MyDB'. Resolved '' Weblogic 12.1.3. c

Question:

I have tow maven projects:

1) named test where i have my tow interfaces:

package interfaces.locals;
import javax.ejb.Local;
@Local
public interface IClientLocal {
void showClientName();
}

package interfaces.Remotes;
import javax.ejb.Remote;
@Remote
public interface IClientRemote {
void showClientName();
}

The pom.xmllooks like:

<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</groupId>
<artifactId>test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
    <dependency>
        <groupId>javax.ejb</groupId>
        <artifactId>ejb-api</artifactId>
        <version>3.0</version>
    </dependency>
</dependencies>

2) named testImpl where i have my implementation class:

The pom.xml looks like:

<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>testImpl</groupId>
<artifactId>testImpl</artifactId>
<version>0.0.1</version>
<dependencies>
    <dependency>
        <groupId>javax.ejb</groupId>
        <artifactId>ejb-api</artifactId>
        <version>3.0</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.10</version>
    </dependency>
    <dependency>
        <groupId>test</groupId>
        <artifactId>test</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>
</dependencies>

The Impl class looks like:

package implimentations;
import javax.ejb.Stateless;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import interfaces.Remotes.IClientRemote;
import interfaces.locals.IClientLocal;
@Stateless
public class Client implements IClientLocal, IClientRemote {    
private final static Logger LOGGER=LoggerFactory.getLogger(Client.class);
public void showClientName() {
    LOGGER.info("The name of this client is ==> Alonso.");      
}

}

NB: when i add the anotation @Override above the showClientName() method it gives me that error : The method showClientName() of type Client must override a superclass method so when i remove it i works.

When i deploy the jar of testImpl project on the Jboss server EAP 6 it gives me these errors :

`16:21:31,395 WARN  [org.jboss.modules] (MSC service thread 1-3) Failed to define class implimentations.Client in Module "deployment.testImpl-0.0.1.jar:main" from Service Module Loader: java.lang.LinkageError: Failed to link implimentations/Client (Module "deployment.testImpl-0.0.1.jar:main" from Service Module Loader)
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:428) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ModuleClassLoader.loadClassLocal(ModuleClassLoader.java:261) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ModuleClassLoader$1.loadClassLocal(ModuleClassLoader.java:76) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.Module.loadModuleClass(Module.java:548) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:189) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:443) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:431) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:373) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:118) [jboss-modules.jar:1.3.0.Final-redhat-2]
at java.lang.Class.forName0(Native Method) [rt.jar:1.7.0_75]
at java.lang.Class.forName(Class.java:274) [rt.jar:1.7.0_75]
at org.jboss.as.server.deployment.reflect.DeploymentClassIndex.classIndex(DeploymentClassIndex.java:54)
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.processComponentConfig(InterceptorAnnotationProcessor.java:85) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.ee.component.deployers.InterceptorAnnotationProcessor.deploy(InterceptorAnnotationProcessor.java:77) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:120)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_75]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_75]`
`Caused by: java.lang.NoClassDefFoundError: interfaces/locals/IClientLocal
at java.lang.ClassLoader.defineClass1(Native Method) [rt.jar:1.7.0_75]
at java.lang.ClassLoader.defineClass(ClassLoader.java:800) [rt.jar:1.7.0_75]
at org.jboss.modules.ModuleClassLoader.doDefineOrLoadClass(ModuleClassLoader.java:345) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ModuleClassLoader.defineClass(ModuleClassLoader.java:423) [jboss-modules.jar:1.3.0.Final-redhat-2]`
`Caused by: java.lang.ClassNotFoundException: interfaces.locals.IClientLocal from [Module "deployment.testImpl-0.0.1.jar:main" from Service Module Loader]
at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:197) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:443) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:431) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:373) [jboss-modules.jar:1.3.0.Final-redhat-2]
at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:118) [jboss-modules.jar:1.3.0.Final-redhat-2]
... 23 more`

Answer:

In AS7 or EAP6 each deployed JAR and WAR file is treated as a module. In your case you have two separate deployments test-0.0.1-SNAPSHOT.jar and testImpl-0.0.1-SNAPSHOT.jar, you need add the dependency from testImpl-0.0.1-SNAPSHOT.jar to test-0.0.1-SNAPSHOT.jar.

Dependencies can be configured adding entries to the MANIFEST.MF file of the deployment.

Eg:

Dependencies: deployment.test-0.0.1-SNAPSHOT

With maven:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ejb-plugin</artifactId>
    <version>2.3</version>
    <configuration>
        <ejbVersion>3.1</ejbVersion>
        <archive>
            <manifestEntries>
                <Dependencies>deployment.test-0.0.1-SNAPSHOT</Dependencies>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>

Alternatively you can deploy all jar files in one ear file to resolve this problem.

See more:

Question:

I'm currently writing a set of EJBs that interface with some old EJB2 code. As part of this, I have an ejb-jar.xml deployment descriptor that contains resource-refs and ejb-refs for the session beans. All of these definitions are basically identical - only the session bean's name differs between them. Obviously, this isn't ideal - every time I add a new bean, I have to copy and paste a large block of XML.

The structure looks something like this:

<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_1.xsd" version="3.1">
    <enterprise-beans>
        <session>
            <ejb-name>/* redacted */</ejb-name>

            <resource-ref>
                <res-ref-name>/* redacted */</res-ref-name>
                <res-type>javax.sql.DataSource</res-type>
                <res-auth>Application</res-auth>
                <lookup-name>/* redacted */</lookup-name>
            </resource-ref>

            <ejb-ref>
                <ejb-ref-name>/* redacted */</ejb-ref-name>
                <ejb-ref-type>Session</ejb-ref-type>
                <home>/* redacted */</home>
                <remote>/* redacted */</remote>
            </ejb-ref>

            /* about 20 more ejb-refs later... */
        </session>

        /* several near identical session beans here ... */
</ejb-jar>

Is there any way to re-use these references in multiple definitions without duplication? Or, alternatively, is there a better way of achieving the same end result that I'm missing?


Answer:

In my particular scenario, I was able to solve the issue by packaging the EJBs as a WAR instead of a plain JAR file - this allowed me to provide the references in web.xml for the application as a whole, rather than on a per-bean level.

Question:

I have an EAR file with 3 WARs and some common dependencies within lib/ folder. One of those dependencies has an EJB with a scheduled method, but it seems that the server is not recognizing it. No evidence in log, no code executed.

But when I deploy a simple war with the same jar within WEB-INF/lib, it works. I've already tried to package the jar as an ejb-jar with the maven plugin, but no success at all.

Any ideas on what must be going on?


Answer:

Jars in the lib directory of an EAR are not considered to be EJB jars and their content is not considered at deployment time in that respect. The lib directory only exists to make it easier to provide library jars whose classes are automatically made visible to all the modules in an EAR file.

Your EAR file contains a META-INF/application.xml file that lists out the various modules that it contains. Prior to Java EE 6, only ejb-modules were considered for potential EJBs. Java EE 6 and newer added web-modules to that list. All jars within a web-module's WEB-INF/lib directory are considered to be part of the web-module, even if they contain ejb-jars. Any ejb-jar.xml files found within a web-module are merged together. This applies even if the web-module is deployed as a standalone WAR file.

Question:

When I try to deploy my JavaEE 7 war project on a payara 4.1.1 server the following error occurs:

Error occurred during deployment: Exception while loading the app : CDI deployment failure:WELD-001408: Unsatisfied dependencies for type RatingEJB with qualifiers @Default at injection point [BackedAnnotatedField] @Inject private rest.resources.RatingResource.persistenceBean at rest.resources.RatingResource.persistenceBean(RatingResource.java:0) .

The stracktrace is as follows:

org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type RatingEJB with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private rest.resources.RatingResource.persistenceBean
at rest.resources.RatingResource.persistenceBean(RatingResource.java:0)
at org.jboss.weld.bootstrap.Validator.validateInjectionPointForDeploymentProblems(Validator.java:355)
at org.jboss.weld.bootstrap.Validator.validateInjectionPoint(Validator.java:277)
at org.jboss.weld.bootstrap.Validator.validateGeneralBean(Validator.java:130)
at org.jboss.weld.bootstrap.Validator.validateRIBean(Validator.java:151)
at org.jboss.weld.bootstrap.Validator.validateBean(Validator.java:494)
at org.jboss.weld.bootstrap.Validator.validateBeans(Validator.java:480)
at org.jboss.weld.bootstrap.Validator.validateDeployment(Validator.java:455)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:454)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.glassfish.weld.WeldDeployer.event(WeldDeployer.java:226)
at org.glassfish.kernel.event.EventsImpl.send(EventsImpl.java:131)
at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:329)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:497)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:220)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:487)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:356)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:263)
at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:234)
at org.glassfish.admin.rest.utils.ResourceUtil.runCommand(ResourceUtil.java:285)
at org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:136)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory$1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:144)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:161)
at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:160)
at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:99)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:389)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:347)
at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:102)
at org.glassfish.jersey.server.ServerRuntime$2.run(ServerRuntime.java:326)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:317)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:305)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1154)
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:384)
at org.glassfish.admin.rest.adapter.RestAdapter$2.service(RestAdapter.java:316)
at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:466)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:169)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:526)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:593)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:573)
at java.lang.Thread.run(Thread.java:745)

Here is my project structure

project structue 1

project structue 2

This is the resource class from the war project:

package rest.resources;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import persistance.ejb.RatingEJB;
import persistance.entities.Personalization;
import persistance.entities.Rating;
import rest.domain.RatingCollection;
import rest.domain.RatingDetails;
import rest.factory.RatingCollectionFactory;

@Stateless
@Path("/ratings")
public class RatingResource implements IRatingResource
{
@Context
private UriInfo uriInfo;

@Inject
private RatingEJB persistenceBean;

@Inject
private RatingDetailsFactory detailsFactory;
@Inject
private RatingCollectionFactory CollectionFactory;

@Override
public Response get(int start, int size)
{
    RatingCollection collection = null;

    List<RatingDetails> details = new ArrayList<>();
    List<Rating> list = persistenceBean.findAll(start, size);

    if (list != null)
    {
        Iterator<Rating> iterator = list.iterator();
        while (iterator.hasNext())
        {
            Rating rating = iterator.next();
            RatingDetails ratingDetails = detailsFactory.createDetail(uriInfo, persistenceBean.create(rating), rating.getId());

            details.add(ratingDetails);
        }
        collection = CollectionFactory.createCollection(details, uriInfo, size, start);
    }

    return Response.ok(collection).build();
}

}

Here is the ejb class from the jar

package persistance.ejb;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

import persistance.entities.Rating;

@Stateless
public class RatingEJB implements IPersistanceBean<Rating>
{
@PersistenceContext(unitName = "feedback")
private EntityManager em;

@Override
public Rating find(Object id)
{
    return em.find(Rating.class, id);
}

@Override
public List<Rating> findAll(int start, int size)
{
    TypedQuery<Rating> query = em.createQuery("SELECT r FROM Rating r", Rating.class);
    query.setFirstResult(start).setMaxResults(size);

    return query.getResultList();
}

@Override
public Rating create(Rating rating)
{
    em.persist(rating);

    return rating;
}

@Override
public void remove(Object id)
{
    em.remove(em.find(Rating.class, id));
}

@Override
public Rating update(Rating item)
{
    // TODO Auto-generated method stub
    return null;
}
}

And here are the poms of the projects

parent:

<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>feedback</groupId>
<artifactId>feedback-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>feedback-parent</name>
<modules>
    <module>feedback-persistance</module>
    <module>feedback-rest</module>
</modules>

<properties>
    <version.java>1.7</version.java>
    <version.maven.clean.plugin>2.4.1</version.maven.clean.plugin>
    <version.maven.war.plugin>2.4</version.maven.war.plugin>
    <version.maven.compiler.plugin>3.1</version.maven.compiler.plugin>
    <version.maven.exec.plugin>1.2.1</version.maven.exec.plugin>
    <javaee.api.version>7.0</javaee.api.version>
</properties>

<dependencies>
    <!-- Java EE -->
    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>${javaee.api.version}</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>rest</groupId>
        <artifactId>rest-api</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

</dependencies>

<build>
    <finalName>feedback</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>${version.maven.clean.plugin}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${version.maven.compiler.plugin}</version>
                <inherited>true</inherited>
                <configuration>
                    <source>${version.java}</source>
                    <target>${version.java}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>${version.maven.war.plugin}</version>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

feedback-psersistance:

<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>
<parent>
    <groupId>feedback</groupId>
    <artifactId>feedback-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>feedback-persistance</artifactId>
<name>feedback-persistance</name>

<build>
    <finalName>feedback-persistance</finalName>
</build>

and feedback-rest

<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>
<parent>
    <groupId>feedback</groupId>
    <artifactId>feedback-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>feedback-rest</artifactId>
<packaging>war</packaging>
<name>feedback-rest</name>

<dependencies>
    <dependency>
        <groupId>rest</groupId>
        <artifactId>rest-api</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </dependency>

    <dependency>
        <groupId>feedback</groupId>
        <artifactId>feedback-persistance</artifactId>
        <version>0.0.1-SNAPSHOT</version>
        <scope>system</scope>
        <systemPath>C:\Users\user\workspace_neon\feedback-parent\feedback-persistance\target\feedback-persistance.jar</systemPath>
    </dependency>
</dependencies>

<build>
    <finalName>feedback-rest</finalName>
</build>

So, what is wrong with my implementation? I'm new to JavaEE and everything I found on the web didn't work.

Thanks in advance. Rudi


Answer:

I was able to solve my problem. The solution was to create an ear project that includes the jar and the war project. Now I can deploy the ear project at the payara server and query the database from my rest services.

Here is the pom of the ear project

<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>
<parent>
    <groupId>feedback</groupId>
    <artifactId>feedback-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>feedback-ear</artifactId>
<packaging>ear</packaging>
<name>feedback-ear</name>

<dependencies>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>feedback-persistance</artifactId>
        <version>${project.version}</version>
        <type>ejb</type>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>feedback-rest</artifactId>
        <version>${project.version}</version>
        <type>war</type>
    </dependency>
</dependencies>

<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.10.1</version>
            <configuration>
                <version>7</version>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <skinnyWars>true</skinnyWars>
                <modules>
                    <webModule>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>feedback-rest</artifactId>
                    </webModule>
                    <ejbModule>
                        <groupId>${project.groupId}</groupId>
                        <artifactId>feedback-persistance</artifactId>
                    </ejbModule>
                </modules>
            </configuration>
        </plugin>
    </plugins>
</build>

Question:

Is there a way to separate EJB among multiple JARs? I want to modularize an EJB application but I want to load classes (session beans and entities from different JARs).

Therefore I have a parent EJB project and child modules.

EJB-PARENT
     |____jar module1
     |____jar module2
     |____jar module 3

I'm using Maven and an EAR to deploy EJBs and its children.


Answer:

If you tought use multiple ejb jars in war files, then it is OK. Just build the EJBs into ejb jars and put them into the classpath of the WAR project. After that you can refer to the contained EJS-s.

But there is no way a tree like module structure as like in your diagram above.

Question:

I have a strange problem with EJB injection in the glassfish 3. Maybe I just not completely understand what I do :)

So this is a problem: My project consists of 2 modules that will be assembled with gradle.

  • Module A
  • Module B

Module A is a usual glassfish module that also works fine. Module B contains general purpose staff. Module B is also a dependency of A. Module A will be deployed to glassfish as a *.war archive and Module B is in the appropriate lib folder as *.jar archive:

module-a.war and somewere inside of it ../lib/module-b.jar

What I want is: Create in the Module B a "general purpose" stateless bean and use it in the Module A. But it doesn't work...

In the Module B I created a bean:

@Stateless
public class GeneralPurposeBean {}

and I try to use it in the Module A as follows:

...
@EJB
private GeneralPurposeBean genPurpBean;
...

So how I already mentioned the GeneralPurposeBean is in the *.jar

Each time when I try to use the bean it fails with following exception:

javax.ejb.CreateException: Could not create stateless EJB

When I move the bean to the Module A it works fine but I want share this bean with other modules, that will be developed in the future. Can someone explain to me what is wrong here? So the bean will be recognized but it can't be created. What I found out through debugging is that

JCDIServiceImpl#_createJCDIInjectionContext

Doesn't recognize the bean as an enterprise bean. So everything in the *.war that directly accessible will be properly created but not what lies in the *.jar's.


Answer:

For the case someone has the same problem:

If you treat one of your modules as a dependency and this module contains EJB beans you want be injected the solution for my problem was to put /META-INF/beans.xml file into the module. Otherwise container doesn't recognize the beans as EJB.

That's it.

Question:

I have a main project used as a standalone batch that I want to move to the container using EJB timer (using WildFly 8.2). I thought building a WAR file with the timer class and the dependencies withing WEB-INF/lib, but doesn't sound an elegant solution because it isn't a web app, it doesn't need to bound a context. It's just a JAR, with an EJB inside and the dependencies (I'm using a fat jar) but the container throws an error when I deploy it. Should I use an EAR? Or do you guys think a WAR file is fine? PS: I'm using Maven, so possible suggestions can take it in account.


Answer:

You don't really need it in a WAR file if it's not a web application, although it doesn't harms. I would also put it in a JAR file, i don't like to add something that doesn't have a meaning...it can be confusing for others. But as @Bruno César pointed out, you need to package first the EJB(s). Have a look at this; you'll see the ways to package them as JAR, WAR, EAR.

Question:

My ear structure is as follows:

XYZ.ear
    |
    |------------- lib
    |-------------META-INF
    |--------------firstEJB.jar
    |--------------app.war

When I am trying to deploy the XYZ.ear, I am not able to access classes in firstEJB.jar. I am getting followint error when trying to deploy:

15:49:24,583 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-5) MSC000001: Failed to start service jboss.deployment.subunit."XYZ.ear"."app.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.subunit."XYZ.ear"."app.war".POST_MODULE: JBAS018733: Failed to process phase POST_MODULE of subdeployment "app.war" of deployment "XYZ.ear"
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
    at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.0.Final.jar:1.2.0.Final]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_71]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_71]
    at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_71]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: java.lang.ClassNotFoundException: com.sial.ecommerce.core.init.DeepInit from [Module "deployment.XYZ.ear.app.war:main" from Service Module Loader]
    at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:292)
    at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scanWebDeployment(JaxrsScanningProcessor.java:154)
    at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:105)
    at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:159) [wildfly-server-8.0.0.Final.jar:8.0.0.Final]
    ... 5 more
Caused by: java.lang.ClassNotFoundException: com.sial.ecommerce.core.init.DeepInit from [Module "deployment.XYZ.ear.app.war:main" from Service Module Loader]
    at org.jboss.modules.ModuleClassLoader.findClass(ModuleClassLoader.java:213) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassUnchecked(ConcurrentClassLoader.java:459) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClassChecked(ConcurrentClassLoader.java:408) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.performLoadClass(ConcurrentClassLoader.java:389) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.modules.ConcurrentClassLoader.loadClass(ConcurrentClassLoader.java:134) [jboss-modules.jar:1.3.3.Final]
    at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:290)

DeepInit class is a class in firstEJB.jar.

When I try to add firstEJB.jar inside lib directory, it is showing some beanmanager related issues, since it contains ejbs. So I tried to put this jar outside lib directory, after going through this link:

https://docs.jboss.org/author/display/WFLY8/Class+Loading+in+WildFly.

I am using build.gradle to build the EAR.My build.gradle is:

buildscript {
    repositories {
        mavenCentral(); 
        maven {
            url "https://repository.jboss.org/nexus/content/repositories/releases/"
        }
    }

    configurations {
        compile
        testCompile
        testRuntime
        jacoco
    } 

    dependencies { 
        classpath 'org.ajoberstar:gradle-jacoco:0.3.0'
    }  
}

allprojects {
    group = 'com.sial.ecommerce'
    version = ''


    repositories {
        mavenCentral();
        maven {
            url "https://repository.jboss.org/nexus/content/repositories/releases/"
        }
    }

    apply plugin: 'java'
    apply plugin: 'jacoco';

    apply plugin: 'ear'

    dependencies {
        deploy project(path:':app', configuration: 'archives');
        deploy project(path:':firstEJB', configuration: 'archives');


    }

    ear {
        version = "";

        archiveName ="XYZ.ear";

        appDirName 'EarContent'

        duplicatesStrategy = DuplicatesStrategy.EXCLUDE;
        caseSensitive = true;

        rootSpec.exclude("**/activation-1.1.jar");
        rootSpec.exclude("**/asm*.jar");
        rootSpec.exclude("**/jboss-*.jar");
        rootSpec.exclude("**/org.jacoco*.jar");
        rootSpec.exclude("**/wildfly-*.jar");
        rootSpec.exclude("**/hibernate-*.jar");
        rootSpec.exclude("**/gradle-*.jar");
        rootSpec.exclude("**/cdi-*.jar");
        rootSpec.exclude("**/org.osgi.*.jar");
        rootSpec.exclude("**/serializer-*.jar");
        rootSpec.exclude("**/arquillian-*.jar");
        rootSpec.exclude("**/resteasy-*.jar");
        rootSpec.exclude("**/guava-*.jar");
        rootSpec.exclude("**/jackson-jaxrs-*.jar");
        rootSpec.exclude("**/jackson-core-asl-*.jar");
        rootSpec.exclude("**/jackson-mapper-asl-*.jar");
        rootSpec.exclude("**/reflections-*.jar");
        rootSpec.exclude("**/metrics-core-*.jar");
        rootSpec.exclude("**/servo-core-*.jar");
        rootSpec.exclude("**/aspectjweaver-*.jar");
        rootSpec.exclude("**/javax.json-*.jar");
        rootSpec.exclude("**/jaxrs-api-*.jar");
        rootSpec.exclude("**/javax.mail-*.jar");
        rootSpec.exclude("**/validation-api-*.jar");
        rootSpec.exclude("**/javassist-*.jar");
        rootSpec.exclude("**/dom4j-*.jar");
        rootSpec.exclude("**/annotations-*.jar");
        rootSpec.exclude("**/javax.inject-*.jar");
        rootSpec.exclude("**/xalan-*.jar");
        rootSpec.exclude("**/el-api-*.jar");
        rootSpec.exclude("**/jsr250-api-*.jar");
        rootSpec.exclude("**/xml-apis-*.jar");
        rootSpec.exclude("**/slf4j-api-1.7.6.jar");
    }
}

My application.xml in META-INF looks like :

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd" id="Application_ID" version="7">
  <display-name>ABC</display-name>
  <module>
    <web>
      <web-uri>app.war</web-uri>
      <context-root>app</context-root>
    </web>
  </module>
  <module>
      <ejb>myfirstEJB.jar</ejb>
    </module>
</application>

One more issue I noticed is that, for deployment the server is searching for files from:

C:\Apps\wildfly8.0.0.Final\bin directory

ERROR com.sial.ecommerce.core.init.DeepInit - C:\Apps\wildfly-8.0.0.Final\bin\src\test\resources\xml\con\con.json (The system cannot find the path specified)

DEEPInit class is a class in myfirstEJB.jar.

instead of

C:\Apps\wildfly-8.0.0.Final\standalone\deploments directory(where our ear is present).

Can someone help me to build and deploy a proper ear so that classes in firstEJB.jar can be accessed?


Answer:

It look's like class com.sial.ecommerce.core.init.DeepInit trying to read local resource using code like this:

new File(".\src\test\resources\xml\con\con.json");

If it's true, replace this code with:

com.sial.ecommerce.core.init.DeepInit.getResource("xml\con\con.json");

Question:

I have a web service that will be deployed two separate VM (example: VM123 and VM300). Depending on the VM id (VM123 or VM300), a subset of message driven beans should be deployed. Is it possible to create ejb-jar.xml with a conditional statement to specify or define the set of mdb's to be deployed VM123 vs VM300 based on a criteria such as environment variable or jndi property? If so, would you provide an example and/or reference?


Answer:

I wouldnt do this programamtically, but use a maven plugin, that includes classes based on environment information specified.

So, somewhere within one of your maven resource plugins, you add profiles which dictate which ejbs beans to include during compilation, and which ones to ignore.

so you could have two profiles:

  1. vm01 from which you compile your project with mvn -Pvm01
  2. vm02 whence mvn -Pvm02

More details on maven compiler plugin and resource helper plugin:

Maven Compiler Plugin Maven Resources Plugin

Question:

I try to look up and EJB under jboss EAP6. I have 2 mavenized projects :

  1. Interfaces where I have justeinterfaces.
  2. Implementations where I have only the implementations of interfaces and my tests classes (I use testNG)

My question is: Do I have to deploy on the server the interfaces or the implementations projects?


Answer:

i have to deploy the jar of maven project where i have all implementations class