I'm facing an issue. On testing a java code with external jar dependency separately, it is working. But when trying to deploy OSB code with java callout calling the same java code, it is throwing method does not exist.
There are multiple ways to resolve this issue.
you can create a fat jar(it will contain all class files, Tools are available online or can use Eclipse or any ide to export the code.) for your Java code along with Dependencies and libraries.
You can deploy your dependencies as libraries/Application or copy Weblogic lib folder it depends on your dependency type. after deployment, you must restart the domain. Then u can deploy import your java callout Jar/Archive in OSB.
Related
I'm using the Java library for the Google Maps API but cannot find the code at runtime. I've added the repository and dependencies to build.gradle as detailed in the readme. Everything compiles fine, the import statement autocompletes, I can open the source code in Eclipse through "View Declaration," and I can see Google Maps in the Java build path.
import com.google.maps.GeoApiContext;
// Throws exception!
GeoApiContext.Builder builder = new GeoApiContext.Builder();
Why is this library visible at compile time but not runtime?
ETA: The application is packaged as an EAR file and deployed to a web server.
With the scarse details you provided, my guess is that you built a jar file and then ran java -jar myApplication.jar.
The default jar file only contains the classes of you own application, and not its dependencies. If you want to make an executable jar, you have several options. Some of the more popular are:
Use the shadow plugin, which will repackage the jar to make it "fat" with all its dependencies.
Use the standard distribution plugin that will create a zip (or tar) of your project and its dependencies. It will also a script for setting the classpath correctly.
I want to migrate running java application to Jdev12c. Can i use all the jar used in Eclipse as it is. I have eclipse related jars also i.e.
org.apache.commons.logging-1.0.4.v201101211617.jar
org.eclipse.persistence.core-2.5.0-RC2.jar
org.eclipse.persistence.jpa-2.5.0.jar
org.eclipse.persistence.oracle-2.5.0.jar
can i use these all jars in Jdev directly. and also apache logger file will work in Jdev or not. also do i need to change something in classes and code?
I have folders in the application and which have files. I am also using .property file. so can i directly use this all.
JDeveloper has ability to import code from WAR file or a Maven project (import menu under file menu).
Or you can just create project from existing code.
You'll need to point to the jars in the project properties->libraries and class path
BackGround:
I am using Eclipse Lunar along with the Google App Engine plugin to try and build a website. Everything was going well until I wanted to save some data so I followed the tutorial on using Objectify. I downloaded the Objectify jar and placed it in "/war/WEB-INF/lib/" and then added it to the classpath. I then made a ObyHelper.java class as instructed in the tutorial and made a couple of my own test classes (which for now you can assume to contain no errors). I can successfully deploy too.
The question
When attempting to load the jsp page that uses Objectify (or any servlet/jsp url for that matter) I get the following error:
Uncaught exception from servlet
java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.objectify.ObjectifyService
What did I do wrong and how should I have added the Objectify jar to the class path?
In order to get the jars to work in the GAE plugin for eclipse project structure you need to
1) place the jar on the WEB-INF/lib folder (in order for them to be deployed to the cloud)
2) add those jars to the classpath manually in order for eclipse to recognize them on you local dev environment.
Have you read the Setup documentation?
https://github.com/objectify/objectify/wiki/Setup
You need the guava jar as well. But really you should use Maven (or Ivy, or Gradle); manually copying jars is very old skool.
I have a pretty basic Java web application (created using Eclipse openshift plugin). The app runs fine on the OpenShift server. Now I need to use an external JAR library for JSON parsing and creation in Java. I can't understand my way around how to add that JAR to openshift server.
I went to project properties>>BuildPath>>Add external JAR. While that does import the JAR, it does not work on openshift server and gives error relating to that file's import (NoClassDefFound, I guess). Could you tell me how to import external jars into openshift project?
Since we use Maven for the build process, all you have to do is add it as a dependency in your pom.xml
Here is an example that adds a mongo driver
https://github.com/thesteve0/openshift-mongo-spatial-jee6/blob/master/pom.xml
Look under the dependencies tag
You can add the jar as a dependency in your pom.xml file. This will cause the jar to be included in your war. If the jar is not available in a public maven repo, please see here: http://www.billdecoste.net/?p=16
[Updates in 2017]
You might want to take a look at this link from OpenShift itself.
It includes information about adding jars with and without maven dependencies.
with a grails project, do you put java code inside the same project or do you have to somehow import the java libraries you created from another java project?
I put any java source in the src/java directory and it gets automatically compiled when I run the app. When I have jar files with out associated code such as third party libraries or librarys from another group in the company I just drop them in the lib directory and grails automatically allows you to use them.
Both alternatives you mention work fine. IIRC, Grails even automatically creates a "java" source folder for your Java classes.
In addition, if you use Maven for the Java project, you can set pom=true in the BuildConfig.groovy file and create a dependency on the original JAR; it will get pulled in with each build.