weblogic 12c deployment failure - java

I'm migrating from Weblogic 11g to 12c, during the deployment process it fails and shows the following error:
Caused by: weblogic.application.naming.ReferenceResolutionException: [J2EE:160199]Error resolving ejb-ref "ejb/BizRuleFacade" from module "BizAgi-ejb.jar" of application "BizAgi-ear-Weblogic". The ejb-ref does not have an ejb-link and the JNDI name of the target bean has not been specified. Attempts to automatically link the ejb-ref to its target bean failed because multiple EJBs in the application were found to implement the "BizAgi.bpm.rules.entities.BizRuleFacade" interface, including BizAgi-war.war/BizRuleFacadeBean, BizAgi-ejb.jar/BizRuleFacadeBean. Specify a qualified ejb-link for this ejb-ref to indicate which EJB is the target of this ejb-ref.
My web.xml file looks like this:
<ejb-local-ref>
<ejb-ref-name>ejb/BAScopeLogFacade</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local>BizAgi.PAL.historylog.entities.BAScopeLogFacade</local>
<ejb-link>BizAgi-ejb.jar#BAScopeLogFacadeBean</ejb-link>
</ejb-local-ref>
The BizAgi-ejb.jar is a module inside the ear (BizAgi-ear-Weblogic.ear).
How can i properly deploy my application?

Thank you so much everybody, I've finally found the solution, it is to simply delete/remove the META-INF/MANIFEST.MF file from the .war file. That way the EJBs aren't double referenced.

1.Add below dependency in Ear Pom.xml
<dependency>
<groupId>com.example</groupId>
<artifactId>ejbModel</artifactId>
<version>1.0-SNAPSHOT</version>
<type>ejb</type>
</dependency>
2.In Ear pom.xml in modules add ejb module
<modules>
<ejbModule>
<groupId>com.example</groupId>
<artifactId>ejbModel</artifactId>
<bundleFileName>ejbModel-1.0-SNAPSHOT.jar</bundleFileName>
</ejbModule>
.......
</modules>
3.Change scope of ejbmodel dependency to provided in application pom.xml
<dependency>
<groupId>com.example</groupId>
<artifactId>ejbModel</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
4.add persistence.xml of ejbmodel application to resource folder

Make sure that the same EJBs are not loaded multiple times in your deployment. You can check this by using the weblogic console (AdminServer) and checking the EJBs of the deployment (by clicking the little "+" sign next to the deployment that is failing int the deployments overview).
In my case I had to fix the maven dependencies (by setting one dependency of one project to "provided") so that it did not load the same EJB twice.

ERROR:
weblogic.management.DeploymentException: weblogic.application.naming.ReferenceResolutionException: [J2EE:160199]Error resolving ejb-ref "com.xxx.xxx.xxx.xxx.xxx.xxx.XXXX/xxxRemote" from module
"XXX-X.X.X.war" of application "XXX-X.X.X". The ejb-ref does not have an ejb-link and the JNDI name of the target Bean has not been specified.
SOLUTION:
1 SOLUTION: pom.xml (Web Project)
<dependencies>
<dependency>
<groupId>co.xx.cxxxx</groupId>
<artifactId>xxxxx-ejb</artifactId>
<version>1.0</version>
<type>ejb</type>
<scope>provided</scope>
</dependency>
<dependencies>
2 SOLUTION: Delete xxxxx-ejb.jar
xxxx.ear > xxxx.war > WEB-INF > lib > xxx-ejb.jar [remove]
3 Conclusion:
This is because there is a double reference to the ejb.jar, therefore the best way to control this is by saying in pom (web) that the is of type EJB, in order to take the (ejb.jar ) from the parent (EAR, where the ejb module is added).
I hope to be of help

Related

#PostConstruct method called twice when making the module containing the EJB a dependency of another module

My maven project structure looks like this:
test_project-parent
|test_project-ejb.jar
|test_project-depl.jar
|test_project-web.war
|test_project-ear.ear
My 3 modules: ejb, depl and web are packaged into the EAR.
I have an EJB in my ejb module that looks like this:
#Startup
#Singleton
public class StartupBean {
#PersistenceContext
private EntityManager em;
#PostConstruct
private void sayHello () {
System.out.println("HELLO !!!");
}
}
My problem is that that the sayHello() method is executed twice.
Here's the output from the log:
00:16:13,803 INFO [stdout] (ServerService Thread Pool -- 113) HELLO !!!
00:16:13,803 INFO [stdout] (ServerService Thread Pool -- 117) HELLO !!!
My ejb module is a dependency of my web module.
When I remove the dependency it works fine (the method is called once as it should be).
The pom.xml of my web module looks like this:
<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>com.testing</groupId>
<artifactId>test_project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>test_project-web</artifactId>
<packaging>war</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>test_project-ejb</artifactId>
<version>${test_project.version}</version>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
</dependency>
</dependencies>
</project>
NOTE: I have read all the related posts and found no answer
I found my error. I needed to change the scope of my dependency to provided, because the way it was the dependency was packaged inside the war archive in it's lib folder. So, basically, my ejb module was deployed twice, and hence the double execution of the #PostConstruct method.
I added <scope>provided</scope> to the ejb dependency inside my web module pom.xml and everything works fine. The ejb module is no longer packaged inside the lib folder of the war archive and the #PostConstruct method is called only once.

