Java EE Application porting - Oracle 10g AS to Oracle 11g Weblogic server - weblogic11g

I am porting a Java EE application from Oracle 10g Application Server to Oracle 11g Weblogic Server.
I have a common.jar which contains Connection related classes and present inside war/web-inf/lib. The application is deployed as an EAR and the ejbs also refer to classes inside the common.jar to get DB Connection. The EJB is not able to get reference to these classes at runtime. I copied the common.jar inside APP-INF/lib directory, In that case what happens is the JSP’s are unable to get reference to the Connection related classes. I have jsp’s which has sql code embedded in it. This application was developed way back and do not have the business knowledge change these code now.
How can I solve this issue? How the ejb can get reference to the classes located inside war/web-inf/lib.

You cannot have the EJB look into the WAR WEB-INF/lib for classes. That goes against the Classloader Hierarchy for Weblogic.
Putting the common jar in the APP-INF/lib is the correct way to go
WebLogic Server provides a location within an EAR file where you can
store shared utility classes. Place utility JAR files in the
APP-INF/lib directory and individual classes in the APP-INF/classes
directory. (Do not place JAR files in the /classes directory or
classes in the /lib directory.) These classes are loaded into the root
classloader for the application.
Can you also post the errors JSPs get when they are unable to load these? Are these ClassNotFoundException or NoClassDefFoundError or something else ?
Also see the Best practices for using Shared Java EE Libraries

Related

How to create and get started with Embedded Apache Derby database in Dropwizard project (Angular 7 front-end)

I'm reading through Derby documentation and following all the instructions. I've successfully installed it (extracted it to my Linux machine and set the DERBY_HOME path). I have a complete REST API project with Angular 7 front-end and Dropwizard backend. I hard coded some data in the backend, and created all the HTTP API methods I need (GET, POST, PATCH, DELETE).
The application is fully functional, but now I need to implement the Embedded version of Derby into it. I have 0 experience with such databases, and because Dropwizard gave me enough trouble already, I cannot figure out how to get started.
Do I create a new class and get started there, how to create those SQL files and how to store data? I can't find a concrete answer to similar questions, if there are detailed explanations and examples already out there, please feel free to provide me with the resources. I know this is a noob question, but I just barely learned how HTTP works (the basics) and managed to completely create a functional REST using Angular and Dropwizard.
Consider the embedded database like a full-fledged database, that instead of being in a different environment, and maybe requiring a network connection, is packed along with your application and run in the same JVM. The same mechanisms applies between the two.
The embedded Derby Driver is located inside the derby.jar file, so it is required to have it in the classpath of your application. It should be located under %DERBY_INSTALL%\lib\, where %DERBY_INSTALL% is the installation directory. You can see by the image where it is contained.
From Oracle
Any JDBC 4.0 drivers that are found in your class path are
automatically loaded. (However, you must manually load any drivers
prior to JDBC 4.0 with the method Class.forName.)
What that means is that if the Derby driver is a JDBC 4.0 driver, you don't have to do anything else besided getting a connection via DriverManager.
If it is not a JDBC 4.0 driver, you'll have to instantiate the Driver with
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Appartently you'll need that piece of code above.
Now simply get a hold on a Connection object.
DriverManager.getConnection("jdbc:derby:dbName;create=true");
From there on, you can create Statement(s) as you like. Which means you can create tables, insert rows, update rows, delete rows, etc.
To gracefully shutdown the embedded Derby database, you need to use
DriverManager.getConnection("jdbc:derby:dbName;shutdown=true"); // see the same database name "dbName"
prior to quitting the main application. It is not mandatory, but recommended.
You can create a utility class to hold an EmbeddedDataSource (docs), which will provide connections around your application.
public final class EmbeddedDerby {
private static final DataSource DATA_SOURCE;
static {
// Initialize DATA_SOURCE with EmbeddedDataSource
}
...
public static Connection getConnection() {
return DATA_SOURCE.getConnection();
}
}

Getting IIS Folder physical path inside a Windows Forms Application

This question is strictly related with Windows Forms as my task is to do this inside a SAP Business one addon using C#. My requirement is to alter some configuration values stored in a Web.Config file of a related wcf service hosted in IIS. I need to get the IIS folder path (even the default path could be like "C:\inetpub\wwwroot", looking for a way to get it without hard-coding it) inside the SAP B1 form (Think as inside of a Windows Forms).
I've tried out the suggestion posted in the Getting IIS Application filesystem path thread.
string apPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
Even if I added the System.Web reference to the project it gives me a null value, and I cant add the System.Web reference specifically to address this issue.
Also I've found Environment.SpecialFolder enum usage on MSDN but even it doesn't list IIS physical folder.
Environment.GetFolderPath(Environment.SpecialFolder.System))
Can someone suggest a workaround for this scenario? Even getting this value from the system registry would be ok.
You are trying to access the web application configuration information from IIS. That means you will need a library such as Microsoft.Web.Administration from Microsoft (part of IIS),
https://www.iis.net/learn/manage/scripting/how-to-use-microsoftwebadministration
or its open source equivalent from Jexus Manager,
https://www.nuget.org/packages/Microsoft.Web.Administration.Jexus

