I'm working with Maven and WebLogic. When building my application with Maven, I can successfully install it manually on my local Weblogic, using the Admin Console.
When trying to deploy this same application on the server using Eclipse IDE, I get a NoClassDefFoundError. (I tried both with "Publish as virtual application" and "Publish as an exploded archive" in the Oracle Weblogic Server tools in Eclipse).
The structure of my application is the following:
MyApp.ear contains:
- MyWar1.war
- MyWar2.war
- MyEjb.jar (ejb module, using maven-ejb-plugin)
- MyJar.jar (another project, as dependency)
And it's this MyJar.jar that seems to be not found in the classpath. I've checked that in the Eclipse settings, this project is include in the Java Build Path\Project, Java Build Path/Order and Export and in the Deployment Assembly for the MyEjb project.
I've also checked the folder build by Eclipse, eclipse-workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\MyApp, where I can see the folder APP-INF\lib\MyJar.jar with the corresponding .class files. And when I try to manually manually install this folder, I got the same error (NoClassDefFoundError).
I'm using Weblogic 10.3.3, Maven 3.2.1, Eclipse 4.4.0 (20140612-0600) and Oracle WebLogic Server Tools 7.2.1.201407111426.
Any ideas how I can investigate this problem ?
Moving the dependencies from APP-INF/lib/ to lib/ folder seems to fix the problem, but I have no idea why.
Related
I've inherited a Spring web app. It's a gradle web app project that I've imported into Eclipse. We're using Eclipse 4.7.3, Tomcat 7.0.47 and JDK 1.8.0.151.
The problem is that when I deploy the project to Tomcat from Eclipse, some of the dependency jars are not copied to the project lib directory. When TC tries to start the web app, there are ClassNotFoundException errors.
I'm new to Java web apps, so what I need is some tips for verifying my project import/build/deploy.
Here's what I've done so far:
Install Tomcat 7.0.47 (don't start it after install) Install Eclipse
4.7.3 JavaEE flavor (which comes with Buildship Gradle integration 2.0 installed)
Import my project as a Gradle project (File -> Import -> Gradle ->
Existing Gradle Project). I point at the project root, choose the
web project for deployment, and use the default settings.
Add a server to the project (from Server view click Add -> choose
Tomcat 7.0 -> point to TC root)
Right click the web target and select Run As -> Run As Server and
choose the TC 7 server I added.
At this point the project builds and deploys. The console shows the TC log. TC starts but the shows an error when it attempts to start the web app (for example):
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
I could copy jars but it's my impression Gradle should be grabbing the dependency jars during deployment. I can verify that some are copied, but others are missing. How can I debug this issue?
Here's part of my build.gradle file
buildscript {
repositories {
maven {
url projectDownloadUrl
}
}
dependencies {
classpath lib_license_gradle_plugin
}
}
The web app is deployed to ...eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0. The lib directory here contains some of the deployed dependency jars. The gradle.properties file contains a list of dependencies, for example
lib_apache_tomee=org.apache.openejb:apache-tomee:1.7.1
This is apparently not the place to ask and answer Gradle/Tomcat questions. I figured out the issue shortly after posting, and not wanting to disappoint the 40 people who've come here for help since then, thought I should finally answer my own question.
First, I was on the right track on how to debug deployment of a gradle/maven app in Eclipse. After it deploys you can check which jars are in the deployment directory. Eclipse deploys locally to a place similar to c:\users\\eclipse-workspace.metadata.plugins\org.eclipse.wst.server.core.
Second, the immediate problem I was having was due to using Tomcat instead of Tomcat EE. The answer to this was right in the question:
lib_apache_tomee=org.apache.openejb:apache-tomee:1.7.1
Tomee is Tomcat + Java Enterprise Edition, which includes some extra logging and other jars, the ones I was missing.
I have read every page that shows up on the first Google result page with that search. But nothing seems to help.
Of course I can run "mvn clean install" in or out of Eclipse and get the .war generated in the target folder. I can copy the .war in the deployments folder of JBoss installation myself. And then I can start the server through the server adapter in Eclipse.
But I want that "manual copy of war" to be automatic as well.
How can I do this? What do I need to do to add a new item to "Run As" menu, say, "Maven JBoss Deploy" where underneath, it does a clean, install, deploy (copy to deployments)?
I have Maven 3.1.1 installed separately (outside of Eclipse) and I have told Eclipse where my Maven is. I have JBoss Tools (latest version) installed with JBoss Maven Integration part of it.
I just don't see any way to integrate JBoss and Maven within Eclipse :(
You can do with fileName tag
<fileName>${basedir}/target/webapp.war</fileName> in pom.xml
or
You can go with Profiles in pom.xml
More 1
More 2
By trial and error, I was able to get Eclipse to deploy a maven project WAR on JBoss.
I just needed to have "Dynamic Web Module" facet attached to the project. I did that using the Project properties in eclipse.
Now I am able to right click the project and Run As Server and that deploys to JBoss. And the project is still a Maven project. Yay!
I've build a spring-based web project in Eclipse using Maven. Dependencies and class path are correct and the deployment assembly also lists spring-web*.jar correctly. However, when I deploy it using WebSphere 8 from within Eclipse the mentioned JAR file is missing from the created libs folder under .metadata.plugins\org.eclipse.wst.server.core\tmp2*\WEB-INF\lib . This JAR however is listed under the module section as a submodule for the container. I wasn't able to find out, why this JAR is listed there and why it is not copied to the LIB folder.
It works with a Tomcat server, it works when I export the WAR and deploy it manually and it also works when I manually copy the JAR to the lib folder.
Q1: Is this specific to Websphere?
Q2: Why is SPRING-WEB listed as submodule and what effect has this?
Q3: How can I automatically deploy it correctly?
This seems to be a bug in WAS as reported here
You can either copy the missing JARs manually or you can use the "Run server with resources on server" option in the "Publishing settings for WebSphere Application Server" server settings.
I have a web application(Myapp) configured in eclipse.
So in order to Deploy it in Websphere v5.1 I have to export it to EAR.
Scenario 1: In eclipse--> new --> Enterprise Application Project
-->Named as MyappEAR--> Selected Existing Module(Myapp)--> Finish. Now I got MyappEAR in Project Explorer. Right click on MyappEAR export to
EAR. Done. Got MyappEAR.ear file with Myapp.war inside it.(Includes
META-INF and xml)
Deployed MyappEAR.ear in Websphere, Deployed Successfully. But when i
tried to start MyappEAR it ends up with this error SRVE0054E: An error
occurred while loading Web application (No more information found).
Scenario 2: Eclipse--> right click on Myapp export to war--> Got
Myapp.war--> Deleted existing myapp from Project explorer.
File-->Import-->WAR--> enabled Add project to an EAR and named it as
MyappEAR-->finish Right click on MyappEAR-->export to EAR. Done . Got
MyappEAR.ear with same stuff as above.
Deloplyed and Started working fine.
Now my question is What's the difference in both ways causing that error? (even checked with beyond compare, everything is same).
Websphere app server v5.1,
Java 1.4,
Eclipse Indigo.
We have a Maven project and it builds the EAR after we run mvn clean install.Then I take EAR from target folder and deploy it in server.
In local setup,Just add the project in server and start the server.Normally it works.
When i make the war i see the XCV.Jar, but I add the project on Tomcat (IDE eclipse), and when I deploy it, I have all jars except XCV.Jar (This jar is the parent of the project I deployed).
When you deploy to Tomcat from Eclipse it often fails to clean up the work directory directory. Try to clean $TOMCAT_HOME/work/Catalina// and the web apps directory then try redeploying.
If you are running tomcat inside eclipse you're asking for trouble. Its often better to build and validate the .war independently(with ant or maven) then deploy manually or with a script.