How to deploy a module in an Alfresco deployed in Tomcat

I have successfully deployed alfresco community 4.2.f in a Tomcat 7.0.59 with a database MySQL5.6 and jdk1.8.0_141
No problems thus far, now, I got a module developed by our company which I need to be deployed in alfresco. This module invokes a WS which will send a PDF to some place.
I got this module in a jar compiled with jdk1.8.0_141
I tried to put it inside the alfresco.war before deployment in Tomcat in WEB-INF/lib but when I do that and deploy with startup.bat from Tomcat it pops in the console
instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: org/codehaus/xfire/XFireRuntimeException
I understand this exception is caused by putting the jar inside the war.
I was told that the jar was compiled also in jdk8.
Also, tell you that if instead of this jar I put inside the alfresco.war in WEB-INF/classes a properties file to get our database in deployment it works fine.
The problem is when I try to deploy the module.
I saw there are quite tutorials pointing to do something like:
java -jar bin/alfresco-mmt.jar
I can't do that because this is done installing alfresco with its wizard I assume. I did it deploying alfresco in a fresh tomcat installation.
Does anyone know how to deploy our module with the way we deployed alfresco? Thank you.
You have two ways to install your amp :
The first traditional one :
This is the one installed with the apply amp procédure (alfresco-mmt).
To me, this is not true that it is not compatible with your installation. You can easily find the bin folder (containing the alfresco-mmt.jar file) here in the alfresco packaging : https://download.alfresco.com/release/community/4.2.f-build-00012/alfresco-community-4.2.f.zip
When you have it, you can follow the documentation : http://docs.alfresco.com/4.2/tasks/amp-install.html
And apply your amp for example following this way :
java -jar alfresco-mmt.jar install <AMPFileLocation> <WARFileLocation>
The second one :
You can recreate the war with the alfresco sdk and include in the build the module you created.
If you follow this documentation : http://docs.alfresco.com/4.2/tasks/dev-extensions-maven-sdk-tutorials-all-in-one-archetype.html
the war produced in the target folder of the repo part will contain your module, since the pom of this module will contains a dependency to the amp module :
...
<dependencies>
<dependency>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco</artifactId>
<type>war</type>
</dependency>
<!-- Demonstrating the dependency on the repo AMP developed in the 'amp'
module -->
<dependency>
<groupId>x.y.z</groupId>
<artifactId>my-amp</artifactId>
<version>${my-amp.version}</version>
<type>amp</type>
</dependency>
</dependencies>
...
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<!-- Here is can control the order of overlay of your (WAR, AMP, etc.)
dependencies | NOTE: At least one WAR dependency must be uncompressed first
| NOTE: In order to have a dependency effectively added to the WAR you need
to | explicitly mention it in the overlay section. | NOTE: First-win resource
strategy is used by the WAR plugin -->
<overlays>
<!-- Current project customizations -->
<overlay />
<!-- The Alfresco WAR -->
<overlay>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco</artifactId>
<type>war</type>
<!-- To allow inclusion of META-INF -->
<excludes />
</overlay>
<!-- Add / order your AMPs here -
<overlay>
<groupId>x.y.z</groupId>
<artifactId>my-amp</artifactId>
<type>amp</type>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>

Spring Boot JNDI not found - can't compile WAR with Maven

