how to fix Javax. Naming.exception: nameNotFoundException <my_JNDI_name> not found - glassfish

I got this exception while trying to deploy ejb-jar file on a glassfish 2.1 :
Javax. Naming.exception: nameNotFoundException not found.
This drive me to be crazy !!!
I don't know why i got this exception while when i launch the hole application (ear) using Netbeans 6.7.1 with integrated glassfish 2.1 it work like magic !
But when i try to deploy it manually under another glassfish in an other pc it does not work
And i am having this exception when i try to deploy it
So i think that the ejb module does not find out how to link to the database
So it must be something that the netbeans do and i am not, when deploying the ejb-jar
Any help ?

I realise this is a bit old, but having just worked through this, I thought I may as well document it here.
For me the issue was the database connection. In your project you should have a persistence.xml file (mine was in the EJB project), which details the database connection parameters. I was using a localhost URL, but when I ran the database project, I noticed in my Services tab under Glassfish that no database connection was being registered.
Here's what I did:
Create a new database connection (right click in Services, Java DB node)
In Services, right click Java DB connection, Properties, check that the pool it's registered to is in the Glassfish JDBC Connection Pools and is the correct one, if not, make sure your database connection is correct, update persistence.xml
Clean the project before running again
This worked for me, hope it's helpful for someone else.

Related

EJB Timer Service is not available, undeployment failed for context

