NotSerializableException With Basic DataSource In JNDI
May 29, 2014
I am setting up a standalone JNDI and loading a Datasource to the JNDI. DataSource I use is:
org.apache.commons.dbcp.BasicDataSource
The JNDI is set up as follows
String detectorHost = InetAddress.getLocalHost().getHostName();
System.out.println("detectorHost: " + detectorHost);
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
final NamingBeanImpl namingInfo = new NamingBeanImpl(); namingInfo.start();
[Code] ....
I get the following exception
javax.naming.CommunicationException [Root exception is java.io.NotSerializableException: org.apache.commons.dbcp.BasicDataSource] at org.jnp.interfaces.NamingContext.bind(NamingContext.java:677) at org.jnp.interfaces.NamingContext.bind(NamingContext.java:611) at javax.naming.InitialContext.bind(Unknown Source) at com.lombardrisk.reform.integration.ReformIntegration.createJNDIServer(ReformIntegration.java:93)
[Code] ....
I don't quite follow why I am getting a NotSerializableException exception, this is a local JNDI in the same JVM and not a remote JNDI. Not sure why this occurs.
View Replies
ADVERTISEMENT
Sep 10, 2014
I need to inject a DataSource, but the catch is the JNDI isn't known until Runtime. I was hoping the EJB could get a System Property of the JNDI name and use that to Inject the DataSource.
For example:
@Resource(name=myRuntimeJNDIName)
DataSource myDataSource;
And I could either @Inject or on postContstruct() set the myRuntimeJNDI variable to the JNDI name that is configured on the App Server via System Properties or some other mechanism. But the JNDI may be different depending on what environment the application is deployed to.
Is this possible? I would like to have the same EAR deployed in all our environments and not have to create a different version of the application for each environment.
View Replies
View Related
Apr 20, 2015
I am new to java. I have recently learned JDBC connection pool in tomcat. To make code reuse I want to share the connection among all servlets without any conflict.
Here My code snippet:
public class GetConnection{
private DataSource ds;
public Connection getConnection(){
try {
InitialContext initialContext = new InitialContext();
Context context = (Context) initialContext.lookup("java:comp/env");
ds = (DataSource) context.lookup("connpool");
[Code] .....
Is this right way to do. Or I will get any problem due to concurrent threads.
View Replies
View Related
Nov 26, 2014
I'm not able to access my bean class (not an EJB) using a given JNDI name in JBoss 5.0.1, where the same is working in Tommcat 7.0.
META-INF/context.xml
<Context>
<Resource name="test/TestDAO" auth="Container"
type="ws.jndi.MyBeanDAO"
factory="org.apache.naming.factory.BeanFactory"/>
[code]....
View Replies
View Related
Aug 5, 2014
jboss 7.1.1
EJB 2.1
Though it may seem strange but in one of the application i work on still uses EJB 2.1 entity beans.While looking at the deployment log, seems like each Entity bean is registered using both remote-home and remote interfaces.
java:app/EJBApp/Entity!com.abc.remote.Remote
java:app/EJBApp/Entity!com.abc.remote.RemoteHome
Using the remote-home's JNDI lookup i was able to get the EJBObject proxy and subsequently create and use the entity.But what about the remote interface JNDI lookup ? Reason i am asking is that one needs to create an entity before use it. That said, how to use the object that i get from remote interface JNDI lookup ? Note that the class of the returned object says its "com.sun.proxy.$Proxy13" type.The JNDI location i am using "java:app/EJBApp/Entity!com.abc.remote.Remote"
View Replies
View Related
Feb 24, 2014
There is a weblogic server running at remote place and i need to access the API's in that remote method using JNDI lookup. My application is configured in Spring Tool Suite IDE with java 6 and tomcat 7 and I have used Spring to perform the jndi lookup of weblogic server. In spring i have used simpleremotestatelesssessionproxyfactorybean class to lookup a weblogic server using jndi and get the remote object. But somehow on doing it i'm getting the following error.
org.omg.CORBA.COMM_FAILURE: vmcid: SUN minor code: 203 completed: Maybe
at com.sun.corba.se.impl.logging.ORBUtilSystemException.writeErrorSend(Unknown Source)
at com.sun.corba.se.impl.logging.ORBUtilSystemException.writeErrorSend(Unknown Source)
at com.sun.corba.se.impl.transport.SocketOrChannelConnectionImpl.sendWithoutLock(Unknown Source)
at com.sun.corba.se.impl.encoding.BufferManagerWriteStream.sendFragment(Unknown Source)
[Code] ....
The exception is been thrown at com.sun.corba.se.impl.encoding.CDROutputObject method when calling writeTo(). Why I'm getting this error and can I do anything to remediate it. Irrespective of java this error occurs, i tried with java 5, 6 and 7 but still getting the same error.
View Replies
View Related
Jul 2, 2014
my task is to add a few functions to an example calculator. I managed to add a divide button but I simply can't figure out how to add a working Pi and reciprocal function.
package newjavaproject;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class CalculateurNC extends Applet {
[code]....
View Replies
View Related
Oct 20, 2014
Why I am getting errors for this program I (tried) to write. I am new to java.
import java.util.Scanner;
public class TheBarkingLot {
public static void main(String args[]) {
int n;
Scanner input = new Scanner(System.in);
System.out.println("How many large dogs are boarding today?");
[Code] ....
View Replies
View Related
Jan 24, 2015
im considered quite the "javanoob" as my account name states..The assignment is to basically take a number that is entered by a user, and based off what they type in, display a corresponding grade letter. For example, if they enter a number between 90-100, they should receive a response that they received an "A". Now, this is fairly simple using an if/else statement, but my professor wanted us to implement this, using a switch case to teach us the difference.
import java.util.*;
public class SwitchTest
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Please enter a number to find out what letter grade you have recieved");
[code]...
View Replies
View Related
Mar 30, 2015
I moved some static html pages I was hosting from apache into tomcat. (no point in running two servers) This works as expected, but I'm having trouble with the authentication part. In apache the authentication was handled by htaccess. I tried various tutorials on the web about configuring basic authentication in tomcat using WEB-INF/web.xml in tomcat, but I'm not sure this approach applies to static html pages. Using basic authentication for static html in tomcat?
View Replies
View Related
May 9, 2015
My code is supposed to give the array index on the left and what is inside the array on the right, but i get nothing except the header? I am using eclipse.
public class Options{
public static void main(String args[]) {
System.out.println("Index Value");
int value[] = {1,2,3,4,5};
for(int add = 0 ; add <value.length ; add++) {
System.out.println(add + " " + value[add]);
}
}
}
View Replies
View Related
Dec 10, 2014
What's wrong with the code.
public class alltheprime {
public static void main(int a) {
int i, j, k, l, m;
m=a;
k=0;
for(i=2;m>1;i++) {
for(l=2; l<i;) {
l=l+1;
[Code] ......
View Replies
View Related
Jan 27, 2015
I am new to the java computer programming world. i am having basic trouble making the statement full and complete. i am trying to get it to say "The speed of the car is <answer> ft/sec" i have tried reading in the my programming book from school but it doesn't tell me how to fix it. the errors I am getting :
cannot find symbol
I have this error twice ....
View Replies
View Related
Oct 25, 2014
I am new to programming so for loops are a little confusing to me still but basically what I am doing is making a small java rpg game and I want to add in a time element to it so your character gets things like promotions and such after a certain amount of time playing.
for (int x = months; x < 12; years++) {
for (int y = weeks; y < 4; months++) {
for (int z = days; z < 7; weeks++) {
for (int j = hours; j < 24; days++) {
for (int k = minutes; k < 60; hours++) {
}
}
}
}
}
That's what I have so far but I am getting a logical error/ infinite loop when I run. I have added each unit of time as a static variable so there's no problem there.
View Replies
View Related
Aug 18, 2014
how I would go about having a moving sprite on a page, such as a virtual pet kind of thing. I've tried searching for it through the years and I've tried it with what I know on my own, but things just act up every time. Either:
A.) The sprite moves (respondent to key strokes, of course), but leaves a trail of its image behind itself.
B.) The background image writes, but for some reason the second image does not write, or is lost behind the background.
I'm sure these are simple issues for most of you, but I've tried going about this for a while now with no luck. What I'm trying to do I'm trying to write a virtual pet game, and I would eventually love to make it move around randomly like an A.I. that's pathfinding, but I've got ideas about that, just I need to know how to make it move period first, everything else I think I could figure out on my own.
View Replies
View Related
Oct 22, 2014
Here is the outline of what the program should do: [URL] .....
So far I've got the very basics in place, I can't really figure out ptplot despite trying to research it online. The only other thing I know is that arrays are not to be used (initially I intended on using them). Here's my code:
//The next line imports the java.io package
import java.io.*;
//Imports math language
import java.lang.Math;
//import ptolemy.plot.*;
//Sets up class
public class cp5 {
//Declares class method called 'main'.
Code] ....
View Replies
View Related
Nov 30, 2014
I am currently working on a application for a car park system. It uses GUI created by myself and holds 15 parking spaces. The user has the option to add, delete or search for a specific car. When the user adds a new car, details of the car are entered, the cars registration number (saved as a string), and the user had to check one raido button if the car is expensive, large or normal.
Once this information is entered a new instance of a vehicle will be created and the bay the car is allocated to turns green and stored in one of three arrays(expensive, normal or large). I also have a fourth array for creating the parking spaces.Each array can only hold 5 vehicles apart from the fourth which can hold all 15. When searching for a vehicle the user enters the registration of the vehicle they want to find, but I have to search through all three arrays to find it, and if it does not exist showing a message saying so.These are my three arrays
public static ParkingBay[] regularBays = new ParkingBay[5];
public static ParkingBay[] largeBays = new ParkingBay[5];
public static ParkingBay[] expensiveBays = new ParkingBay[5];
String Registration; - saves registration entered from add form
String RegistrationNumber; - saves registration number from search form
I need to search to see if RegistrationNumber is in either of the three arrays if not show a message saying otherwise
View Replies
View Related
Jul 8, 2014
I want a simple jsp page that performs basic operations on numbers such as addition, subtraction, multiplication, division and modulus . How to run that file?
View Replies
View Related
Jun 25, 2014
I think its a standard concept but just not getting it. I have 3 classes:
1) Base class
2) Derived class, which extends base
3) TestClass
public class Base {
public void display() {
System.out.println("Display method in Base");
}
}
class Derived extends Base {
public void display() {
System.out.println("display method in Derived");
[Code] .....
So if i run this, my results are:
Display method in Base
display method in Derived
display method in Derived
Thats cool, no problems there, but if i change my Display method in Base and Derived to static methods then the results become:
Display method in Base
display method in Derived
Display method in Base
So why oh why does obj3.display() now print "Display method in Base"?
(and yes I know the calls should be static calls, but for sake of arguments -- or is that the whole problem, that technically obj3.display() is an incorrect call as it can only be Base.display() or Derived.display() when display() is a static method ).
View Replies
View Related
Dec 29, 2014
public class BookExamples {
String title;
String genre;
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hey");
[code]...
Eclipse gives me an error for b1.genre = "hey"; saying "Syntax error on token "genre", VariableDeclaratorId expected after this token". I am learning from a HeadFirst Java book that is all in Java 5.0 version which may be part of the problem.
View Replies
View Related
Oct 12, 2014
You have to create a very basic hangman type of game. Open Notepad and create a list of at least ten words in a text file. Save the file as a .txt file and use it to read words for the game. In this game you do not have to show pictures but you do need to keep track of the amount of times that the user has guessed wrong. When the game starts, show the amount of characters in the word represented as dashes and ask the user to type in a letter. if the user guesses correctly show the word again with the correct letter filled in the correct positions(s) and if the user correctly guessed the word, show a message. If the user guesses wrong, keep track of the body parts that needs to be reduced with every wrong guess and inform the user as well, also show a message.
I'm struggling with reading the file, showing the amount of parts left and asking the user to play again. Here is the code:
package hangman;
/**
*
* @author
*/
import java.nio.*;
import java.io.*;
import java.util.*;
public class HangMan {
[code]...
View Replies
View Related
Aug 29, 2014
How many files does it take to make a very basic java page? Can it be just one file which is run off a hard drive?I want to connect to a SQL server and update records only
View Replies
View Related
Feb 27, 2014
Basic console java program. I need to generate an employee id. I have an employee class that I will paste here so you can see my fields and constructors.
public class Employee {
private String firstName;
private String lastName;
private int id;
public int nextUniqueId = 0;
public Scanner sc = new Scanner(System.in);
[Code] ....
View Replies
View Related
Jan 13, 2015
I started programming some time ago and i recently finished a game i've been programming in Java just to get used to the code. The game is a simple text-based RPG where almost everything is random except the character movement.
I've been thinking about learning HTML and CSS because i'm really interested in building webpages. I have no one to ask this question so here i am.
Is there a way to implement my game in a webpage?
I imagine a black window exactly like a classic OS terminal where the text is streamed and the user can play the game with keyboard inputs. I made the game with 5 different classes, i used Eclipse and i have my project there. Should i use a service like Github to share works like this one?
View Replies
View Related
Jan 27, 2012
I have to be able to read files that have been serialized in VB. 2 things, 1 they are serialized in Binary, and I tried to look up on how to serialize/deserialize in Binary, but didn't have much support...
Also in the VB code they talk about "TYPES" which seems to be to just be a class full of stuff...
View Replies
View Related
Oct 16, 2014
Having just started college, Bob has been busy looking for a part-time job to fund his new college social life and after only two weeks of looking he has managed to get two job offers! Each job comes with different hours, basic rates of pay and over-time rates so he needs to work out which would get him the most money.
Develop an application that would allow Bob to enter his basic pay rate, his number of regular hours work per week and his number of overtime hours per week. The application should then calculate and display Bobs total basic pay for the week, his overtime pay for the week and his total pay including overtime.
Your application should use instantiable classes to separate the calculations from the user input and output.
Save the instantiable class as Pay.java
Note: The overtime rate is 1.5 times the basic rate of pay
This is my instantiable class code which compiles correctly
public class Pay{
//Declare Data members/Variables
private double pay;
private double hours;
private double overtime;
private double totalBasicPay;
[Code] .....
My errors in the second bit of code that i have never seen before
"C:UsersAndreDownloadsPayApp.java:25: error: no suitable method found for println(<null>,String)
System.out.println(null,"Please enter Basic Pay");
^
method PrintStream.println() is not applicable
(actual and formal argument lists differ in length)
[Code] .....
View Replies
View Related