i can't mvn clean install my project.
I need to use a remote JNDI in WAR(not jar), but having the name in application.properties throws error during mvn clean install(due to "datasource jndi name not found")
if I have to use jndi name from a remote server, that I have no control over, how do i compile my package in WAR without lookup fail, but let it look up during the deployment/installation of the app on the server? any hint, or direction is very much appreicated...
in app prop, i have
spring.datasource.jndi-name=jdbc/ff-app
I have tried: Spring boot JNDI datasource lookup failure - Name comp/env/jdbc not found in context "java:"
tried, http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-connecting-to-a-jndi-datasource
and pretty much every questions asked in stackoverflow about a remote jndi..
Some of the errors:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/ff-app'; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
... 69 common frames omitted
Caused by: org.springframework.jdbc.datasource.lookup.DataSourceLookupFailureException: Failed to look up JNDI DataSource with name 'jdbc/ff-app'; nested exception is javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup.getDataSource(JndiDataSourceLookup.java:48) ~[spring-jdbc-4.3.6.RELEASE.jar:4.3.6.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration.dataSource(JndiDataSourceAutoConfiguration.java:62) ~[spring-boot-autoconfigure-1.5.1.RELEASE.jar:1.5.1.RELEASE]
at org.springframework.boot.autoconfigure.jdbc.JndiDataSourceAutoConfiguration$$EnhancerBySpringCGLIB$$9509801a.CGLIB$dataSource$0() ~ ........
My POM.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
</dependencies>
The point is that when you try to compile by using maven, maven tries to execute also Junit tests; in your case you have in src/resources/java some unit tests and so maven tries to execute them. Since you are using a JNDI datasource, it means that also the servlet container must be active for executing tests otherwise you can't get connection.
In this case when maven tries to execute tests maybe no servlet container (and, so, no JNDI datasource) is active and your test throws error.
To solve this (and to compile the maven artifact) you must:
or exclude tests execution: this is done by adding <maven.test.skip>true</maven.test.skip> in pom.xml. No test will be executed
or ignore tests error this is done by adding <maven.test.failure.ignore>true</maven.test.failure.ignore> in pom.xml. In this case tests will be executed but any test error will not stop maven compilation
The configuration I gave not only tells maven to not execute tests but it tells maven to not stop on any test error
I hope i have been clearer... my english is not the best

Master project - Maven dependencies in Intellij

I'm currently working with Intellij as IDE, and I have 4 projects:
- An Admin project (contains java & ember for the front-end)
- An WS project (contains the WS)
- An API project (contains the objects, dao's etc)
- A master project which only contains a pom to reference the other 3.
Admin and WS depend on API.
I deploy everything in JBoss. Maven clean-install works, but I can't deploy to jboss: I get a ClassNotFoundError: WS can't find classes in API
My pom of the master file looks like this:
<dependencies>
<dependency>
<groupId>API</groupId>
<artifactId>API</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:/.../api/target/API-1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>WS</groupId>
<artifactId>WS</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:/.../ws/www/target/WS-1.0.war</systemPath>
</dependency>
<dependency>
<groupId>Admin</groupId>
<artifactId>Admin</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:/.../admin/www/target/Admin-1.0.war</systemPath>
</dependency>
</dependencies>
I use Maven 3.3.3 and Jboss WildFly 8.2.1
In Project Settings I've simply put the 3 Maven libraries (Admin, WS, API) under
In the Deployement tab of the Jboss condfiguration, the 2 wars (Admin, WS) and the jar (API) are listed
The errors I get:
Failed to define class ...ws.endpoints.helpers.WS in Module "deployment.WS-1.0.war:main" from Service Module Loader: java.lang.LinkageError: Failed to link .../ws/endpoints/helpers/WS (Module "deployment.WS-1.0.war:main" from Service Module Loader) Caused by: java.lang.NoClassDefFoundError: .../dao/helpers/Dao Caused by: java.lang.ClassNotFoundException: ...dao.helpers.Dao from [Module "deployment.WS-1.0.war:main" from Service Module Loader]
What am I doing wrong? Is there a better way to deploy all this?
I've also tried to use the local Maven repository to find the correct depedencies (removed the scope and system path), but I can't find them, although they are correct located under the C:\users.m2 directory
Thanks in advance!
Specifying scope as 'system' means that your artifact is always available and is not looked up in a repository, so if you are building those artifacts during your build life cycle - "system" scope is not the right way to go.
I would recommend:
1. Try packaging your artifacts and deploy to JBoss manually, just to make sure that it works
2. Then try it out with Maven plugin for JBoss: http://docs.jboss.org/jbossas/7/plugins/maven/latest/examples/deployment-example.html

Maven Dependency Project Not Found While Deploy to Glassfish 4

I have a project IIFS-ejb (EJB project) and IIFS-common (jar file)
<dependency>
<groupId>com.islandfurniture</groupId>
<artifactId>IIFS-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
I define the dependency as shown above
However, receive an error saying when i try to deploy the ejb project together with iifs-common to glassfish 4.0. The iifs-common project can be deployed while the ejb failed with the following error
severe: java.lang.NoClassDefFoundError: iifs/common/exceptions/UserRoleNotFoundException
Please help thank you

Categories

Resources