Maven - erroneous weblogic classpath - maven

On my Oracle weblogic 12 installation I have deployed an .ear (built with maven). All is OK except when I go to wls-cat and check Classloader Tree I get entries such as:
D:\Oracle\Middleware\Oracle_Home\user_projects\domains\liferayportal\servers\AdminServer\tmp\_WL_user\mywebapp\nsio4q\APP-INF\lib\lib\antlr-2.7.6.jar
and
D:\Oracle\Middleware\Oracle_Home\user_projects\domains\liferayportal\servers\AdminServer\tmp\_WL_user\mywebapp\5ohvco\war\WEB-INF\lib\..\..\lib\
I have no \lib\lib folder and neither do \lib...\...\lib
What can be the cause? What should I check in my POMs? Thank you.

This is not related to your pom.xml
WLS expands the war file, but copy the files in different places, therefor It doesn't recreate a directory structure (ie: OC4J does it).
Therefore, WLS-CAT is telling where (psychically) is retrieving a particular class (from antlr jar file in your case).

Related

Kafka Connector - Packacking jars

QUESTION
I am not a maven pro and I got stuck trying to package a Kafka Connector. There are two options for packaging it:
Either you produce a folder with a jar that contains the connector + all the dependency jars - all the kafka-specific jars
Or build a fat jar with all of the dependencies (and I also assume without the kafka-specific jars again, but it is not explicit in the docs).
I am following docs on confluent webpage and the connector I am trying to package is this one on github.
What I tried, after cloning the repo with git, is the following mvn clean package. But this seems to create only a single jar of the original project with the dependencies in mvn cache (~/.m2/repository/).
Google also has link on how to create a fat jar, but I would need somehow to specify which jars I want to exclude from the fat jar.
Thanks
UPDATE
Now I am running:
connect-standalone /etc/kafka/connect-standalone.properties /etc/kafka/connect-cdc-mssql-source.properties
Where /etc/kafka/connect-standalone.properties contains the following line:
plugin.path=/shared_win_files
And ls -al /shared_win_files contains the following:
kafka-connect-cdc-mssql-0.0.1-SNAPSHOT.jar
And jar tvf kafka-connect-cdc-mssql-0.0.1-SNAPSHOT.jar contains the following:
6996 Thu Sep 07 14:47:24 BST 2017 com/github/jcustenborder/kafka/connect/cdc/mssql/MsSqlSourceConnector.class
where MsSqlSourceConnector.classis basically this class here which implements the Connector.
But when I try to run the connector with the command above, I get an error
Failed to find any class that implements Connector and which name matches com.github.jcustenborder.kafka.connect.cdc.mssql.MsSqlSourceConnector
It gives a massive list with all available plugins, but mine is not in there.
Currently, an easy way to package your connector with maven is to use maven-assembly-plugin. This basically entails two main steps:
Define one or more assembly descriptors and save them under src/assembly.
Doc: http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html
Example: https://github.com/confluentinc/kafka-connect-elasticsearch/blob/master/src/assembly/package.xml
In the descriptor, among other things, you may choose the packaging format of your archive, files and directories to include or exclude, as well as specific settings regarding your projects dependencies.
Include the plugin in your project's pom.xml
Example: https://github.com/confluentinc/kafka-connect-elasticsearch/blob/master/pom.xml
This mainly requires you to define the configuration and execution sections of the maven-assembly-plugin section. Additionally you can associate calls to specific assembly plugin descriptors with certain maven profiles that you may define.
Finally, stay tuned because packaging your Kafka Connect plugins (connectors, transforms, converters) might be significantly simplified soon.
Following Konstantine's answer how to package jars.
The remaining problem was that when specifying plugin.path=/abc in KafkaConnect config, you have to be careful.
You can either put a fat jar like this:
/abc/fatjar.jar
Or you have to create another folder in abc and put all the related jars into that folder like this:
/abc/my-connector-a/connector.jar
/abc/my-connector-a/connector-dependency.jar
...
As in my case, it was treating jars as separate plugins.

Deploy a embedded Jetty&Jersey war to jetty9,only can see static file?

I cteate a jetty&jersey embedded project with IDEA and Maven,I put it in Github https://github.com/Mengqi777/JettyProject. Run JettyServerStart.java start the server, in the browser address bar enter localhost:8080/dynamic, show OK, enter localhost:8080/static, show static resource file
Now I package it to a war file,and put it in jetty webapps directory. But only can see static file in brower with enter localhost:8080/static.404 Not Found Error when in brower with enter localhost:8080/dynamic
What happend?
What should I do to package this project into a war file or jar file and run it in jetty successfully?
You are doing things in your embedded-jetty usage in JettyServerStart.java that you do not declare/configure in your webapp or war file.
It's a maven project, but not declared as a webapp or war project (in the pom.xml)
Its doesn't have its WEB-INF in the right place (maven directory structure wise), which means your built war file is invalid.
The dependencies are not declared correctly for a webapp or war project (you cannot include jetty-server in a war file)
Your badly located WEB-INF/web.xml does not perform the same configuration steps as your JettyServerStart.java
You don't specify how you created your ${jetty.base} directory to support this war file?
You didn't specify what version of jetty-distribution or jetty-home you downloaded, or are attempting to work with.
The statement "and put it in jetty webapps directory" is unclear, which one? (using jetty-distribution/webapps is invalid and will cause many errors and warnings if you attempt to use it for your own webapps, there's no jetty-home/webapps, and you didn't identify your jetty-base configuration)
The way your project is declared right now, even if manually assembled, skipping maven entirely, you have no servlets, no filters, no listeners, no intializers, only a servlet spec mandated DefaultServlet on url-pattern / giving you static content. That's why accessing http://localhost:8080/static/ works, but nothing else.