I have the following code:
package ejbs;
import javax.annotation.Resource;
import javax.ejb.Singleton;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerConfig;
import javax.ejb.TimerService;
#Singleton
public class timerbackup {
#Resource
private TimerService timerservice;
#Timeout
public void methodTimeout(Timer timer)
{
System.out.println("timeout");
}
public void settimer(long in)
{
Timer timer=timerservice.createSingleActionTimer(in,new TimerConfig());
}
}
After deploying the application appeared the error message "EJB Timer Service is not available".
To solve the problem i followed these steps:
Access the glash fish admin console (http://localhost:4848)
Go to Configurations->server-config->EJB Container
Select the tab EJB Timer Service
Then fill out Timer Datasource: with your JDBC Resource (i used "jdbc/projecto_final")
Restart the server
As suggested in Set/configure the EJB Timer Service’s DataSource.
This resulted but after sometime the TimerService stopped working. After deploying the application appears the following error messages:
Severe: Exception while loading the app
Severe: Undeployment failed for context /ProjetoEE1
Info: /file:/E:/formacaoJAVA/2moduloJEE/pratica/projecto_final /projfinal2/ProjetoEE1/build/web/WEB-INF/classes/_DEFAULT_PU logout successful
Warning: EJB Timer Service is not available. Timers for application with id 96332697224871936 will not be deleted
The Set/configure the EJB Timer Service’s DataSource also mention this problem, and present a solution in Glassfish DeploymentException: Error in linking security policy for.
The solutions presented in Glassfish DeploymentException: Error in linking security policy for consists basically in delete some files. The answer more voted suggests basically the following:
Stoped the Glassfish server
Deleted all the content from glassfishhome/glassfish/domains/ yourdomainname/generated
Started Glassfish
I have installed the "GlassFish Server 4.1.1", and this doesn´t work.
The second answer more voted suggests the basically the following:
1.All that's needed to fix this problem is delete the entire OSGi cache under $GLASSFISH_HOME/glassfish/domains//osgi-cache
This also doesn´t work.
What i can do? Any help will be very appreciate
Best regards,
Rafael Costa
I have solved the "same" problem in
deleting glassfish/domains/domain-name/generated folder completely
building application again
restarting glassfish application
In my case, I have installed a new version of my application after a Pull/Push operation with GIT and my application has stopped to work. So I know that before this new build my application worked well and that nothing has been changed on Glassfish.
I have found some explanation on another following site
https://dzone.com/articles/solving-ejb-timer-service-not-available-error-in-g-1
The Glassfish application server uses its embedded JAVADB to persist the state of its available EJB timers. Not setting the data resource for the timer service correctly prevents the EJB timers from being restored and eventually from functioning properly. In this case, normally the “EJB timer service not available” error message is returned. This problem prevents any application that uses an EJB timer service from being started or deployed.
There are two procedures available to overcome such blocking situations:
The first solution is to go to JDBC connection pools and double check the health of the Timerpool connection pool by pinging it. If the ping fails then the connection pool needs to be checked or to be redefined.
If pinging the connection pool is successful, then the problem could be the presence of the EJB timer marker file. A marker file is created whenever a problem occurs during the EJB timer service start-up or restore.
Deleting the marker will solve the problem. The marker file "ejb-timer-service-app" located under as-install-parent/glassfish/domains/domain-name/generated/ejb/. Dont forget to restart Glassfish !
Replace
import javax.ejb.Singleton;
With
import javax.inject.Singleton;
It worked for me. I'm using Derby database is it the case for you?
I solved the problem. If i remenber, i created a new JDBC resource and a new JDBC Connection Pool.
The following link explains how to create a JDBC resource and a JDBC Connection Pool.
General Steps for Creating a JDBC Resource
The JDBC resource and the JDBC Connection Pool can be created using the admin console or the asadmin utility.
The following link explains how to use the asadmin utility.Using the asadmin Utility
(I used this utility because in the admin console when i tried to create a JDBC resource and a JDBC Connection Pool appeared an error)
In the admin console, in the created JDBC Resource the field "Pool Name" should equals the name of the created JDBC Connection Pool.
After that i followed these steps:
Configurations->server-config->EJB Container
Select the tab EJB Timer Service
Fill the field Timer Datasource with the name of the JDBC resource.
Restart the server
Any question please feel free.
Best Regards Rafael Santos Costa
Hello I met the same problem if you have glassfish 4.1.1 there is probably an instability in the server with respect to timer.
Solution: update glassfish 4.1 to glassfish 5 and deploy the web application in this new server

Can't configure Glassfish for new JavaMail session

When I go to Glassfish web console localhost 4848 and go to Resources JavaMail and hit the "new" button, I get this error class java.lang.RuntimeException I'm fairly new to Glassfish and am trying to follow the mail tutorials. Can anyone give me some advice on where to start? Thx in advance!!
This is a bug introduced in the GlassFish 4.1.1 release. GlassFish 4.1 should work.
For any one struggling to do this via the Web Console and doesn't want to downgrade, just use the sub-command line option to create the mail session then continue on the web console to add additional properties.
asadmin> create-javamail-resource --mailhost localhost
--mailuser sample --fromaddress sample\#sun\.com mail/MyMailSession
Fortunately I was able to get the email to work. The problem was that they had setup Exchange for an Anonymous user with no security (SMTP not SMTPS). However, I never did get the JavaMail in Glassfish to work. Due to some other reasons, the decision was made to stick with the current version of Glassfish. I did try to go back to 4.1 as noted, but had similar issues in getting JavaMail setup as a Resource. Once I got the basic issue resolved, I abandoned the effort to go back to 4.1, so I'm not sure if that would have changed anything.
Thx

can't deploy ear file on Weblogic 12c

i have EAR file contains jar and war packages.this ear file deploy on glassfish correctly but when deploy this ear file on weblogic 12c, get this error :
Unable to access the selected application.
Error Exception in AppMerge flows' progression
Error Exception in AppMerge flows' progression
Error Unable to resolve deadlock in factory claims
Error Unable to resolve deadlock in factory claims
i check application.xml and name of jar and war packages are correct.anybody have idea for solving this issue ?
I too had this problem and tried everything (schemas, project structure, dependant libs, etc). Finally compared my domain with the sample "medrec", the only difference was that I had added SIP support. After removing this support, I can now deploy my EAR with included WAR and EJBs. I assume this is a bug in 12c...
I too had the same problem and I had to create another domain to resolve the issue.The key here is not to use the eclipse tool to create the the domain as the option to create "Basic Weblogic Domain" is not presented.
The option to create a basic weblogic domain is presented when you launch the weblogic domain creation wizard.
I had faced the exact same problem today. This problem is associated with the way the Domain was created. If you have used "Basic WebLogic SIP Server Domain" then it would occur while installing an ear. You can double check if the Domain is created with Basic SIP or not, go to your Weblogic Server Domain >> bin >> setDomainEnv (cmd or sh) file and check if you have the below properties defined.
-- set WLSS_HOME=C:\Oracle\Middleware\wlserver_12.1\sip
-- set SIP_ENABLED=true
I tried to create the Domain again with JAX-RPC extension instead of Basic SIP and got this problem resolved.

Deploy EJB2 on Weblogic 10.3

I try to deploy ejb2 on weblogic 10.3 but I face a problem the deployed ear can't see new methods added to any ejb session bean. I added the method to remote interface and I added the implementation to bean class. I hope anyone can help. Thanks
I believe WebLogic 10.3 supports EJB3, so you'll have to do some modification. You already have the evidence to prove it.
As you say the old EJBs are working, but it's not reflecting updated methods - I think this is cached.
Drill down on your server to the following path or a similar one
DefaultDomain\servers\DefaultServer\cache\EJBCompilerCache
There will be many folders in there with random names like ff7i19ot3cg6 and l443b5vws35h
Clear out all these folders and redeploy the app

FluentNHibernate blows up in Windows Service but not website

I've got a class library doing all my NHibernate stuff. It also handles all the mapping using Fluent NHibernate - no mapping files to deploy.
This class library is consumed by a number of apps, including a Windows Service running on my computer. Although it works fine in all my web apps, the Windows Service gets this when it tries to use NHibernate:
An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.
at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
at Kctc.NHibernate.KctcSessionFactory.get_SessionFactory() in C:\Kctc\Trunk\Kctc.NHibernate\KctcSessionFactory.cs:line 28
...more stack trace...
I have checked for an InnerException and there doesn't appear to be one. I have no idea what the PotentialReasons collection is, and Google doesn't seem to be forthcoming either.
This is my dev machine, so when I'm working on my web apps they run locally (i.e. using the web server in Visual Studio). The fact that the Windows Service and my dev web apps are running on this same machine suggest it's not to do with trust settings or what have you.
Can anyone suggest what I should try? This is one of those ones where I'm so stumped I can't even think of how to get more information about the problem.
Just a wild guess. NHibernate picks up the hibernate.cfg.xml file from the execution directory. Did you configure the execution directory of the service that it can find this file?
I've found out what the problem is. The Service did not deploy with the required NHibernate.ByteCode.LinFu.dll.
I appear to have an ongoing problem with the Visual Studio compiler not always copying indirect dependencies (i.e. dlls required by class libraries required by the app) into the output folder during the build. I should have thought of this sooner really.
Thanks for racking your brains on my behalf guys.
I bet the name of the connection string is missing from the app.config. For me that message is almost exclusively a missing connection string.
Are you targeting the same database or could it be some sort of schema mismatch between databases?
Could it be authentication issues on the service like you use windows authentication where it can't be used (or the sql authentication that doesn't work)?
It's hard to tell when there is no code, just an exception!
EDIT Are you ever using HttpContext, HostingEnvironment or anything else specific to "web"?