Solution:Error occurred during deployment: Exception while preparing the app : Invalid resource

Problems happened in Glassfish:

When trying to deploy it on my own machine which I used to develop my WS, the deployment successes. But when I try to deploy it on another machine, it fails with this error message:


"Error occurred during deployment: Exception while preparing the app : Invalid resource : java-appbc/movieDB__pm. Please see server.log for more details."

The reason for this error is that I haven't set up proper database connection (both jdbc-connection-pool and jdbc-resource) on the targeting Glassfish server.

The solution is following:

The Admin Console is not very user friendly, so the third way involves altering the configuration file directly.

First find out which data-source you are using: 

in the Projects view of Netbeans, open ->Configuration Files->persistence.xml and find the tag. The content of it is the data source you are using. for example, mine is: java-appbc/movieDB.

Second, locate your domain’s configuration file on your development machine. You can find it through Netbeans’ Services View. Find GlassFish Server, right click it and find properties. You will find your domain folder and domain name. Go to ->config, open domain.xml file.

Thirdly, copy related information from your development machine to the machine you want to deploy your WAR file. These information includes: jdbc-resource whose jndi-name is your data source and related jdbc-connection-pool, and resource-ref. For example, mine is:


      
      
      
      
      
      
      
   


They are under element.

And

.

It’s under element.

Copy that information to the domain config file. Restart your GlassFish and Deploy it again.

It works!

你可能感兴趣的:(Database)