oracle driver for java web application

Is it okay to place an oracle driver jar within the web application's /lib directory, or is it better practice to place it in tomcat's lib directory?
I'm wondering about this because on my local host, my web app runs fine with the jar in the web app's /lib directory, but when I move the web app to a real development server, I continue to receive null pointer exceptions when trying to close a connection pool object. I thought this issue may be why I'm unable to free the connection.
Thanks.
To answer the initial question, about placement of the .jar file, there are some things to consider:
Are there other apps on the same server that use this? If yes, and you want to ensure all of them use the same version, the placing on the server/lib folder would be better
If you want some flexibility in terms of what version of the .jar each app uses, then webapp/lib is better
If you are packaging your app as an ear or war, and there are size considerations, then the server/lib option has some advantages, given it makes sense considering the two points above.
If you run into classloader issues from dependencies, you may have to consider other jars when deciding on placement.
Whatever you decide, its best to make sure each jar exists only once in each apps classpath.

Installation Error in DotNetNuke

I am new in dotnetNuke. I am trying to install DotNetNuke_Community_05.06.02_Source.zip file.Firstle i extract it to C:\DotNetNuke. There is a release.config file created in C:\DotNetNuke\WebSite\ . Renamed it as we.config. There is another we.config file in C:\DotNetNuke\DotNetNuke_Community_05.06.02_Source\Modules\RazorHost\ renamed it to web1.config. I configured it in IIS6.0 .Created a Database in SQLServer2005 named -DotNetNuke.Changed the connection string as directed by the installation guide. When i am trying to open the installtion wizard through browser it shows an error
Server Error in '/' Application.
Configuration Error
Description: An error occurred during
the processing of a configuration file
required to service this request.
Please review the specific error
details below and modify your
configuration file appropriately.
Parser Error Message: It is an error
to use a section registered as
allowDefinition='MachineToApplication'
beyond application level. This error
can be caused by a virtual directory
not being configured as an application
in IIS.
Source Error:
Line 56: Line 57:
Line 58:
validationKey="F9D1A2D3E1D3E2F7B3D9F90FF3965ABDAC304902"
Line 60:
decryptionKey="F9D1A2D3E1D3E2F7B3D9F90FF3965ABDAC304902F8D923AC"
In order to use the source package you must compile the code in release mode before attempting to access the website.
Being new to DNN, I recommend starting with the install package which will not need compiled, or even easier, you can get DNN through the Microsoft Web Platform Installer. WPI will also take care of all the dependnacies that may need configured on your computer.
I'ld like to clarify the intention behind downloading the Source Package. Were you intending to start developing and changing the dotnetnuke framework to suit your needs or did you want to set up a website that you could build modules against on IIS?
If you're intending to develop modules, I'ld suggest downloading the Install Package, creating an IIS site under Default Web Site.
- There's no need to change connection strings if you're using the database file that's in the App_Data folder.
- All you need to do is set the Folder Permissions for Network Service or IIS_IUSRS based on what application pool you're running.
- The url to the site will be http://localhost/xxx.
There are 2 ways to build modules in DNN. The Website Project and the Web Application are two different ways. They produce source code and dll's respectively. If it's internal, any way's good. If it's external facing, you might want a little bit more speed, so go Web Application.
However, If you're intending to muck around with the DNN Core Framework and adjust things, the Source is the way to go. there's no need to adjust the settings, just open the website project up in Visual Studio and away you go.

What's the benefit of deploying a war file instead of an exploded directory?

I'm configuring an installer for our product which, up until now, was distributed as a war file, usually on tomcat. Once tomcat has exploded the directory, the user has to open a properties file and set their database connection information. I'd like the installer to do this (we're using install4j) but there doesn't seem to be a built-in way to modify a text file inside a war file. I could just have the installer deploy the app as an exploded directory, which would save me the trouble here, but what do I lose by deploying like that instead of deploying the war?
It might work better to set up the database connection as a JNDI Datasource, rather than hand-editing a properties file inside the webapp/ directory. This is especially important if you want to allow users to re-deploy the application from the .WAR archive without overwriting their local configuration changes.
Of course, the JNDI setup isn't going to be trivially accomplished through the installer, either, since the mechanism used varies from app server to app server. However, any competent Java application server administrator should know how to configure a named datasource. Furthermore, by delegating responsibility to the app server, you allow your users to take advantage of connection pooling, clustering, and any other features provided by the datasource implementation bundled with their application server of choice.
Not much I would think - perhaps a bit of disk space, but if that's not a problem you'd be fine. Have you thought of having the installer generate the properties file and using a ZIP library (.WAR is really a .ZIP - rename it to a .ZIP and see what you get :) ) to replace or add it in?

Resources