Websphere liberty profile 16.0.0.4 deployment issue (ZipException)

We are using Websphere liberty profile 16.0.0.4 to deploy EAR application.
Nothing jee specific. the EAR has a simple WAR file. We put the EAR file inside
the dropins folder and it seems like websphere is extracting the content of EAR
file inside the workarea directory.
When reading the content of one jar sqljdbc.jar it puts the jar inside cache
folder. However the sqljdbc.jar seems to be a 0 sized file.
Here is a sample path to the sqljdbc.jar. All of them are directories
D:\comdata\wlp\usr\servers\defaultServer\workarea\org.eclipse.osgi\121\data\cach
e\com.ibm.ws.app.manager_88\Tax2290.war\WEB-INF\lib\.cache\sqljdbc.jar
The sqljdbc.jar inside sqljdbc.jar folder above turns out to be 0 byte sized.
Because of this ZipException is thrown.
There is also this exception thrown before the ZipException. I am not sure if
it is related to this or not.
java.lang.ClassNotFoundException: iconnectlogout
com.ibm.ws.jaxrs20.server.component.JaxRsWebModuleInfoBuilder
What are these org.eclipse.osgi, cache, com.ibm.ws.app.manager_88 folders.
We checked the WAR file inside EAR and it has the right sized sqljdbc.jar.
any ideas why this is happening? Is anything getting downloaded from internet?
Proxy / firewall issues.
First Edit:
-----------
Uploaded the problematic ear file.
Here is link to problematic ear file
https://wetransfer.com/downloads/3585882e88626f6e5a480075fba0c48e20170118170610/43e43f
The sqljdbc.jar file in the Tax2290.war's WEB-INF/lib directory contains an embedded JAR file with the same name - and that embedded sqljdbc.jar file is 0 length - with another another file, sqljdbc.jar.old, that seems like a valid archive. It is this embedded JAR file that Liberty is choking on.
You should be able to resolve the problem by removing that 0 length JAR file from the sqljdbc.jar -- or by replacing it with a valid JAR.
That said, Liberty should probably provide a better error message or be able to handle this case better, so I would suggest opening a PMR with IBM support to have this addressed.
Thanks, Andy

jboss-as-maven-plugin: which directory does command "jboss-as:deploy" deploy an .ear to?

I am running jboss 7.1, maven 3, and a java ee6 application that generates an .ear
I am doing a mvn clean package jboss:as-deployand Jboss-as-maven-plugin 1.5 does its thing--I can view my app using http://localhost:8080...
just fine, but I want to know where the actual .ear is being put.
It is not in my jboss7.../standalone/deployments folder. So where is it? My app is obviously running in jboss 7.1 just fine, but I can't find the .ear file. I know that there is an .ear in Eclipse's 'target' directory, but that wasn't produced by jboss-as-maven-plugin is it? I hope you can understand my confusion--don't all .ear files need to be in the deployments directory? I also do see my .ear file inside my hidden .m2/repository directory, but does this have any interaction with jboss-as-maven-plugin? Maybe there is some hidden sym-linking between my Eclipse project's 'target' directory and the jboss7.1 standalone/deployment directory?
p.s. I am used to using a hard-deploy option with the other plugin jboss-maven that requires you to say jboss:hard-deploy which just copies the .ear to your deployments folder. Then jboss would pick up the new .ear and redeploy automatically. I get the sense that jboss-as-maven-plugin is the preferred plugin so that's why I am bothering.
The jboss-as-maven-plugin uses the deployment API so it doesn't copy the file to the deployments directory for the scanner to pick it up. It deploys just as if you deployed it from the web console or via CLI. The files should be located somewhere in the $JBOSS_HOME/standalone/data/ directory.
You're welcome to open an issue, for a discussion around it at least. I'm not sure how I feel about adding a goal for it, but here isn't the place to discuss that :)

How to add OSGi WAR bundle ine eclipse target platform

For my OSGi development i have setup a target definition (.target file) which references two directories. Eclipse picks up all the jar files inside these directories and adds them to the target platform. But one of the bundles i have is a WAR file (.war extension) which is run using pax-web. Eclipse doesn't show this in the list of bundles available. Is there any way to add a particular bundle directly into the target definition? Any way out that i might be missing?
One workaround i found was to rename the .war file to .jar. Pax-web doesn't care about the extension, eclipse picks it up and so everything runs fine. But i am not very convinced if this is the right solution.
Thanks.
Bug 355890 was fixed for 3.8/4.2. You can now include archive files that are not jars (i.e. WAR files).
There is a known bug filed on eclipse on this very issue. Until it is fixed, the only workaround is to rename the file to have the .jar extension.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=355890

Resources